diff --git a/calendar/amd/build/crud.min.js b/calendar/amd/build/crud.min.js index d44cd944c8ffe..31d3420d683eb 100644 --- a/calendar/amd/build/crud.min.js +++ b/calendar/amd/build/crud.min.js @@ -1,2 +1,2 @@ -define ("core_calendar/crud",["jquery","core/str","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_factory","core/modal_events","core_calendar/modal_event_form","core_calendar/repository","core_calendar/events","core_calendar/modal_delete","core_calendar/selectors","core/pending"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){function o(d,e,f){var i=[{key:"deleteevent",component:"calendar"}];f=parseInt(f,10);var m,o=1.\n\n/**\n * A module to handle CRUD operations within the UI.\n *\n * @module core_calendar/crud\n * @package core_calendar\n * @copyright 2017 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/notification',\n 'core/custom_interaction_events',\n 'core/modal',\n 'core/modal_registry',\n 'core/modal_factory',\n 'core/modal_events',\n 'core_calendar/modal_event_form',\n 'core_calendar/repository',\n 'core_calendar/events',\n 'core_calendar/modal_delete',\n 'core_calendar/selectors',\n 'core/pending',\n],\nfunction(\n $,\n Str,\n Notification,\n CustomEvents,\n Modal,\n ModalRegistry,\n ModalFactory,\n ModalEvents,\n ModalEventForm,\n CalendarRepository,\n CalendarEvents,\n ModalDelete,\n CalendarSelectors,\n Pending\n) {\n\n /**\n * Prepares the action for the summary modal's delete action.\n *\n * @param {Number} eventId The ID of the event.\n * @param {string} eventTitle The event title.\n * @param {Number} eventCount The number of events in the series.\n * @return {Promise}\n */\n function confirmDeletion(eventId, eventTitle, eventCount) {\n var deleteStrings = [\n {\n key: 'deleteevent',\n component: 'calendar'\n },\n ];\n\n eventCount = parseInt(eventCount, 10);\n var deletePromise;\n var isRepeatedEvent = eventCount > 1;\n if (isRepeatedEvent) {\n deleteStrings.push({\n key: 'confirmeventseriesdelete',\n component: 'calendar',\n param: {\n name: eventTitle,\n count: eventCount,\n },\n });\n\n deletePromise = ModalFactory.create(\n {\n type: ModalDelete.TYPE\n }\n );\n } else {\n deleteStrings.push({\n key: 'confirmeventdelete',\n component: 'calendar',\n param: eventTitle\n });\n\n\n deletePromise = ModalFactory.create(\n {\n type: ModalFactory.types.SAVE_CANCEL\n }\n );\n }\n\n var stringsPromise = Str.get_strings(deleteStrings);\n\n var finalPromise = $.when(stringsPromise, deletePromise)\n .then(function(strings, deleteModal) {\n deleteModal.setTitle(strings[0]);\n deleteModal.setBody(strings[1]);\n if (!isRepeatedEvent) {\n deleteModal.setSaveButtonText(strings[0]);\n }\n\n deleteModal.show();\n\n deleteModal.getRoot().on(ModalEvents.save, function() {\n var pendingPromise = new Pending('calendar/crud:initModal:deletedevent');\n CalendarRepository.deleteEvent(eventId, false)\n .then(function() {\n $('body').trigger(CalendarEvents.deleted, [eventId, false]);\n return;\n })\n .then(pendingPromise.resolve)\n .catch(Notification.exception);\n });\n\n deleteModal.getRoot().on(CalendarEvents.deleteAll, function() {\n var pendingPromise = new Pending('calendar/crud:initModal:deletedallevent');\n CalendarRepository.deleteEvent(eventId, true)\n .then(function() {\n $('body').trigger(CalendarEvents.deleted, [eventId, true]);\n return;\n })\n .then(pendingPromise.resolve)\n .catch(Notification.exception);\n });\n\n return deleteModal;\n })\n .catch(Notification.exception);\n\n return finalPromise;\n }\n\n /**\n * Create the event form modal for creating new events and\n * editing existing events.\n *\n * @method registerEventFormModal\n * @param {object} root The calendar root element\n * @return {object} The create modal promise\n */\n var registerEventFormModal = function(root) {\n var eventFormPromise = ModalFactory.create({\n type: ModalEventForm.TYPE,\n large: true\n });\n\n // Bind click event on the new event button.\n root.on('click', CalendarSelectors.actions.create, function(e) {\n eventFormPromise.then(function(modal) {\n var wrapper = root.find(CalendarSelectors.wrapper);\n\n var categoryId = wrapper.data('categoryid');\n if (typeof categoryId !== 'undefined') {\n modal.setCategoryId(categoryId);\n }\n\n // Attempt to find the cell for today.\n // If it can't be found, then use the start time of the first day on the calendar.\n var today = root.find(CalendarSelectors.today);\n var firstDay = root.find(CalendarSelectors.day);\n if (!today.length && firstDay.length) {\n modal.setStartTime(firstDay.data('newEventTimestamp'));\n }\n\n modal.setContextId(wrapper.data('contextId'));\n modal.setCourseId(wrapper.data('courseid'));\n modal.show();\n return;\n })\n .fail(Notification.exception);\n\n e.preventDefault();\n });\n\n root.on('click', CalendarSelectors.actions.edit, function(e) {\n e.preventDefault();\n var target = $(e.currentTarget),\n calendarWrapper = target.closest(CalendarSelectors.wrapper),\n eventWrapper = target.closest(CalendarSelectors.eventItem);\n\n eventFormPromise.then(function(modal) {\n // When something within the calendar tells us the user wants\n // to edit an event then show the event form modal.\n modal.setEventId(eventWrapper.data('eventId'));\n\n modal.setContextId(calendarWrapper.data('contextId'));\n modal.show();\n\n e.stopImmediatePropagation();\n return;\n }).fail(Notification.exception);\n });\n\n\n return eventFormPromise;\n };\n /**\n * Register the listeners required to remove the event.\n *\n * @param {jQuery} root\n */\n function registerRemove(root) {\n root.on('click', CalendarSelectors.actions.remove, function(e) {\n // Fetch the event title, count, and pass them into the new dialogue.\n var eventSource = $(this).closest(CalendarSelectors.eventItem);\n var eventId = eventSource.data('eventId'),\n eventTitle = eventSource.data('eventTitle'),\n eventCount = eventSource.data('eventCount');\n confirmDeletion(eventId, eventTitle, eventCount);\n\n e.preventDefault();\n });\n }\n\n /**\n * Register the listeners required to edit the event.\n *\n * @param {jQuery} root\n * @param {Promise} eventFormModalPromise\n * @returns {Promise}\n */\n function registerEditListeners(root, eventFormModalPromise) {\n eventFormModalPromise\n .then(function(modal) {\n // When something within the calendar tells us the user wants\n // to edit an event then show the event form modal.\n $('body').on(CalendarEvents.editEvent, function(e, eventId) {\n var calendarWrapper = root.find(CalendarSelectors.wrapper);\n modal.setEventId(eventId);\n modal.setContextId(calendarWrapper.data('contextId'));\n modal.show();\n\n e.stopImmediatePropagation();\n });\n return;\n })\n .fail(Notification.exception);\n\n return eventFormModalPromise;\n }\n\n return {\n registerRemove: registerRemove,\n registerEditListeners: registerEditListeners,\n registerEventFormModal: registerEventFormModal\n };\n});\n"],"file":"crud.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/crud.js"],"names":["define","$","Str","Notification","CustomEvents","Modal","ModalRegistry","ModalFactory","ModalEvents","ModalEventForm","CalendarRepository","CalendarEvents","ModalDelete","CalendarSelectors","Pending","confirmDeletion","eventId","eventTitle","eventCount","pendingPromise","deleteStrings","key","component","parseInt","deletePromise","isRepeatedEvent","push","param","name","count","create","type","TYPE","types","SAVE_CANCEL","stringsPromise","get_strings","finalPromise","when","then","strings","deleteModal","setTitle","setBody","setSaveButtonText","show","getRoot","on","save","deleteEvent","trigger","deleted","resolve","catch","exception","deleteAll","modal","registerRemove","root","actions","remove","e","eventSource","closest","eventItem","data","preventDefault","registerEditListeners","eventFormModalPromise","editEvent","calendarWrapper","find","wrapper","setEventId","setContextId","stopImmediatePropagation","fail","registerEventFormModal","eventFormPromise","large","categoryId","setCategoryId","today","firstDay","day","length","setStartTime","setCourseId","edit","target","currentTarget","eventWrapper"],"mappings":"AAuBAA,OAAM,sBAAC,CACH,QADG,CAEH,UAFG,CAGH,mBAHG,CAIH,gCAJG,CAKH,YALG,CAMH,qBANG,CAOH,oBAPG,CAQH,mBARG,CASH,gCATG,CAUH,0BAVG,CAWH,sBAXG,CAYH,4BAZG,CAaH,yBAbG,CAcH,cAdG,CAAD,CAgBN,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQIC,CARJ,CASIC,CATJ,CAUIC,CAVJ,CAWIC,CAXJ,CAYIC,CAZJ,CAaIC,CAbJ,CAcIC,CAdJ,CAeE,CAUE,QAASC,CAAAA,CAAT,CAAyBC,CAAzB,CAAkCC,CAAlC,CAA8CC,CAA9C,CAA0D,IAClDC,CAAAA,CAAc,CAAG,GAAIL,CAAAA,CAAJ,CAAY,oCAAZ,CADiC,CAElDM,CAAa,CAAG,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CAAC1B,OAAP,CAAelD,CAAiB,CAAC2D,OAAjC,CADtB,CAEImB,CAAY,CAAGF,CAAM,CAAC1B,OAAP,CAAelD,CAAiB,CAACmD,SAAjC,CAFnB,CAIAc,CAAgB,CAACvC,IAAjB,CAAsB,SAASiB,CAAT,CAAgB,CAGlCA,CAAK,CAACiB,UAAN,CAAiBkB,CAAY,CAAC1B,IAAb,CAAkB,SAAlB,CAAjB,EAEAT,CAAK,CAACkB,YAAN,CAAmBJ,CAAe,CAACL,IAAhB,CAAqB,WAArB,CAAnB,EACAT,CAAK,CAACX,IAAN,GAEAgB,CAAC,CAACc,wBAAF,EAEH,CAVD,EAUGC,IAVH,CAUQzE,CAAY,CAACmD,SAVrB,CAWH,CAjBD,EAoBA,MAAOwB,CAAAA,CACV,CA8CM,CAKV,CAnPK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * A module to handle CRUD operations within the UI.\n *\n * @module core_calendar/crud\n * @package core_calendar\n * @copyright 2017 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/notification',\n 'core/custom_interaction_events',\n 'core/modal',\n 'core/modal_registry',\n 'core/modal_factory',\n 'core/modal_events',\n 'core_calendar/modal_event_form',\n 'core_calendar/repository',\n 'core_calendar/events',\n 'core_calendar/modal_delete',\n 'core_calendar/selectors',\n 'core/pending',\n],\nfunction(\n $,\n Str,\n Notification,\n CustomEvents,\n Modal,\n ModalRegistry,\n ModalFactory,\n ModalEvents,\n ModalEventForm,\n CalendarRepository,\n CalendarEvents,\n ModalDelete,\n CalendarSelectors,\n Pending\n) {\n\n /**\n * Prepares the action for the summary modal's delete action.\n *\n * @param {Number} eventId The ID of the event.\n * @param {string} eventTitle The event title.\n * @param {Number} eventCount The number of events in the series.\n * @return {Promise}\n */\n function confirmDeletion(eventId, eventTitle, eventCount) {\n var pendingPromise = new Pending('core_calendar/crud:confirmDeletion');\n var deleteStrings = [\n {\n key: 'deleteevent',\n component: 'calendar'\n },\n ];\n\n eventCount = parseInt(eventCount, 10);\n var deletePromise;\n var isRepeatedEvent = eventCount > 1;\n if (isRepeatedEvent) {\n deleteStrings.push({\n key: 'confirmeventseriesdelete',\n component: 'calendar',\n param: {\n name: eventTitle,\n count: eventCount,\n },\n });\n\n deletePromise = ModalFactory.create(\n {\n type: ModalDelete.TYPE\n }\n );\n } else {\n deleteStrings.push({\n key: 'confirmeventdelete',\n component: 'calendar',\n param: eventTitle\n });\n\n\n deletePromise = ModalFactory.create(\n {\n type: ModalFactory.types.SAVE_CANCEL\n }\n );\n }\n\n var stringsPromise = Str.get_strings(deleteStrings);\n\n var finalPromise = $.when(stringsPromise, deletePromise)\n .then(function(strings, deleteModal) {\n deleteModal.setTitle(strings[0]);\n deleteModal.setBody(strings[1]);\n if (!isRepeatedEvent) {\n deleteModal.setSaveButtonText(strings[0]);\n }\n\n deleteModal.show();\n\n deleteModal.getRoot().on(ModalEvents.save, function() {\n var pendingPromise = new Pending('calendar/crud:initModal:deletedevent');\n CalendarRepository.deleteEvent(eventId, false)\n .then(function() {\n $('body').trigger(CalendarEvents.deleted, [eventId, false]);\n return;\n })\n .then(pendingPromise.resolve)\n .catch(Notification.exception);\n });\n\n deleteModal.getRoot().on(CalendarEvents.deleteAll, function() {\n var pendingPromise = new Pending('calendar/crud:initModal:deletedallevent');\n CalendarRepository.deleteEvent(eventId, true)\n .then(function() {\n $('body').trigger(CalendarEvents.deleted, [eventId, true]);\n return;\n })\n .then(pendingPromise.resolve)\n .catch(Notification.exception);\n });\n\n return deleteModal;\n })\n .then(function(modal) {\n pendingPromise.resolve();\n\n return modal;\n })\n .catch(Notification.exception);\n\n return finalPromise;\n }\n\n /**\n * Create the event form modal for creating new events and\n * editing existing events.\n *\n * @method registerEventFormModal\n * @param {object} root The calendar root element\n * @return {object} The create modal promise\n */\n var registerEventFormModal = function(root) {\n var eventFormPromise = ModalFactory.create({\n type: ModalEventForm.TYPE,\n large: true\n });\n\n // Bind click event on the new event button.\n root.on('click', CalendarSelectors.actions.create, function(e) {\n eventFormPromise.then(function(modal) {\n var wrapper = root.find(CalendarSelectors.wrapper);\n\n var categoryId = wrapper.data('categoryid');\n if (typeof categoryId !== 'undefined') {\n modal.setCategoryId(categoryId);\n }\n\n // Attempt to find the cell for today.\n // If it can't be found, then use the start time of the first day on the calendar.\n var today = root.find(CalendarSelectors.today);\n var firstDay = root.find(CalendarSelectors.day);\n if (!today.length && firstDay.length) {\n modal.setStartTime(firstDay.data('newEventTimestamp'));\n }\n\n modal.setContextId(wrapper.data('contextId'));\n modal.setCourseId(wrapper.data('courseid'));\n modal.show();\n return;\n })\n .fail(Notification.exception);\n\n e.preventDefault();\n });\n\n root.on('click', CalendarSelectors.actions.edit, function(e) {\n e.preventDefault();\n var target = $(e.currentTarget),\n calendarWrapper = target.closest(CalendarSelectors.wrapper),\n eventWrapper = target.closest(CalendarSelectors.eventItem);\n\n eventFormPromise.then(function(modal) {\n // When something within the calendar tells us the user wants\n // to edit an event then show the event form modal.\n modal.setEventId(eventWrapper.data('eventId'));\n\n modal.setContextId(calendarWrapper.data('contextId'));\n modal.show();\n\n e.stopImmediatePropagation();\n return;\n }).fail(Notification.exception);\n });\n\n\n return eventFormPromise;\n };\n /**\n * Register the listeners required to remove the event.\n *\n * @param {jQuery} root\n */\n function registerRemove(root) {\n root.on('click', CalendarSelectors.actions.remove, function(e) {\n // Fetch the event title, count, and pass them into the new dialogue.\n var eventSource = $(this).closest(CalendarSelectors.eventItem);\n var eventId = eventSource.data('eventId'),\n eventTitle = eventSource.data('eventTitle'),\n eventCount = eventSource.data('eventCount');\n confirmDeletion(eventId, eventTitle, eventCount);\n\n e.preventDefault();\n });\n }\n\n /**\n * Register the listeners required to edit the event.\n *\n * @param {jQuery} root\n * @param {Promise} eventFormModalPromise\n * @returns {Promise}\n */\n function registerEditListeners(root, eventFormModalPromise) {\n eventFormModalPromise\n .then(function(modal) {\n // When something within the calendar tells us the user wants\n // to edit an event then show the event form modal.\n $('body').on(CalendarEvents.editEvent, function(e, eventId) {\n var calendarWrapper = root.find(CalendarSelectors.wrapper);\n modal.setEventId(eventId);\n modal.setContextId(calendarWrapper.data('contextId'));\n modal.show();\n\n e.stopImmediatePropagation();\n });\n return;\n })\n .fail(Notification.exception);\n\n return eventFormModalPromise;\n }\n\n return {\n registerRemove: registerRemove,\n registerEditListeners: registerEditListeners,\n registerEventFormModal: registerEventFormModal\n };\n});\n"],"file":"crud.min.js"} \ No newline at end of file diff --git a/calendar/amd/build/modal_delete.min.js b/calendar/amd/build/modal_delete.min.js index 184a2836c39d1..77dbc028a3aea 100644 --- a/calendar/amd/build/modal_delete.min.js +++ b/calendar/amd/build/modal_delete.min.js @@ -1,2 +1,2 @@ -define ("core_calendar/modal_delete",["jquery","core/notification","core/custom_interaction_events","core/modal","core/modal_events","core/modal_registry","core_calendar/events"],function(a,b,c,d,f,g,h){var i=!1,j={DELETE_ONE_BUTTON:"[data-action=\"deleteone\"]",DELETE_ALL_BUTTON:"[data-action=\"deleteall\"]",CANCEL_BUTTON:"[data-action=\"cancel\"]"},k=function(a){d.call(this,a)};k.TYPE="core_calendar-modal_delete";k.prototype=Object.create(d.prototype);k.prototype.constructor=k;k.prototype.registerEventListeners=function(){d.prototype.registerEventListeners.call(this);this.getModal().on(c.events.activate,j.DELETE_ONE_BUTTON,function(b,c){var d=a.Event(f.save);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){this.hide();c.originalEvent.preventDefault()}}.bind(this));this.getModal().on(c.events.activate,j.DELETE_ALL_BUTTON,function(b,c){var d=a.Event(h.deleteAll);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){this.hide();c.originalEvent.preventDefault()}}.bind(this));this.getModal().on(c.events.activate,j.CANCEL_BUTTON,function(b,c){var d=a.Event(f.cancel);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){this.hide();c.originalEvent.preventDefault()}}.bind(this))};if(!i){g.register(k.TYPE,k,"calendar/event_delete_modal");i=!0}return k}); +define ("core_calendar/modal_delete",["jquery","core/notification","core/custom_interaction_events","core/modal","core/modal_events","core/modal_registry","core_calendar/events"],function(a,b,c,d,f,g,h){var i=!1,j={DELETE_ONE_BUTTON:"[data-action=\"deleteone\"]",DELETE_ALL_BUTTON:"[data-action=\"deleteall\"]",CANCEL_BUTTON:"[data-action=\"cancel\"]"},k=function(a){d.call(this,a);this.setRemoveOnClose(!0)};k.TYPE="core_calendar-modal_delete";k.prototype=Object.create(d.prototype);k.prototype.constructor=k;k.prototype.registerEventListeners=function(){d.prototype.registerEventListeners.call(this);this.getModal().on(c.events.activate,j.DELETE_ONE_BUTTON,function(b,c){var d=a.Event(f.save);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){this.hide();c.originalEvent.preventDefault()}}.bind(this));this.getModal().on(c.events.activate,j.DELETE_ALL_BUTTON,function(b,c){var d=a.Event(h.deleteAll);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){this.hide();c.originalEvent.preventDefault()}}.bind(this));this.getModal().on(c.events.activate,j.CANCEL_BUTTON,function(b,c){var d=a.Event(f.cancel);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){this.hide();c.originalEvent.preventDefault()}}.bind(this))};if(!i){g.register(k.TYPE,k,"calendar/event_delete_modal");i=!0}return k}); //# sourceMappingURL=modal_delete.min.js.map diff --git a/calendar/amd/build/modal_delete.min.js.map b/calendar/amd/build/modal_delete.min.js.map index 4a4c1857b158a..090c326af6b03 100644 --- a/calendar/amd/build/modal_delete.min.js.map +++ b/calendar/amd/build/modal_delete.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/modal_delete.js"],"names":["define","$","Notification","CustomEvents","Modal","ModalEvents","ModalRegistry","CalendarEvents","registered","SELECTORS","DELETE_ONE_BUTTON","DELETE_ALL_BUTTON","CANCEL_BUTTON","ModalDelete","root","call","TYPE","prototype","Object","create","constructor","registerEventListeners","getModal","on","events","activate","e","data","saveEvent","Event","save","getRoot","trigger","isDefaultPrevented","hide","originalEvent","preventDefault","bind","deleteAll","cancelEvent","cancel","register"],"mappings":"AAwBAA,OAAM,8BAAC,CACH,QADG,CAEH,mBAFG,CAGH,gCAHG,CAIH,YAJG,CAKH,mBALG,CAMH,qBANG,CAOH,sBAPG,CAAD,CASN,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQE,IAEMC,CAAAA,CAAU,GAFhB,CAGMC,CAAS,CAAG,CACZC,iBAAiB,CAAE,6BADP,CAEZC,iBAAiB,CAAE,6BAFP,CAGZC,aAAa,CAAE,0BAHH,CAHlB,CAcMC,CAAW,CAAG,SAASC,CAAT,CAAe,CAC7BV,CAAK,CAACW,IAAN,CAAW,IAAX,CAAiBD,CAAjB,CACH,CAhBH,CAkBED,CAAW,CAACG,IAAZ,CAAmB,4BAAnB,CACAH,CAAW,CAACI,SAAZ,CAAwBC,MAAM,CAACC,MAAP,CAAcf,CAAK,CAACa,SAApB,CAAxB,CACAJ,CAAW,CAACI,SAAZ,CAAsBG,WAAtB,CAAoCP,CAApC,CAOAA,CAAW,CAACI,SAAZ,CAAsBI,sBAAtB,CAA+C,UAAW,CAEtDjB,CAAK,CAACa,SAAN,CAAgBI,sBAAhB,CAAuCN,IAAvC,CAA4C,IAA5C,EAEA,KAAKO,QAAL,GAAgBC,EAAhB,CAAmBpB,CAAY,CAACqB,MAAb,CAAoBC,QAAvC,CAAiDhB,CAAS,CAACC,iBAA3D,CAA8E,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cAAnB,EACH,CACJ,CARyE,CAQxEC,IARwE,CAQnE,IARmE,CAA1E,CASH,CAjCD,CAqCA,GAAI,CAAC7B,CAAL,CAAiB,CACbF,CAAa,CAACmC,QAAd,CAAuB5B,CAAW,CAACG,IAAnC,CAAyCH,CAAzC,CAAsD,6BAAtD,EACAL,CAAU,GACb,CAED,MAAOK,CAAAA,CACV,CAvFK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the save/cancel modal.\n *\n * @module core_calendar/modal_delete\n * @class modal_delete\n * @package core_calendar\n * @copyright 2017 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/notification',\n 'core/custom_interaction_events',\n 'core/modal',\n 'core/modal_events',\n 'core/modal_registry',\n 'core_calendar/events',\n],\nfunction(\n $,\n Notification,\n CustomEvents,\n Modal,\n ModalEvents,\n ModalRegistry,\n CalendarEvents\n) {\n\n var registered = false;\n var SELECTORS = {\n DELETE_ONE_BUTTON: '[data-action=\"deleteone\"]',\n DELETE_ALL_BUTTON: '[data-action=\"deleteall\"]',\n CANCEL_BUTTON: '[data-action=\"cancel\"]',\n };\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var ModalDelete = function(root) {\n Modal.call(this, root);\n };\n\n ModalDelete.TYPE = 'core_calendar-modal_delete';\n ModalDelete.prototype = Object.create(Modal.prototype);\n ModalDelete.prototype.constructor = ModalDelete;\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n ModalDelete.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.DELETE_ONE_BUTTON, function(e, data) {\n var saveEvent = $.Event(ModalEvents.save);\n this.getRoot().trigger(saveEvent, this);\n\n if (!saveEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.DELETE_ALL_BUTTON, function(e, data) {\n var saveEvent = $.Event(CalendarEvents.deleteAll);\n this.getRoot().trigger(saveEvent, this);\n\n if (!saveEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, function(e, data) {\n var cancelEvent = $.Event(ModalEvents.cancel);\n this.getRoot().trigger(cancelEvent, this);\n\n if (!cancelEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n };\n\n // Automatically register with the modal registry the first time this module is imported so that you can create modals\n // of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(ModalDelete.TYPE, ModalDelete, 'calendar/event_delete_modal');\n registered = true;\n }\n\n return ModalDelete;\n});\n"],"file":"modal_delete.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/modal_delete.js"],"names":["define","$","Notification","CustomEvents","Modal","ModalEvents","ModalRegistry","CalendarEvents","registered","SELECTORS","DELETE_ONE_BUTTON","DELETE_ALL_BUTTON","CANCEL_BUTTON","ModalDelete","root","call","setRemoveOnClose","TYPE","prototype","Object","create","constructor","registerEventListeners","getModal","on","events","activate","e","data","saveEvent","Event","save","getRoot","trigger","isDefaultPrevented","hide","originalEvent","preventDefault","bind","deleteAll","cancelEvent","cancel","register"],"mappings":"AAwBAA,OAAM,8BAAC,CACH,QADG,CAEH,mBAFG,CAGH,gCAHG,CAIH,YAJG,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B,CAAmBrB,CAAY,CAACsB,MAAb,CAAoBC,QAAvC,CAAiDjB,CAAS,CAACE,iBAA3D,CAA8E,SAASgB,CAAT,CAAYC,CAAZ,CAAkB,CAC5F,GAAIC,CAAAA,CAAS,CAAG5B,CAAC,CAAC6B,KAAF,CAAQvB,CAAc,CAACgC,SAAvB,CAAhB,CACA,KAAKP,OAAL,GAAeC,OAAf,CAAuBJ,CAAvB,CAAkC,IAAlC,EAEA,GAAI,CAACA,CAAS,CAACK,kBAAV,EAAL,CAAqC,CACjC,KAAKC,IAAL,GACAP,CAAI,CAACQ,aAAL,CAAmBC,cAAnB,EACH,CACJ,CAR6E,CAQ5EC,IAR4E,CAQvE,IARuE,CAA9E,EAUA,KAAKf,QAAL,GAAgBC,EAAhB,CAAmBrB,CAAY,CAACsB,MAAb,CAAoBC,QAAvC,CAAiDjB,CAAS,CAACG,aAA3D,CAA0E,SAASe,CAAT,CAAYC,CAAZ,CAAkB,CACxF,GAAIY,CAAAA,CAAW,CAAGvC,CAAC,CAAC6B,KAAF,CAAQzB,CAAW,CAACoC,MAApB,CAAlB,CACA,KAAKT,OAAL,GAAeC,OAAf,CAAuBO,CAAvB,CAAoC,IAApC,EAEA,GAAI,CAACA,CAAW,CAACN,kBAAZ,EAAL,CAAuC,CACnC,KAAKC,IAAL,GACAP,CAAI,CAACQ,aAAL,CAAmBC,cAAnB,EACH,CACJ,CARyE,CAQxEC,IARwE,CAQnE,IARmE,CAA1E,CASH,CAjCD,CAqCA,GAAI,CAAC9B,CAAL,CAAiB,CACbF,CAAa,CAACoC,QAAd,CAAuB7B,CAAW,CAACI,IAAnC,CAAyCJ,CAAzC,CAAsD,6BAAtD,EACAL,CAAU,GACb,CAED,MAAOK,CAAAA,CACV,CAzFK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the save/cancel modal.\n *\n * @module core_calendar/modal_delete\n * @class modal_delete\n * @package core_calendar\n * @copyright 2017 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/notification',\n 'core/custom_interaction_events',\n 'core/modal',\n 'core/modal_events',\n 'core/modal_registry',\n 'core_calendar/events',\n],\nfunction(\n $,\n Notification,\n CustomEvents,\n Modal,\n ModalEvents,\n ModalRegistry,\n CalendarEvents\n) {\n\n var registered = false;\n var SELECTORS = {\n DELETE_ONE_BUTTON: '[data-action=\"deleteone\"]',\n DELETE_ALL_BUTTON: '[data-action=\"deleteall\"]',\n CANCEL_BUTTON: '[data-action=\"cancel\"]',\n };\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var ModalDelete = function(root) {\n Modal.call(this, root);\n\n this.setRemoveOnClose(true);\n };\n\n ModalDelete.TYPE = 'core_calendar-modal_delete';\n ModalDelete.prototype = Object.create(Modal.prototype);\n ModalDelete.prototype.constructor = ModalDelete;\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n ModalDelete.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.DELETE_ONE_BUTTON, function(e, data) {\n var saveEvent = $.Event(ModalEvents.save);\n this.getRoot().trigger(saveEvent, this);\n\n if (!saveEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.DELETE_ALL_BUTTON, function(e, data) {\n var saveEvent = $.Event(CalendarEvents.deleteAll);\n this.getRoot().trigger(saveEvent, this);\n\n if (!saveEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, function(e, data) {\n var cancelEvent = $.Event(ModalEvents.cancel);\n this.getRoot().trigger(cancelEvent, this);\n\n if (!cancelEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n };\n\n // Automatically register with the modal registry the first time this module is imported so that you can create modals\n // of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(ModalDelete.TYPE, ModalDelete, 'calendar/event_delete_modal');\n registered = true;\n }\n\n return ModalDelete;\n});\n"],"file":"modal_delete.min.js"} \ No newline at end of file diff --git a/calendar/amd/src/crud.js b/calendar/amd/src/crud.js index 7853a67fdea78..c18cb56728589 100644 --- a/calendar/amd/src/crud.js +++ b/calendar/amd/src/crud.js @@ -63,6 +63,7 @@ function( * @return {Promise} */ function confirmDeletion(eventId, eventTitle, eventCount) { + var pendingPromise = new Pending('core_calendar/crud:confirmDeletion'); var deleteStrings = [ { key: 'deleteevent', @@ -139,6 +140,11 @@ function( return deleteModal; }) + .then(function(modal) { + pendingPromise.resolve(); + + return modal; + }) .catch(Notification.exception); return finalPromise; diff --git a/calendar/amd/src/modal_delete.js b/calendar/amd/src/modal_delete.js index 9541dec35e2db..e457761ef78ac 100644 --- a/calendar/amd/src/modal_delete.js +++ b/calendar/amd/src/modal_delete.js @@ -55,6 +55,8 @@ function( */ var ModalDelete = function(root) { Modal.call(this, root); + + this.setRemoveOnClose(true); }; ModalDelete.TYPE = 'core_calendar-modal_delete'; diff --git a/mod/assign/feedback/editpdf/tests/behat/view_previous_annotations.feature b/mod/assign/feedback/editpdf/tests/behat/view_previous_annotations.feature index b593498dd7f37..1b341ee178167 100644 --- a/mod/assign/feedback/editpdf/tests/behat/view_previous_annotations.feature +++ b/mod/assign/feedback/editpdf/tests/behat/view_previous_annotations.feature @@ -56,7 +56,7 @@ Feature: In an assignment, teacher can view the feedback for a previous attempt. And I should see "The changes to the grade and feedback were saved" And I press "Ok" And I follow "View a different attempt" - And I click on "//div[contains(@class, 'moodle-dialogue-bd')]//label[2]" "xpath_element" + And I click on "Attempt 1" "radio" in the "View a different attempt" "dialogue" And I press "View" And I wait until the page is ready And I should see "You are editing the feedback for a previous attempt. This is attempt 1 out of 2." diff --git a/mod/assign/tests/behat/edit_previous_feedback.feature b/mod/assign/tests/behat/edit_previous_feedback.feature index 007d4fda39648..add1bec001b33 100644 --- a/mod/assign/tests/behat/edit_previous_feedback.feature +++ b/mod/assign/tests/behat/edit_previous_feedback.feature @@ -60,7 +60,7 @@ Feature: In an assignment, teachers can edit feedback for a students previous su And I navigate to "View all submissions" in current page administration And I click on "Grade" "link" in the "Student 2" "table_row" And I click on "View a different attempt" "link" - And I click on "//div[contains(concat(' ', normalize-space(@class), ' '), ' confirmation-dialogue ')]//input[@value='0']" "xpath_element" + And I click on "Attempt 1" "radio" in the "View a different attempt" "dialogue" And I click on "View" "button" And I set the following fields to these values: | Grade | 50 | diff --git a/tag/tests/behat/delete_tag.feature b/tag/tests/behat/delete_tag.feature index 542360426d246..18eb048f16ad1 100644 --- a/tag/tests/behat/delete_tag.feature +++ b/tag/tests/behat/delete_tag.feature @@ -53,7 +53,7 @@ Feature: Manager is able to delete tags And I follow "Default collection" And I click on "Delete" "link" in the "Turtle" "table_row" Then I should see "Are you sure you want to delete this tag?" - And I press "No" + And I click on "Cancel" "button" in the "Delete" "dialogue" And I should not see "Tag(s) deleted" And I should see "Turtle" And I click on "Delete" "link" in the "Dog" "table_row" @@ -81,7 +81,7 @@ Feature: Manager is able to delete tags | Select tag Cat | 1 | And I press "Delete selected" And I should see "Are you sure you want to delete selected tags?" - And I press "No" + And I click on "Cancel" "button" in the "Delete" "dialogue" And I should not see "Tag(s) deleted" And I should see "Cat" And I set the following fields to these values: