Merge branch 'MDL-59759-master-2' of git://github.com/junpataleta/moodle
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/str","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_factory","core/modal_events","core_calendar/repository","core_calendar/events"],function(a,b,c,d,e,f,g,h,i,j){var k=!1,l={ROOT:"[data-region='summary-modal-container']",EDIT_BUTTON:'[data-action="edit"]',DELETE_BUTTON:'[data-action="delete"]'},m=function(a){e.call(this,a)};return m.TYPE="core_calendar-event_summary",m.prototype=Object.create(e.prototype),m.prototype.constructor=m,m.prototype.getEditButton=function(){return"undefined"==typeof this.editButton&&(this.editButton=this.getFooter().find(l.EDIT_BUTTON)),this.editButton},m.prototype.getDeleteButton=function(){return"undefined"==typeof this.deleteButton&&(this.deleteButton=this.getFooter().find(l.DELETE_BUTTON)),this.deleteButton},m.prototype.getEventId=function(){return this.getBody().find(l.ROOT).attr("data-event-id")},m.prototype.getEditUrl=function(){return this.getBody().find(l.ROOT).attr("data-edit-url")},m.prototype.isActionEvent=function(){return"true"==this.getBody().find(l.ROOT).attr("data-action-event")},m.prototype.registerEventListeners=function(){e.prototype.registerEventListeners.call(this);var f=g.create({type:g.types.CONFIRM},this.getDeleteButton()).then(function(b){return b.getRoot().on(h.yes,function(){var b=this.getEventId();i.deleteEvent(b).then(function(){a("body").trigger(j.deleted,[b]),this.hide()}.bind(this))["catch"](c.exception)}.bind(this)),b}.bind(this));this.getRoot().on(h.bodyRendered,function(){var a=this.getBody().find(l.ROOT).attr("data-event-title");f.then(function(c){c.setBody(b.get_string("confirmeventdelete","core_calendar",a))})}.bind(this)),d.define(this.getEditButton(),[d.events.activate]),this.getEditButton().on(d.events.activate,function(b,c){this.isActionEvent()?a("body").trigger(j.editActionEvent,[this.getEditUrl()]):a("body").trigger(j.editEvent,[this.getEventId()]),this.hide(),b.preventDefault(),b.stopPropagation(),c.originalEvent.preventDefault(),c.originalEvent.stopPropagation()}.bind(this))},k||(f.register(m.TYPE,m,"core_calendar/event_summary_modal"),k=!0),m});
|
||||
define(["jquery","core/str","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_factory","core/modal_events","core_calendar/repository","core_calendar/events"],function(a,b,c,d,e,f,g,h,i,j){function k(d,e){var f=[{key:"deleteevent",component:"calendar"},{key:"confirmeventdelete",component:"calendar",param:e}],k=d.getEventId(),l=b.get_strings(f),m=g.create({type:g.types.SAVE_CANCEL},d.getDeleteButton());a.when(l,m).then(function(b,e){return e.setTitle(b[0]),e.setBody(b[1]),e.setSaveButtonText(b[0]),e.getRoot().on(h.save,function(){i.deleteEvent(k).then(function(){a("body").trigger(j.deleted,[k]),d.hide()})["catch"](c.exception)}),e}).fail(c.exception)}var l=!1,m={ROOT:"[data-region='summary-modal-container']",EDIT_BUTTON:'[data-action="edit"]',DELETE_BUTTON:'[data-action="delete"]'},n=function(a){e.call(this,a)};return n.TYPE="core_calendar-event_summary",n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.prototype.getEditButton=function(){return"undefined"==typeof this.editButton&&(this.editButton=this.getFooter().find(m.EDIT_BUTTON)),this.editButton},n.prototype.getDeleteButton=function(){return"undefined"==typeof this.deleteButton&&(this.deleteButton=this.getFooter().find(m.DELETE_BUTTON)),this.deleteButton},n.prototype.getEventId=function(){return this.getBody().find(m.ROOT).attr("data-event-id")},n.prototype.getEditUrl=function(){return this.getBody().find(m.ROOT).attr("data-edit-url")},n.prototype.isActionEvent=function(){return"true"==this.getBody().find(m.ROOT).attr("data-action-event")},n.prototype.registerEventListeners=function(){e.prototype.registerEventListeners.call(this),this.getRoot().on(h.bodyRendered,function(){var a=this.getBody().find(m.ROOT).attr("data-event-title");k(this,a)}.bind(this)),d.define(this.getEditButton(),[d.events.activate]),this.getEditButton().on(d.events.activate,function(b,c){this.isActionEvent()?a("body").trigger(j.editActionEvent,[this.getEditUrl()]):a("body").trigger(j.editEvent,[this.getEventId()]),this.hide(),b.preventDefault(),b.stopPropagation(),c.originalEvent.preventDefault(),c.originalEvent.stopPropagation()}.bind(this))},l||(f.register(n.TYPE,n,"core_calendar/event_summary_modal"),l=!0),n});
|
||||
@@ -118,33 +118,11 @@ define(['jquery', 'core/str', 'core/notification', 'core/custom_interaction_even
|
||||
// Apply parent event listeners.
|
||||
Modal.prototype.registerEventListeners.call(this);
|
||||
|
||||
var confirmPromise = ModalFactory.create(
|
||||
{
|
||||
type: ModalFactory.types.CONFIRM
|
||||
},
|
||||
this.getDeleteButton()
|
||||
).then(function(modal) {
|
||||
modal.getRoot().on(ModalEvents.yes, function() {
|
||||
var eventId = this.getEventId();
|
||||
|
||||
CalendarRepository.deleteEvent(eventId)
|
||||
.then(function() {
|
||||
$('body').trigger(CalendarEvents.deleted, [eventId]);
|
||||
this.hide();
|
||||
}.bind(this))
|
||||
.catch(Notification.exception);
|
||||
}.bind(this));
|
||||
|
||||
return modal;
|
||||
}.bind(this));
|
||||
|
||||
// We have to wait for the modal to finish rendering in order to ensure that
|
||||
// the data-event-title property is available to use as the modal title.
|
||||
this.getRoot().on(ModalEvents.bodyRendered, function() {
|
||||
var eventTitle = this.getBody().find(SELECTORS.ROOT).attr('data-event-title');
|
||||
confirmPromise.then(function(modal) {
|
||||
modal.setBody(Str.get_string('confirmeventdelete', 'core_calendar', eventTitle));
|
||||
});
|
||||
prepareDeleteAction(this, eventTitle);
|
||||
}.bind(this));
|
||||
|
||||
CustomEvents.define(this.getEditButton(), [
|
||||
@@ -173,6 +151,48 @@ define(['jquery', 'core/str', 'core/notification', 'core/custom_interaction_even
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Prepares the action for the summary modal's delete action.
|
||||
*
|
||||
* @param {ModalEventSummary} summaryModal The summary modal instance.
|
||||
* @param {string} eventTitle The event title.
|
||||
*/
|
||||
function prepareDeleteAction(summaryModal, eventTitle) {
|
||||
var deleteStrings = [
|
||||
{
|
||||
key: 'deleteevent',
|
||||
component: 'calendar'
|
||||
},
|
||||
{
|
||||
key: 'confirmeventdelete',
|
||||
component: 'calendar',
|
||||
param: eventTitle
|
||||
}
|
||||
];
|
||||
var eventId = summaryModal.getEventId();
|
||||
var stringsPromise = Str.get_strings(deleteStrings);
|
||||
var deletePromise = ModalFactory.create(
|
||||
{
|
||||
type: ModalFactory.types.SAVE_CANCEL
|
||||
},
|
||||
summaryModal.getDeleteButton()
|
||||
);
|
||||
|
||||
$.when(stringsPromise, deletePromise).then(function(strings, deleteModal) {
|
||||
deleteModal.setTitle(strings[0]);
|
||||
deleteModal.setBody(strings[1]);
|
||||
deleteModal.setSaveButtonText(strings[0]);
|
||||
deleteModal.getRoot().on(ModalEvents.save, function() {
|
||||
CalendarRepository.deleteEvent(eventId).then(function() {
|
||||
$('body').trigger(CalendarEvents.deleted, [eventId]);
|
||||
summaryModal.hide();
|
||||
return;
|
||||
}).catch(Notification.exception);
|
||||
});
|
||||
return deleteModal;
|
||||
}).fail(Notification.exception);
|
||||
}
|
||||
|
||||
// Automatically register with the modal registry the first time this module is imported so that you can create modals
|
||||
// of this type using the modal factory.
|
||||
if (!registered) {
|
||||
|
||||
@@ -104,7 +104,7 @@ Feature: Perform basic calendar functionality
|
||||
When I follow "This month"
|
||||
And I click on "Really awesome event!" "link"
|
||||
And I click on "Delete" "button"
|
||||
And I click on "Yes" "button"
|
||||
And I click on "Delete event" "button"
|
||||
And I wait to be redirected
|
||||
Then I should not see "Really awesome event!"
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/notification","core/custom_interaction_events","core/modal","core/modal_events"],function(a,b,c,d,e){var f={YES_BUTTON:'[data-action="yes"]',NO_BUTTON:'[data-action="no"]'},g=function(a){d.call(this,a),this.getFooter().find(f.YES_BUTTON).length||b.exception({message:'No "yes" button found'}),this.getFooter().find(f.NO_BUTTON).length||b.exception({message:'No "no" button found'})};return g.prototype=Object.create(d.prototype),g.prototype.constructor=g,g.prototype.setFooter=function(){b.exception({message:"Can not change the footer of a confirm modal"})},g.prototype.registerEventListeners=function(){d.prototype.registerEventListeners.call(this),this.getModal().on(c.events.activate,f.YES_BUTTON,function(b,c){var d=a.Event(e.yes);this.getRoot().trigger(d,this),d.isDefaultPrevented()||(this.hide(),c.originalEvent.preventDefault())}.bind(this)),this.getModal().on(c.events.activate,f.NO_BUTTON,function(b,c){var d=a.Event(e.no);this.getRoot().trigger(d,this),d.isDefaultPrevented()||(this.hide(),c.originalEvent.preventDefault())}.bind(this))},g});
|
||||
define(["jquery","core/custom_interaction_events","core/modal_events","core/modal_save_cancel","core/log"],function(a,b,c,d,e){var f=function(a){e.warn("The CONFIRM modal type has been deprecated and should not be used anymore. Please use the SAVE_CANCEL modal type instead."),d.call(this,a)};return f.prototype=Object.create(d.prototype),f.prototype.constructor=f,f});
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
define([],function(){return{shown:"modal:shown",hidden:"modal:hidden",destroyed:"modal:destroyed",bodyRendered:"modal:bodyRendered",save:"modal-save-cancel:save",cancel:"modal-save-cancel:cancel",yes:"modal-confirm:yes",no:"modal-confirm:no"}});
|
||||
define([],function(){return{shown:"modal:shown",hidden:"modal:hidden",destroyed:"modal:destroyed",bodyRendered:"modal:bodyRendered",save:"modal-save-cancel:save",cancel:"modal-save-cancel:cancel",yes:"modal-save-cancel:save",no:"modal-save-cancel:cancel"}});
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/modal_events","core/modal_registry","core/modal","core/modal_save_cancel","core/modal_confirm","core/modal_cancel","core/templates","core/notification","core/custom_interaction_events"],function(a,b,c,d,e,f,g,h,i,j){var k={DEFAULT:"core/modal",SAVE_CANCEL:"core/modal_save_cancel",CONFIRM:"core/modal_confirm",CANCEL:"core/modal_cancel"},l={DEFAULT:"DEFAULT",SAVE_CANCEL:"SAVE_CANCEL",CONFIRM:"CONFIRM",CANCEL:"CANCEL"};c.register(l.DEFAULT,d,k.DEFAULT),c.register(l.SAVE_CANCEL,e,k.SAVE_CANCEL),c.register(l.CONFIRM,f,k.CONFIRM),c.register(l.CANCEL,g,k.CANCEL);var m=function(a,c){if("undefined"!=typeof c){if(Array.isArray(c)){var d=c[1];c=c[0],j.define(c,[j.events.activate]),c.on(j.events.activate,d,function(b,c){a.then(function(a){return a.show(),a}),c.originalEvent.preventDefault()})}else j.define(c,[j.events.activate]),c.on(j.events.activate,function(b,c){a.then(function(a){return a.show(),a}),c.originalEvent.preventDefault()});a.then(function(a){return a.getRoot().on(b.hidden,function(){c.focus()}),a})}},n=function(b,c){c=a(c);var d=b.module,e=new d(c);return e},o=function(b,c,d){var e=b.template,f=h.render(e,c).then(function(c){var d=a(c);return n(b,d)}).fail(i.exception);return m(f,d),f},p=function(a,b){var d=a.type||l.DEFAULT,e=!!a.large,f=null,g={};return f=c.get(d),f||i.exception({message:"Unable to find modal of type: "+d}),"undefined"!=typeof a.templateContext&&(g=a.templateContext),o(f,g,b).then(function(b){return"undefined"!=typeof a.title&&b.setTitle(a.title),"undefined"!=typeof a.body&&b.setBody(a.body),"undefined"!=typeof a.footer&&b.setFooter(a.footer),e&&b.setLarge(),b})};return{create:p,types:l}});
|
||||
define(["jquery","core/modal_events","core/modal_registry","core/modal","core/modal_save_cancel","core/modal_confirm","core/modal_cancel","core/templates","core/notification","core/custom_interaction_events"],function(a,b,c,d,e,f,g,h,i,j){var k={DEFAULT:"core/modal",SAVE_CANCEL:"core/modal_save_cancel",CONFIRM:"core/modal_save_cancel",CANCEL:"core/modal_cancel"},l={DEFAULT:"DEFAULT",SAVE_CANCEL:"SAVE_CANCEL",CONFIRM:"CONFIRM",CANCEL:"CANCEL"};c.register(l.DEFAULT,d,k.DEFAULT),c.register(l.SAVE_CANCEL,e,k.SAVE_CANCEL),c.register(l.CONFIRM,f,k.CONFIRM),c.register(l.CANCEL,g,k.CANCEL);var m=function(a,c){if("undefined"!=typeof c){if(Array.isArray(c)){var d=c[1];c=c[0],j.define(c,[j.events.activate]),c.on(j.events.activate,d,function(b,c){a.then(function(a){return a.show(),a}),c.originalEvent.preventDefault()})}else j.define(c,[j.events.activate]),c.on(j.events.activate,function(b,c){a.then(function(a){return a.show(),a}),c.originalEvent.preventDefault()});a.then(function(a){return a.getRoot().on(b.hidden,function(){c.focus()}),a})}},n=function(b,c){c=a(c);var d=b.module,e=new d(c);return e},o=function(b,c,d){var e=b.template,f=h.render(e,c).then(function(c){var d=a(c);return n(b,d)}).fail(i.exception);return m(f,d),f},p=function(a,b){var d=a.type||l.DEFAULT,e=!!a.large,f=null,g={};return f=c.get(d),f||i.exception({message:"Unable to find modal of type: "+d}),"undefined"!=typeof a.templateContext&&(g=a.templateContext),o(f,g,b).then(function(b){return"undefined"!=typeof a.title&&b.setTitle(a.title),"undefined"!=typeof a.body&&b.setBody(a.body),"undefined"!=typeof a.footer&&b.setFooter(a.footer),e&&b.setLarge(),b})};return{create:p,types:l}});
|
||||
@@ -14,21 +14,19 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Contain the logic for the save/cancel modal.
|
||||
* Contain the logic for the yes/no confirmation modal.
|
||||
* This has been deprecated and should not be used anymore. Please use core/modal_save_cancel instead.
|
||||
* See MDL-59759.
|
||||
*
|
||||
* @module core/modal_save_cancel
|
||||
* @class modal_save_cancel
|
||||
* @deprecated Since Moodle 3.4
|
||||
* @module core/modal_confirm
|
||||
* @class modal_confirm
|
||||
* @package core
|
||||
* @copyright 2016 Ryan Wyllie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/notification', 'core/custom_interaction_events', 'core/modal', 'core/modal_events'],
|
||||
function($, Notification, CustomEvents, Modal, ModalEvents) {
|
||||
|
||||
var SELECTORS = {
|
||||
YES_BUTTON: '[data-action="yes"]',
|
||||
NO_BUTTON: '[data-action="no"]',
|
||||
};
|
||||
define(['jquery', 'core/custom_interaction_events', 'core/modal_events', 'core/modal_save_cancel', 'core/log'],
|
||||
function($, CustomEvents, ModalEvents, ModalSaveCancel, Log) {
|
||||
|
||||
/**
|
||||
* Constructor for the Modal.
|
||||
@@ -36,57 +34,13 @@ define(['jquery', 'core/notification', 'core/custom_interaction_events', 'core/m
|
||||
* @param {object} root The root jQuery element for the modal
|
||||
*/
|
||||
var ModalConfirm = function(root) {
|
||||
Modal.call(this, root);
|
||||
|
||||
if (!this.getFooter().find(SELECTORS.YES_BUTTON).length) {
|
||||
Notification.exception({message: 'No "yes" button found'});
|
||||
}
|
||||
|
||||
if (!this.getFooter().find(SELECTORS.NO_BUTTON).length) {
|
||||
Notification.exception({message: 'No "no" button found'});
|
||||
}
|
||||
Log.warn("The CONFIRM modal type has been deprecated and should not be used anymore." +
|
||||
" Please use the SAVE_CANCEL modal type instead.");
|
||||
ModalSaveCancel.call(this, root);
|
||||
};
|
||||
|
||||
ModalConfirm.prototype = Object.create(Modal.prototype);
|
||||
ModalConfirm.prototype = Object.create(ModalSaveCancel.prototype);
|
||||
ModalConfirm.prototype.constructor = ModalConfirm;
|
||||
|
||||
/**
|
||||
* Override parent implementation to prevent changing the footer content.
|
||||
*/
|
||||
ModalConfirm.prototype.setFooter = function() {
|
||||
Notification.exception({message: 'Can not change the footer of a confirm modal'});
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set up all of the event handling for the modal.
|
||||
*
|
||||
* @method registerEventListeners
|
||||
*/
|
||||
ModalConfirm.prototype.registerEventListeners = function() {
|
||||
// Apply parent event listeners.
|
||||
Modal.prototype.registerEventListeners.call(this);
|
||||
|
||||
this.getModal().on(CustomEvents.events.activate, SELECTORS.YES_BUTTON, function(e, data) {
|
||||
var yesEvent = $.Event(ModalEvents.yes);
|
||||
this.getRoot().trigger(yesEvent, this);
|
||||
|
||||
if (!yesEvent.isDefaultPrevented()) {
|
||||
this.hide();
|
||||
data.originalEvent.preventDefault();
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
this.getModal().on(CustomEvents.events.activate, SELECTORS.NO_BUTTON, function(e, data) {
|
||||
var noEvent = $.Event(ModalEvents.no);
|
||||
this.getRoot().trigger(noEvent, this);
|
||||
|
||||
if (!noEvent.isDefaultPrevented()) {
|
||||
this.hide();
|
||||
data.originalEvent.preventDefault();
|
||||
}
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
return ModalConfirm;
|
||||
});
|
||||
|
||||
@@ -32,8 +32,9 @@ define([], function() {
|
||||
// ModalSaveCancel events.
|
||||
save: 'modal-save-cancel:save',
|
||||
cancel: 'modal-save-cancel:cancel',
|
||||
// ModalConfirm events.
|
||||
yes: 'modal-confirm:yes',
|
||||
no: 'modal-confirm:no',
|
||||
// ModalConfirm events. Deprecated since Moodle 3.4. See MDL-59759.
|
||||
// Point core/modal_confirm events to save/cancel events of core/modal_save_cancel.
|
||||
yes: 'modal-save-cancel:save',
|
||||
no: 'modal-save-cancel:cancel',
|
||||
};
|
||||
});
|
||||
|
||||
@@ -32,7 +32,8 @@ define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal',
|
||||
var TEMPLATES = {
|
||||
DEFAULT: 'core/modal',
|
||||
SAVE_CANCEL: 'core/modal_save_cancel',
|
||||
CONFIRM: 'core/modal_confirm',
|
||||
// Deprecated since Moodle 3.4. Point template to core/modal_save_cancel instead. See MDL-59759.
|
||||
CONFIRM: 'core/modal_save_cancel',
|
||||
CANCEL: 'core/modal_cancel',
|
||||
};
|
||||
|
||||
@@ -40,6 +41,7 @@ define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal',
|
||||
var TYPES = {
|
||||
DEFAULT: 'DEFAULT',
|
||||
SAVE_CANCEL: 'SAVE_CANCEL',
|
||||
// Deprecated since Moodle 3.4. See MDL-59759.
|
||||
CONFIRM: 'CONFIRM',
|
||||
CANCEL: 'CANCEL',
|
||||
};
|
||||
@@ -47,6 +49,7 @@ define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal',
|
||||
// Register the common set of modals.
|
||||
ModalRegistry.register(TYPES.DEFAULT, Modal, TEMPLATES.DEFAULT);
|
||||
ModalRegistry.register(TYPES.SAVE_CANCEL, ModalSaveCancel, TEMPLATES.SAVE_CANCEL);
|
||||
// Deprecated since Moodle 3.4. See MDL-59759.
|
||||
ModalRegistry.register(TYPES.CONFIRM, ModalConfirm, TEMPLATES.CONFIRM);
|
||||
ModalRegistry.register(TYPES.CANCEL, ModalCancel, TEMPLATES.CANCEL);
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core/modal_confirm
|
||||
|
||||
Moodle template for a confirmation modal.
|
||||
|
||||
The purpose of this template is to render a modal.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* body HTML content for the boday
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
}
|
||||
}}
|
||||
|
||||
{{< core/modal }}
|
||||
{{$title}}{{#str}} confirm {{/str}}{{/title}}
|
||||
{{$body}}{{#str}} areyousure {{/str}}{{/body}}
|
||||
{{$footer}}
|
||||
<button type="button" class="btn btn-primary" data-action="yes">{{#str}} yes {{/str}}</button>
|
||||
<button type="button" class="btn btn-secondary" data-action="no">{{#str}} no {{/str}}</button>
|
||||
{{/footer}}
|
||||
{{/ core/modal }}
|
||||
@@ -42,6 +42,8 @@ information provided here is intended especially for developers.
|
||||
close the suggestions popup immediately after an option has been selected. If not specified, it defaults to true for single-select
|
||||
elements and false for multiple-select elements.
|
||||
* user_can_view_profile() now also checks the moodle/user:viewalldetails capability.
|
||||
* The core/modal_confirm dialogue has been deprecated. Please use the core/modal_save_cancel dialogue instead. Please ensure you
|
||||
update to use the ModalEvents.save and ModalEvents.cancel events instead of their yes/no counterparts.
|
||||
|
||||
=== 3.3.1 ===
|
||||
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -531,19 +531,26 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
|
||||
return;
|
||||
}
|
||||
|
||||
Str.get_strings([
|
||||
var stringsPromise = Str.get_strings([
|
||||
{key: 'confirm'},
|
||||
{key: 'deleteallconfirm', component: 'message'}
|
||||
]).then(function(s) {
|
||||
return ModalFactory.create({
|
||||
title: s[0],
|
||||
type: ModalFactory.types.CONFIRM,
|
||||
body: s[1]
|
||||
}, this.messageArea.find(SELECTORS.DELETEALLMESSAGES));
|
||||
}.bind(this)).then(function(modal) {
|
||||
{key: 'deleteallconfirm', component: 'message'},
|
||||
{key: 'delete'}
|
||||
]);
|
||||
var deleteModalPromise = ModalFactory.create(
|
||||
{
|
||||
type: ModalFactory.types.SAVE_CANCEL
|
||||
},
|
||||
this.messageArea.find(SELECTORS.DELETEALLMESSAGES)
|
||||
);
|
||||
|
||||
$.when(stringsPromise, deleteModalPromise).then(function(s, modal) {
|
||||
modal.setTitle(s[0]);
|
||||
modal.setBody(s[1]);
|
||||
modal.setSaveButtonText(s[2]);
|
||||
|
||||
this._confirmationModal = modal;
|
||||
// Only delete the conversation if the user agreed in the confirmation modal.
|
||||
modal.getRoot().on(ModalEvents.yes, function() {
|
||||
modal.getRoot().on(ModalEvents.save, function() {
|
||||
var otherUserId = this._getUserId();
|
||||
var request = {
|
||||
methodname: 'core_message_delete_conversation',
|
||||
|
||||
@@ -19,7 +19,7 @@ Feature: Delete all messages
|
||||
And I click on "start-delete-messages" "message_area_action"
|
||||
And I click on "Delete all" "button"
|
||||
# Confirm dialogue.
|
||||
And I click on "Yes" "button"
|
||||
And I click on "Delete" "button" in the ".modal-footer" "css_element"
|
||||
# Confirm the interface is immediately updated.
|
||||
Then I should not see "User 2" in the "conversations" "message_area_region_content"
|
||||
# Confirm the changes are persisted.
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
define(["core/templates","jquery","core/str","core/config","core/notification","core/modal_factory","core/modal_events","core/fragment","core/ajax"],function(a,b,c,d,e,f,g,h,i){var j={EDIT_ENROLMENT:'[data-action="editenrolment"]',SHOW_DETAILS:'[data-action="showdetails"]',UNENROL:'[data-action="unenrol"]'},k=function(a){this.contextid=a.contextid,this.courseid=a.courseid,this.bindEditEnrol(),this.bindUnenrol(),this.bindStatusDetails()};return k.prototype.courseid=0,k.prototype.bindEditEnrol=function(){var a=this;b(j.EDIT_ENROLMENT).click(function(d){d.preventDefault();var h=b(this),i=h.parent(),j=i.data("fullname"),k=h.attr("rel");b.when(c.get_string("edituserenrolment","enrol",j)).then(function(a){return f.create({large:!0,title:a,type:f.types.SAVE_CANCEL})}).done(function(b){b.getRoot().on(g.save,function(c){c.preventDefault(),a.submitEditFormAjax(b)}),b.getRoot().on(g.hidden,function(){b.destroy()}),b.setBody(a.getBody(k)),b.show()}).fail(e.exception)})},k.prototype.bindUnenrol=function(){b(j.UNENROL).click(function(a){a.preventDefault();var h=b(this),i=h.parent(),j=[{key:"unenrol",component:"enrol"},{key:"unenrolconfirm",component:"enrol",param:{user:i.data("fullname"),course:i.data("coursename")}}];b.when(c.get_strings(j)).then(function(a){var b=a[0],c=a[1];return f.create({body:c,large:!0,title:b,type:f.types.CONFIRM})}).done(function(a){a.getRoot().on(g.yes,function(){var a={confirm:1,sesskey:d.sesskey,ue:b(h).attr("rel")};window.location.href=d.wwwroot+"/enrol/unenroluser.php?"+b.param(a)}),a.getRoot().on(g.hidden,function(){a.destroy()}),a.show()}).fail(e.exception)})},k.prototype.bindStatusDetails=function(){b(j.SHOW_DETAILS).click(function(d){d.preventDefault();var h=b(this),i=h.parent(),k={fullname:i.data("fullname"),coursename:i.data("coursename"),enrolinstancename:i.data("enrolinstancename"),status:i.data("status"),statusclass:i.find("span").attr("class"),timestart:i.data("timestart"),timeend:i.data("timeend")},l=[{key:"enroldetails",component:"enrol"}],m=h.next(j.EDIT_ENROLMENT);m.length&&(k.editenrollink=b("<div>").append(m.clone()).html());var n=c.get_strings(l),o=f.create({large:!0,type:f.types.CANCEL});b.when(n,o).done(function(c,d){var e=a.render("core_user/status_details",k);d.setTitle(c[0]),d.setBody(e),m.length&&d.getRoot().on("click",j.EDIT_ENROLMENT,function(a){a.preventDefault(),d.hide(),b(m).trigger("click")}),d.show(),d.getRoot().on(g.hidden,function(){d.destroy()})}).fail(e.exception)})},k.prototype.submitEditFormAjax=function(a){var c=this,d=a.getRoot().find("form"),f=b(d).find('[name="ue"]').val(),g=b(d).find('[name="status"]').val(),h={courseid:this.courseid,ueid:f,status:g},j=b(d).find('[name="timestart[enabled]"]');if(j.is(":checked")){var k=b(d).find('[name="timestart[year]"]').val(),l=b(d).find('[name="timestart[month]"]').val()-1,m=b(d).find('[name="timestart[day]"]').val(),n=b(d).find('[name="timestart[hour]"]').val(),o=b(d).find('[name="timestart[minute]"]').val(),p=new Date(k,l,m,n,o);h.timestart=p.getTime()/1e3}var q=b(d).find('[name="timeend[enabled]"]');if(q.is(":checked")){var r=b(d).find('[name="timeend[year]"]').val(),s=b(d).find('[name="timeend[month]"]').val()-1,t=b(d).find('[name="timeend[day]"]').val(),u=b(d).find('[name="timeend[hour]"]').val(),v=b(d).find('[name="timeend[minute]"]').val(),w=new Date(r,s,t,u,v);h.timeend=w.getTime()/1e3}var x={methodname:"core_enrol_edit_user_enrolment",args:h};i.call([x])[0].done(function(b){if(b.result)a.hide(),"undefined"!=typeof window.M.core_formchangechecker&&window.M.core_formchangechecker.reset_form_dirty_state(),window.location.reload();else{var e=JSON.stringify(d.serialize());a.setBody(c.getBody(f,e))}}).fail(e.exception)},k.prototype.getBody=function(a,b){var c={ueid:a};return"undefined"!=typeof b&&(c.formdata=b),h.loadFragment("enrol","user_enrolment_form",this.contextid,c).fail(e.exception)},{init:function(a){new k(a)}}});
|
||||
define(["core/templates","jquery","core/str","core/config","core/notification","core/modal_factory","core/modal_events","core/fragment","core/ajax"],function(a,b,c,d,e,f,g,h,i){var j={EDIT_ENROLMENT:'[data-action="editenrolment"]',SHOW_DETAILS:'[data-action="showdetails"]',UNENROL:'[data-action="unenrol"]'},k=function(a){this.contextid=a.contextid,this.courseid=a.courseid,this.bindEditEnrol(),this.bindUnenrol(),this.bindStatusDetails()};return k.prototype.courseid=0,k.prototype.bindEditEnrol=function(){var a=this;b(j.EDIT_ENROLMENT).click(function(d){d.preventDefault();var h=b(this),i=h.parent(),j=i.data("fullname"),k=h.attr("rel");b.when(c.get_string("edituserenrolment","enrol",j)).then(function(a){return f.create({large:!0,title:a,type:f.types.SAVE_CANCEL})}).done(function(b){b.getRoot().on(g.save,function(c){c.preventDefault(),a.submitEditFormAjax(b)}),b.getRoot().on(g.hidden,function(){b.destroy()}),b.setBody(a.getBody(k)),b.show()}).fail(e.exception)})},k.prototype.bindUnenrol=function(){b(j.UNENROL).click(function(a){a.preventDefault();var h=b(this),i=h.parent(),j=[{key:"unenrol",component:"enrol"},{key:"unenrolconfirm",component:"enrol",param:{user:i.data("fullname"),course:i.data("coursename")}}],k=f.create({type:f.types.SAVE_CANCEL});b.when(c.get_strings(j),k).done(function(a,c){var e=a[0],f=a[1];c.setTitle(e),c.setBody(f),c.setSaveButtonText(e),c.getRoot().on(g.save,function(){var a={confirm:1,sesskey:d.sesskey,ue:b(h).attr("rel")};window.location.href=d.wwwroot+"/enrol/unenroluser.php?"+b.param(a)}),c.getRoot().on(g.hidden,function(){c.destroy()}),c.show()}).fail(e.exception)})},k.prototype.bindStatusDetails=function(){b(j.SHOW_DETAILS).click(function(d){d.preventDefault();var h=b(this),i=h.parent(),k={fullname:i.data("fullname"),coursename:i.data("coursename"),enrolinstancename:i.data("enrolinstancename"),status:i.data("status"),statusclass:i.find("span").attr("class"),timestart:i.data("timestart"),timeend:i.data("timeend")},l=[{key:"enroldetails",component:"enrol"}],m=h.next(j.EDIT_ENROLMENT);m.length&&(k.editenrollink=b("<div>").append(m.clone()).html());var n=c.get_strings(l),o=f.create({large:!0,type:f.types.CANCEL});b.when(n,o).done(function(c,d){var e=a.render("core_user/status_details",k);d.setTitle(c[0]),d.setBody(e),m.length&&d.getRoot().on("click",j.EDIT_ENROLMENT,function(a){a.preventDefault(),d.hide(),b(m).trigger("click")}),d.show(),d.getRoot().on(g.hidden,function(){d.destroy()})}).fail(e.exception)})},k.prototype.submitEditFormAjax=function(a){var c=this,d=a.getRoot().find("form"),f=b(d).find('[name="ue"]').val(),g=b(d).find('[name="status"]').val(),h={courseid:this.courseid,ueid:f,status:g},j=b(d).find('[name="timestart[enabled]"]');if(j.is(":checked")){var k=b(d).find('[name="timestart[year]"]').val(),l=b(d).find('[name="timestart[month]"]').val()-1,m=b(d).find('[name="timestart[day]"]').val(),n=b(d).find('[name="timestart[hour]"]').val(),o=b(d).find('[name="timestart[minute]"]').val(),p=new Date(k,l,m,n,o);h.timestart=p.getTime()/1e3}var q=b(d).find('[name="timeend[enabled]"]');if(q.is(":checked")){var r=b(d).find('[name="timeend[year]"]').val(),s=b(d).find('[name="timeend[month]"]').val()-1,t=b(d).find('[name="timeend[day]"]').val(),u=b(d).find('[name="timeend[hour]"]').val(),v=b(d).find('[name="timeend[minute]"]').val(),w=new Date(r,s,t,u,v);h.timeend=w.getTime()/1e3}var x={methodname:"core_enrol_edit_user_enrolment",args:h};i.call([x])[0].done(function(b){if(b.result)a.hide(),"undefined"!=typeof window.M.core_formchangechecker&&window.M.core_formchangechecker.reset_form_dirty_state(),window.location.reload();else{var e=JSON.stringify(d.serialize());a.setBody(c.getBody(f,e))}}).fail(e.exception)},k.prototype.getBody=function(a,b){var c={ueid:a};return"undefined"!=typeof b&&(c.formdata=b),h.loadFragment("enrol","user_enrolment_form",this.contextid,c).fail(e.exception)},{init:function(a){new k(a)}}});
|
||||
@@ -145,18 +145,19 @@ define(['core/templates',
|
||||
}
|
||||
];
|
||||
|
||||
$.when(Str.get_strings(strings)).then(function(results) {
|
||||
var deleteModalPromise = ModalFactory.create({
|
||||
type: ModalFactory.types.SAVE_CANCEL
|
||||
});
|
||||
|
||||
$.when(Str.get_strings(strings), deleteModalPromise).done(function(results, modal) {
|
||||
var title = results[0];
|
||||
var confirmMessage = results[1];
|
||||
return ModalFactory.create({
|
||||
body: confirmMessage,
|
||||
large: true,
|
||||
title: title,
|
||||
type: ModalFactory.types.CONFIRM
|
||||
});
|
||||
}).done(function(modal) {
|
||||
modal.setTitle(title);
|
||||
modal.setBody(confirmMessage);
|
||||
modal.setSaveButtonText(title);
|
||||
|
||||
// Handle confirm event.
|
||||
modal.getRoot().on(ModalEvents.yes, function() {
|
||||
modal.getRoot().on(ModalEvents.save, function() {
|
||||
// Build params.
|
||||
var unenrolParams = {
|
||||
confirm: 1,
|
||||
|
||||
@@ -45,7 +45,7 @@ Feature: Edit user enrolment
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to course participants
|
||||
When I click on "Unenrol" "icon" in the "student1" "table_row"
|
||||
And I click on "Yes" "button"
|
||||
And I click on "Unenrol" "button" in the ".modal-footer" "css_element"
|
||||
Then I should not see "Student 1" in the "participants" "table"
|
||||
|
||||
@javascript
|
||||
|
||||
Reference in New Issue
Block a user