MDL-87444 core: Add 'extraclasses' param to drag_handle
Add new 'extraclasses' parameter to drag_handle template. That will help to customise the button sizing and extra styles.
This commit is contained in:
@@ -212,10 +212,19 @@ class edit_table extends XMLDBAction {
|
||||
$row = 0;
|
||||
foreach ($fields as $field) {
|
||||
// Drag element up/down.
|
||||
$move = (count($fields) > 1) ? html_writer::span($OUTPUT->render_from_template('core/drag_handle',
|
||||
['movetitle' => get_string('movecontent', 'moodle', $field->getName())]), '',
|
||||
['data-action' => 'move_updown_field', 'data-dir' => str_replace($CFG->dirroot, '', $dirpath),
|
||||
'data-table' => $table->getName(), 'data-field' => $field->getName()]) : '';
|
||||
$draghandle = html_writer::span(
|
||||
content: $OUTPUT->render_from_template(
|
||||
'core/drag_handle',
|
||||
['movetitle' => get_string('movecontent', 'moodle', $field->getName()), 'extraclasses' => 'me-2']
|
||||
),
|
||||
attributes: [
|
||||
'data-action' => 'move_updown_field',
|
||||
'data-dir' => str_replace($CFG->dirroot, '', $dirpath),
|
||||
'data-table' => $table->getName(),
|
||||
'data-field' => $field->getName(),
|
||||
]
|
||||
);
|
||||
$move = (count($fields) > 1) ? $draghandle : '';
|
||||
// The field name (link to edit - if the field has no uses)
|
||||
if (!$structure->getFieldUses($table->getName(), $field->getName())) {
|
||||
$f = '<a href="index.php?action=edit_field&field=' .$field->getName() . '&table=' . $table->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">' . $field->getName() . '</a>';
|
||||
@@ -263,10 +272,19 @@ class edit_table extends XMLDBAction {
|
||||
$row = 0;
|
||||
foreach ($keys as $key) {
|
||||
// Drag element up/down.
|
||||
$move = (count($keys) > 1) ? html_writer::span($OUTPUT->render_from_template('core/drag_handle',
|
||||
['movetitle' => get_string('movecontent', 'moodle', $key->getName())]), '',
|
||||
['data-action' => 'move_updown_key', 'data-dir' => str_replace($CFG->dirroot, '', $dirpath),
|
||||
'data-table' => $table->getName(), 'data-key' => $key->getName()]) : '';
|
||||
$draghandle = html_writer::span(
|
||||
content: $OUTPUT->render_from_template(
|
||||
'core/drag_handle',
|
||||
['movetitle' => get_string('movecontent', 'moodle', $field->getName()), 'extraclasses' => 'me-2']
|
||||
),
|
||||
attributes: [
|
||||
'data-action' => 'move_updown_key',
|
||||
'data-dir' => str_replace($CFG->dirroot, '', $dirpath),
|
||||
'data-table' => $table->getName(),
|
||||
'data-key' => $key->getName(),
|
||||
]
|
||||
);
|
||||
$move = (count($keys) > 1) ? $draghandle : '';
|
||||
// The key name (link to edit - if the key has no uses)
|
||||
if (!$structure->getKeyUses($table->getName(), $key->getName())) {
|
||||
$k = '<a href="index.php?action=edit_key&key=' .$key->getName() . '&table=' . $table->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">' . $key->getName() . '</a>';
|
||||
@@ -309,10 +327,19 @@ class edit_table extends XMLDBAction {
|
||||
$row = 0;
|
||||
foreach ($indexes as $index) {
|
||||
// Drag element up/down.
|
||||
$move = (count($indexes) > 1) ? html_writer::span($OUTPUT->render_from_template('core/drag_handle',
|
||||
['movetitle' => get_string('movecontent', 'moodle', $index->getName())]), '',
|
||||
['data-action' => 'move_updown_index', 'data-dir' => str_replace($CFG->dirroot, '', $dirpath),
|
||||
'data-table' => $table->getName(), 'data-index' => $index->getName()]) : '';
|
||||
$draghandle = html_writer::span(
|
||||
content: $OUTPUT->render_from_template(
|
||||
'core/drag_handle',
|
||||
['movetitle' => get_string('movecontent', 'moodle', $field->getName()), 'extraclasses' => 'me-2']
|
||||
),
|
||||
attributes: [
|
||||
'data-action' => 'move_updown_index',
|
||||
'data-dir' => str_replace($CFG->dirroot, '', $dirpath),
|
||||
'data-table' => $table->getName(),
|
||||
'data-index' => $index->getName(),
|
||||
]
|
||||
);
|
||||
$move = (count($indexes) > 1) ? $draghandle : '';
|
||||
// The index name (link to edit)
|
||||
$i = '<a href="index.php?action=edit_index&index=' .$index->getName() . '&table=' . $table->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">' . $index->getName() . '</a>';
|
||||
// Calculate buttons
|
||||
|
||||
@@ -183,10 +183,17 @@ class edit_xml_file extends XMLDBAction {
|
||||
$row = 0;
|
||||
foreach ($tables as $table) {
|
||||
// Drag element for sortorder.
|
||||
$move = html_writer::span($OUTPUT->render_from_template('core/drag_handle',
|
||||
['movetitle' => get_string('movecontent', 'moodle', $table->getName())]), '',
|
||||
['data-action' => 'move_updown_table', 'data-dir' => str_replace($CFG->dirroot, '', $dirpath),
|
||||
'data-table' => $table->getName()]);
|
||||
$move = html_writer::span(
|
||||
content: $OUTPUT->render_from_template(
|
||||
'core/drag_handle',
|
||||
['movetitle' => get_string('movecontent', 'moodle', $table->getName()), 'extraclasses' => 'me-2']
|
||||
),
|
||||
attributes: [
|
||||
'data-action' => 'move_updown_table',
|
||||
'data-dir' => str_replace($CFG->dirroot, '', $dirpath),
|
||||
'data-table' => $table->getName(),
|
||||
]
|
||||
);
|
||||
// The table name (link to edit table)
|
||||
$t = '<a href="index.php?action=edit_table&table=' . $table->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">' . $table->getName() . '</a>';
|
||||
// Calculate buttons
|
||||
|
||||
@@ -21,9 +21,16 @@
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"movetitle": "Move this element"
|
||||
"movetitle": "Move this element",
|
||||
"extraclasses": "icon-size-2"
|
||||
}
|
||||
}}
|
||||
<button type="button" class="btn btn-icon" aria-haspopup="true" data-drag-type="move" title="{{movetitle}}" aria-label="{{movetitle}}">
|
||||
<button type="button"
|
||||
class="btn btn-icon {{$ extraclasses }}{{extraclasses}}{{/ extraclasses }}"
|
||||
title="{{movetitle}}"
|
||||
data-drag-type="move"
|
||||
aria-haspopup="true"
|
||||
aria-label="{{movetitle}}"
|
||||
>
|
||||
{{#pix}} i/dragdrop, core {{/pix}}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user