Skip to content

Commit

Permalink
MDL-59368 groups: Add an explicit cancel button
Browse files Browse the repository at this point in the history
Autocomplete already uses Escape keyboard handler - so we can't use it to cancel an edit-inplace thing.
Make an obvious cancel button instead.
  • Loading branch information
Damyon Wiese committed Jul 12, 2017
1 parent 2fa35b8 commit 5a90a7c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion group/classes/output/user_groups_editable.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ public static function update($itemid, $newvalue) {

$course = get_course($courseid);
$user = core_user::get_user($userid);
return new self($course, $context, $user, $coursegroups, $groupids);
return new self($course, $context, $user, $coursegroups, array_values($groupids));
}
}
18 changes: 16 additions & 2 deletions lib/amd/src/inplace_editable.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
.attr('for', inputelement.attr('id')),
options = args.options,
attributes = args.attributes,
saveelement = $('<a href="#"></a>');
saveelement = $('<a href="#"></a>'),
cancelelement = $('<a href="#"></a>');

for (i in options) {
inputelement
Expand All @@ -228,11 +229,19 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
saveelement.append(html);
return;
}).fail(notification.exception);

str.get_string('cancel', 'core').then(function(s) {
return templates.renderPix('e/cancel', 'core', s);
}).then(function(html) {
cancelelement.append(html);
return;
}).fail(notification.exception);

el.html('')
.append(lbl)
.append(inputelement)
.append(saveelement);
.append(saveelement)
.append(cancelelement);

inputelement.focus();
inputelement.select();
Expand All @@ -254,6 +263,11 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
var val = JSON.stringify(inputelement.val());
turnEditingOff(el);
updateValue(el, val);
e.preventDefault();
});
cancelelement.on('click', function(e) {
turnEditingOff(el);
e.preventDefault();
});
};

Expand Down
1 change: 1 addition & 0 deletions lib/classes/output/icon_system_fontawesome.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function get_core_icon_map() {
'core:e/backward' => 'fa-undo',
'core:e/bold' => 'fa-bold',
'core:e/bullet_list' => 'fa-list-ul',
'core:e/cancel' => 'fa-times',
'core:e/cell_props' => 'fa-info',
'core:e/cite' => 'fa-quote-right',
'core:e/cleanup_messy_code' => 'fa-eraser',
Expand Down
Binary file added pix/e/cancel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions pix/e/cancel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5a90a7c

Please sign in to comment.