diff --git a/amd/build/block_manage_series.min.js b/amd/build/block_manage_series.min.js index 7a6ffb36..351b81c0 100644 --- a/amd/build/block_manage_series.min.js +++ b/amd/build/block_manage_series.min.js @@ -5,6 +5,6 @@ define("block_opencast/block_manage_series",["exports","block_opencast/tabulator * @module block/opencast * @copyright 2021 Tamara Gunkel, University of Münster * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */function getBody(contextid,ocinstanceid,seriesid,formdata){void 0===formdata&&(formdata="");var params={ocinstanceid:ocinstanceid,seriesid:seriesid,jsonformdata:formdata};return _fragment.default.loadFragment("block_opencast","series_form",contextid,params)}function submitFormAjax(e){e.preventDefault();var modal=e.data.modal,contextid=e.data.contextid,seriestable=window.seriestable,edited=e.data.edited,numseriesallowed=e.data.numseriesallowed,changeEvent=document.createEvent("HTMLEvents");changeEvent.initEvent("change",!0,!0),modal.getRoot().find(":input").each((function(index,element){element.dispatchEvent(changeEvent)}));var invalid=_jquery.default.merge(modal.getRoot().find('[aria-invalid="true"]'),modal.getRoot().find(".error"));if(invalid.length)invalid.first().focus();else{var formData=modal.getRoot().find("form").serialize(),seriestitle=(0,_jquery.default)(".modal #id_title").val();_ajax.default.call([{methodname:"block_opencast_submit_series_form",args:{contextid:contextid,ocinstanceid:e.data.ocinstanceid,seriesid:e.data.seriesid,jsonformdata:formData},done:function(newseries){if(modal.destroy(),edited){seriestable.getRows().find((r=>r.getData().series===e.data.seriesid)).update({seriesname:seriestitle})}else{var _$,_$2,s=JSON.parse(newseries);if(seriestable.addRow({seriesname:s.seriestitle,series:s.series,isdefault:s.isdefault}),seriestable.getRows().length>=numseriesallowed)null===(_$=(0,_jquery.default)("#createseries"))||void 0===_$||_$.hide(),null===(_$2=(0,_jquery.default)("#importseries"))||void 0===_$2||_$2.hide()}},fail:function(er){"metadataseriesupdatefailed"===er.errorcode?(modal.destroy(),displayError(er.message)):modal.setBody(getBody(contextid,e.data.ocinstanceid,e.data.seriesid,formData))}}])}}function displayError(message){var context={announce:!0,closebutton:!0,extraclasses:"",message:message};_templates.default.render("core/notification_error",context).then((function(m){(0,_jquery.default)("#user-notifications").append(m)})).fail((function(){_notification.default.alert(message,message)}))}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_tabulator=_interopRequireDefault(_tabulator),_jquery=_interopRequireDefault(_jquery),str=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(str),_modal_factory=_interopRequireDefault(_modal_factory),_modal_events=_interopRequireDefault(_modal_events),_fragment=_interopRequireDefault(_fragment),_ajax=_interopRequireDefault(_ajax),_templates=_interopRequireDefault(_templates),_notification=_interopRequireDefault(_notification);_exports.init=(contextid,ocinstanceid,createseries,series,numseriesallowed)=>{str.get_strings([{key:"seriesname",component:"block_opencast"},{key:"form_seriesid",component:"block_opencast"},{key:"default",component:"block_opencast"},{key:"noconnectedseries",component:"block_opencast"},{key:"createseriesforcourse",component:"block_opencast"},{key:"delete_series",component:"block_opencast"},{key:"delete_confirm_series",component:"block_opencast"},{key:"editseries",component:"block_opencast"},{key:"delete",component:"moodle"},{key:"loading",component:"block_opencast"},{key:"importseries",component:"block_opencast"},{key:"importfailed",component:"block_opencast"},{key:"form_seriesid",component:"block_opencast"},{key:"setdefaultseries_heading",component:"block_opencast"},{key:"setdefaultseries",component:"block_opencast"}]).then((function(jsstrings){var _$3,_$4,seriestable=new _tabulator.default("#seriestable",{data:series,layout:"fitColumns",placeholder:jsstrings[3],headerSort:!1,dataLoaded:function(data){!function(contextid,ocinstanceid,series,seriestable,row){_ajax.default.call([{methodname:"block_opencast_get_series_titles",args:{contextid:contextid,ocinstanceid:ocinstanceid,series:JSON.stringify(series)},done:function(data){var titles=JSON.parse(data);null!==seriestable?seriestable.getRows().forEach((function(row){row.update({seriesname:titles[row.getData().series]})})):row.update({seriesname:titles[row.getData().series]})},fail:function(error){null!==seriestable?seriestable.getRows().forEach((function(row){row.update({seriesname:error.message})})):row.update({seriesname:error.message})}}])}(contextid,ocinstanceid,data.map((x=>x.series)),this)},columns:[{title:jsstrings[0],field:"seriesname",editable:!1},{title:jsstrings[1],field:"series",editable:!1},{title:jsstrings[2],field:"isdefault",hozAlign:"center",widthGrow:0,formatter:function(cell){var input=document.createElement("input");return input.type="radio",input.name="defaultseries",input.checked=cell.getValue(),input.classList.add("ignoredirty"),input.addEventListener("click",(function(e){e.preventDefault(),_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:jsstrings[13],body:jsstrings[14]}).then((function(modal){modal.getRoot().on(_modal_events.default.hidden,(function(){modal.destroy()})),modal.getRoot().on(_modal_events.default.save,(function(){_ajax.default.call([{methodname:"block_opencast_set_default_series",args:{contextid:contextid,ocinstanceid:ocinstanceid,seriesid:cell.getRow().getData().series},done:function(){modal.destroy(),cell.getTable().getRows().forEach((function(row){row===cell.getRow()?row.update({isdefault:1}):row.update({isdefault:0})}))},fail:function(e){modal.destroy(),displayError(e.message)}}])})),modal.show()})).catch(_notification.default.exception)})),input}},{title:"",width:40,headerSort:!1,hozAlign:"center",formatter:function(){return''},cellClick:function(_,cell){_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:jsstrings[7],body:getBody(contextid,ocinstanceid,cell.getRow().getCell("series").getValue())}).then((function(modal){modal.setSaveButtonText(jsstrings[7]),modal.setLarge(),modal.getRoot().on(_modal_events.default.hidden,(function(){modal.destroy()})),modal.getRoot().on(_modal_events.default.shown,(function(){modal.getRoot().append("")})),modal.getRoot().on(_modal_events.default.save,(function(e){e.preventDefault(),modal.getRoot().find("form").submit()})),modal.getRoot().on("submit","form",{modal:modal,contextid:contextid,ocinstanceid:ocinstanceid,seriesid:cell.getRow().getCell("series").getValue(),numseriesallowed:numseriesallowed,edited:!0},submitFormAjax),modal.show()})).catch(_notification.default.exception)}},{title:"",width:40,headerSort:!1,hozAlign:"center",formatter:function(){return''},cellClick:function(e,cell){_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:jsstrings[5],body:jsstrings[6]}).then((function(modal){modal.setSaveButtonText(jsstrings[8]),modal.getRoot().on(_modal_events.default.save,(function(){_ajax.default.call([{methodname:"block_opencast_unlink_series",args:{contextid:contextid,ocinstanceid:ocinstanceid,seriesid:cell.getRow().getData().series},done:function(result){modal.destroy();let res=JSON.parse(result);if(res.error)displayError(res.message);else{cell.getRow().delete();const createseries=(0,_jquery.default)("#createseries"),importseries=(0,_jquery.default)("#importseries");null==createseries||createseries.show(),null==createseries||createseries.removeClass("d-none"),null==importseries||importseries.show(),null==importseries||importseries.removeClass("d-none")}},fail:function(e){modal.destroy(),displayError(e.message)}}])})),modal.show()})).catch(_notification.default.exception)}}]});window.seriestable=seriestable,null===(_$3=(0,_jquery.default)("#createseries"))||void 0===_$3||_$3.click((function(){_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:jsstrings[4],body:getBody(contextid,ocinstanceid,"",void 0)}).then((function(modal){modal.setSaveButtonText(jsstrings[4]),modal.setLarge(),modal.getRoot().on(_modal_events.default.hidden,(function(){modal.destroy()})),modal.getRoot().on(_modal_events.default.shown,(function(){modal.getRoot().append("")})),modal.getRoot().on(_modal_events.default.save,(function(e){e.preventDefault(),modal.getRoot().find("form").submit()})),modal.getRoot().on("submit","form",{modal:modal,contextid:contextid,ocinstanceid:ocinstanceid,seriesid:"",numseriesallowed:numseriesallowed,edited:!1},submitFormAjax),modal.show()})).catch(_notification.default.exception)})),null===(_$4=(0,_jquery.default)("#importseries"))||void 0===_$4||_$4.click((function(){let context={label:jsstrings[12],required:!1,advanced:!1,element:{wrapperid:"importseriesid_wrapper",name:"importseriesid",id:"importseriesid",type:"text",size:40,value:""}};_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:jsstrings[10],body:_templates.default.render("core_form/element-text",context)}).then((function(modal){modal.setSaveButtonText(jsstrings[10]),modal.setLarge(),modal.getRoot().on(_modal_events.default.hidden,(function(){modal.destroy()})),modal.getRoot().on(_modal_events.default.save,(function(e){e.preventDefault();var seriesid=(0,_jquery.default)("#importseriesid").val();_ajax.default.call([{methodname:"block_opencast_import_series",args:{contextid:contextid,ocinstanceid:ocinstanceid,seriesid:seriesid},done:function(newseries){if(modal.destroy(),void 0!==seriestable){var _$5,_$6,s=JSON.parse(newseries);if(seriestable.addRow({seriesname:s.title,series:s.id,isdefault:s.isdefault}),seriestable.getRows().length>=numseriesallowed)null===(_$5=(0,_jquery.default)("#createseries"))||void 0===_$5||_$5.hide(),null===(_$6=(0,_jquery.default)("#importseries"))||void 0===_$6||_$6.hide()}},fail:function(){modal.destroy(),displayError(jsstrings[11])}}])})),modal.show()})).catch(_notification.default.exception)})),createseries&&(0,_jquery.default)("#createseries").trigger("click")})).catch(_notification.default.exception)}})); + */function getBody(contextid,ocinstanceid,seriesid,formdata){void 0===formdata&&(formdata="");var params={ocinstanceid:ocinstanceid,seriesid:seriesid,jsonformdata:formdata};return _fragment.default.loadFragment("block_opencast","series_form",contextid,params)}function submitFormAjax(e){e.preventDefault();var modal=e.data.modal,contextid=e.data.contextid,seriestable=window.seriestable,edited=e.data.edited,numseriesallowed=e.data.numseriesallowed,changeEvent=document.createEvent("HTMLEvents");changeEvent.initEvent("change",!0,!0),modal.getRoot().find(":input").each((function(index,element){element.dispatchEvent(changeEvent)}));var invalid=_jquery.default.merge(modal.getRoot().find('[aria-invalid="true"]'),modal.getRoot().find(".error"));if(invalid.length)invalid.first().focus();else{var formData=modal.getRoot().find("form").serialize(),seriestitle=(0,_jquery.default)(".modal #id_title").val();_ajax.default.call([{methodname:"block_opencast_submit_series_form",args:{contextid:contextid,ocinstanceid:e.data.ocinstanceid,seriesid:e.data.seriesid,jsonformdata:formData},done:function(newseries){modal.destroy();var stringkey="createseriesforcourse_succeeded";if(edited){seriestable.getRows().find((r=>r.getData().series===e.data.seriesid)).update({seriesname:seriestitle}),stringkey="editseries_succeeded"}else{var _$,_$2,s=JSON.parse(newseries);if(seriestable.addRow({seriesname:s.seriestitle,series:s.series,isdefault:s.isdefault}),seriestable.getRows().length>=numseriesallowed)null===(_$=(0,_jquery.default)("#createseries"))||void 0===_$||_$.hide(),null===(_$2=(0,_jquery.default)("#importseries"))||void 0===_$2||_$2.hide()}str.get_string(stringkey,"block_opencast").done((function(result){_notification.default.addNotification({message:result,type:"success"})})).fail(_notification.default.exception)},fail:function(er){"metadataseriesupdatefailed"===er.errorcode?(modal.destroy(),displayError(er.message)):modal.setBody(getBody(contextid,e.data.ocinstanceid,e.data.seriesid,formData))}}])}}function displayError(message){var context={announce:!0,closebutton:!0,extraclasses:"",message:message};_templates.default.render("core/notification_error",context).then((function(m){(0,_jquery.default)("#user-notifications").append(m)})).fail((function(){_notification.default.alert(message,message)}))}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_tabulator=_interopRequireDefault(_tabulator),_jquery=_interopRequireDefault(_jquery),str=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(str),_modal_factory=_interopRequireDefault(_modal_factory),_modal_events=_interopRequireDefault(_modal_events),_fragment=_interopRequireDefault(_fragment),_ajax=_interopRequireDefault(_ajax),_templates=_interopRequireDefault(_templates),_notification=_interopRequireDefault(_notification);_exports.init=(contextid,ocinstanceid,createseries,series,numseriesallowed)=>{str.get_strings([{key:"seriesname",component:"block_opencast"},{key:"form_seriesid",component:"block_opencast"},{key:"default",component:"block_opencast"},{key:"noconnectedseries",component:"block_opencast"},{key:"createseriesforcourse",component:"block_opencast"},{key:"delete_series",component:"block_opencast"},{key:"delete_confirm_series",component:"block_opencast"},{key:"editseries",component:"block_opencast"},{key:"delete",component:"moodle"},{key:"loading",component:"block_opencast"},{key:"importseries",component:"block_opencast"},{key:"importfailed",component:"block_opencast"},{key:"form_seriesid",component:"block_opencast"},{key:"setdefaultseries_heading",component:"block_opencast"},{key:"setdefaultseries",component:"block_opencast"},{key:"setdefaultseriessucceeded",component:"block_opencast"},{key:"cantdeletedefaultseries_modaltitle",component:"block_opencast"},{key:"cantdeletedefaultseries",component:"block_opencast"},{key:"delete_series_succeeded",component:"block_opencast"},{key:"importseries_succeeded",component:"block_opencast"}]).then((function(jsstrings){var _$3,_$4,seriestable=new _tabulator.default("#seriestable",{data:series,layout:"fitColumns",placeholder:jsstrings[3],headerSort:!1,dataLoaded:function(data){!function(contextid,ocinstanceid,series,seriestable,row){_ajax.default.call([{methodname:"block_opencast_get_series_titles",args:{contextid:contextid,ocinstanceid:ocinstanceid,series:JSON.stringify(series)},done:function(data){var titles=JSON.parse(data);null!==seriestable?seriestable.getRows().forEach((function(row){row.update({seriesname:titles[row.getData().series]})})):row.update({seriesname:titles[row.getData().series]})},fail:function(error){null!==seriestable?seriestable.getRows().forEach((function(row){row.update({seriesname:error.message})})):row.update({seriesname:error.message})}}])}(contextid,ocinstanceid,data.map((x=>x.series)),this)},columns:[{title:jsstrings[0],field:"seriesname",editable:!1},{title:jsstrings[1],field:"series",editable:!1},{title:jsstrings[2],field:"isdefault",hozAlign:"center",widthGrow:0,formatter:function(cell){var input=document.createElement("input");return input.type="radio",input.name="defaultseries",input.checked=cell.getValue(),input.classList.add("ignoredirty"),input.addEventListener("change",(function(){_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:jsstrings[13],body:jsstrings[14]}).then((function(modal){modal.getRoot().on(_modal_events.default.hidden,(function(){modal.destroy()})),modal.getRoot().on(_modal_events.default.save,(function(){_ajax.default.call([{methodname:"block_opencast_set_default_series",args:{contextid:contextid,ocinstanceid:ocinstanceid,seriesid:cell.getRow().getData().series},done:function(){modal.destroy(),cell.getTable().getRows().forEach((function(row){row===cell.getRow()?row.update({isdefault:1}):row.update({isdefault:0})})),_notification.default.addNotification({message:jsstrings[15],type:"success"})},fail:function(e){modal.destroy(),displayError(e.message)}}])})),modal.show()})).catch(_notification.default.exception)})),input}},{title:"",width:40,headerSort:!1,hozAlign:"center",formatter:function(){return''},cellClick:function(_,cell){_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:jsstrings[7],body:getBody(contextid,ocinstanceid,cell.getRow().getCell("series").getValue())}).then((function(modal){modal.setSaveButtonText(jsstrings[7]),modal.setLarge(),modal.getRoot().on(_modal_events.default.hidden,(function(){modal.destroy()})),modal.getRoot().on(_modal_events.default.shown,(function(){modal.getRoot().append("")})),modal.getRoot().on(_modal_events.default.save,(function(e){e.preventDefault(),modal.getRoot().find("form").submit()})),modal.getRoot().on("submit","form",{modal:modal,contextid:contextid,ocinstanceid:ocinstanceid,seriesid:cell.getRow().getCell("series").getValue(),numseriesallowed:numseriesallowed,edited:!0},submitFormAjax),modal.show()})).catch(_notification.default.exception)}},{title:"",width:40,headerSort:!1,hozAlign:"center",formatter:function(){return''},cellClick:function(e,cell){1!==cell.getRow().getData().isdefault?_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:jsstrings[5],body:jsstrings[6]}).then((function(modal){modal.setSaveButtonText(jsstrings[8]),modal.getRoot().on(_modal_events.default.save,(function(){_ajax.default.call([{methodname:"block_opencast_unlink_series",args:{contextid:contextid,ocinstanceid:ocinstanceid,seriesid:cell.getRow().getData().series},done:function(result){modal.destroy();let res=JSON.parse(result);if(res.error)displayError(res.message);else{cell.getRow().delete();const createseries=(0,_jquery.default)("#createseries"),importseries=(0,_jquery.default)("#importseries");null==createseries||createseries.show(),null==createseries||createseries.removeClass("d-none"),null==importseries||importseries.show(),null==importseries||importseries.removeClass("d-none"),_notification.default.addNotification({message:jsstrings[18],type:"success"})}},fail:function(e){modal.destroy(),displayError(e.message)}}])})),modal.show()})).catch(_notification.default.exception):_notification.default.alert(jsstrings[16],jsstrings[17])}}]});window.seriestable=seriestable,null===(_$3=(0,_jquery.default)("#createseries"))||void 0===_$3||_$3.click((function(){_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:jsstrings[4],body:getBody(contextid,ocinstanceid,"",void 0)}).then((function(modal){modal.setSaveButtonText(jsstrings[4]),modal.setLarge(),modal.getRoot().on(_modal_events.default.hidden,(function(){modal.destroy()})),modal.getRoot().on(_modal_events.default.shown,(function(){modal.getRoot().append("")})),modal.getRoot().on(_modal_events.default.save,(function(e){e.preventDefault(),modal.getRoot().find("form").submit()})),modal.getRoot().on("submit","form",{modal:modal,contextid:contextid,ocinstanceid:ocinstanceid,seriesid:"",numseriesallowed:numseriesallowed,edited:!1},submitFormAjax),modal.show()})).catch(_notification.default.exception)})),null===(_$4=(0,_jquery.default)("#importseries"))||void 0===_$4||_$4.click((function(){let context={label:jsstrings[12],required:!1,advanced:!1,element:{wrapperid:"importseriesid_wrapper",name:"importseriesid",id:"importseriesid",type:"text",size:40,value:""}};_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:jsstrings[10],body:_templates.default.render("core_form/element-text",context)}).then((function(modal){modal.setSaveButtonText(jsstrings[10]),modal.setLarge(),modal.getRoot().on(_modal_events.default.hidden,(function(){modal.destroy()})),modal.getRoot().on(_modal_events.default.save,(function(e){e.preventDefault();var seriesid=(0,_jquery.default)("#importseriesid").val();_ajax.default.call([{methodname:"block_opencast_import_series",args:{contextid:contextid,ocinstanceid:ocinstanceid,seriesid:seriesid},done:function(newseries){if(modal.destroy(),void 0!==seriestable){var _$5,_$6,s=JSON.parse(newseries);if(seriestable.addRow({seriesname:s.title,series:s.id,isdefault:s.isdefault}),seriestable.getRows().length>=numseriesallowed)null===(_$5=(0,_jquery.default)("#createseries"))||void 0===_$5||_$5.hide(),null===(_$6=(0,_jquery.default)("#importseries"))||void 0===_$6||_$6.hide();_notification.default.addNotification({message:jsstrings[19],type:"success"})}},fail:function(er){modal.destroy();var message=jsstrings[11];"importseries_alreadyexists"===er.errorcode&&(message=er.message),displayError(message)}}])})),modal.show()})).catch(_notification.default.exception)})),createseries&&(0,_jquery.default)("#createseries").trigger("click")})).catch(_notification.default.exception)}})); //# sourceMappingURL=block_manage_series.min.js.map \ No newline at end of file diff --git a/amd/build/block_manage_series.min.js.map b/amd/build/block_manage_series.min.js.map index e9097963..920e250b 100644 --- a/amd/build/block_manage_series.min.js.map +++ b/amd/build/block_manage_series.min.js.map @@ -1 +1 @@ -{"version":3,"file":"block_manage_series.min.js","sources":["../src/block_manage_series.js"],"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 * Javascript to initialise the opencast block settings.\n *\n * @module block/opencast\n * @copyright 2021 Tamara Gunkel, University of Münster\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Tabulator from 'block_opencast/tabulator';\nimport $ from 'jquery';\nimport * as str from 'core/str';\nimport ModalFactory from 'core/modal_factory';\nimport ModalEvents from 'core/modal_events';\nimport Fragment from 'core/fragment';\nimport Ajax from 'core/ajax';\nimport Templates from 'core/templates';\nimport Notification from 'core/notification';\n\n/**\n * Get the Body.\n *\n * @param {string} contextid\n * @param {string} ocinstanceid\n * @param {string} seriesid\n * @param {string|undefined} formdata\n * @return {Deferred} new promise that is resolved with the html and js of the Body.\n */\nfunction getBody(contextid, ocinstanceid, seriesid, formdata) {\n if (typeof formdata === 'undefined') {\n formdata = \"\";\n }\n\n var params = {ocinstanceid: ocinstanceid, seriesid: seriesid, jsonformdata: formdata};\n return Fragment.loadFragment('block_opencast', 'series_form', contextid, params);\n}\n\n/**\n * @param {any} e\n */\nfunction submitFormAjax(e) {\n e.preventDefault();\n var modal = e.data.modal;\n var contextid = e.data.contextid;\n var seriestable = window.seriestable;\n var edited = e.data.edited;\n var numseriesallowed = e.data.numseriesallowed;\n\n var changeEvent = document.createEvent('HTMLEvents');\n changeEvent.initEvent('change', true, true);\n\n // Run validation functions.\n modal.getRoot().find(':input').each(function(index, element) {\n element.dispatchEvent(changeEvent);\n });\n\n // Check if there are invalid fields.\n var invalid = $.merge(\n modal.getRoot().find('[aria-invalid=\"true\"]'),\n modal.getRoot().find('.error')\n );\n\n if (invalid.length) {\n invalid.first().focus();\n return;\n }\n\n // Convert all the form elements values to a serialised string.\n var formData = modal.getRoot().find('form').serialize();\n var seriestitle = $('.modal #id_title').val();\n\n // Submit form.\n Ajax.call([{\n methodname: 'block_opencast_submit_series_form',\n args: {contextid: contextid, ocinstanceid: e.data.ocinstanceid, seriesid: e.data.seriesid, jsonformdata: formData},\n done: function(newseries) {\n modal.destroy();\n if (edited) {\n let row = seriestable.getRows().find(r => r.getData().series === e.data.seriesid);\n row.update({\"seriesname\": seriestitle});\n } else {\n var s = JSON.parse(newseries);\n seriestable.addRow({'seriesname': s.seriestitle, 'series': s.series, 'isdefault': s.isdefault});\n\n if (seriestable.getRows().length >= numseriesallowed) {\n $(\"#createseries\")?.hide();\n $(\"#importseries\")?.hide();\n }\n }\n },\n fail: function(er) {\n if (er.errorcode === 'metadataseriesupdatefailed') {\n modal.destroy();\n displayError(er.message);\n } else {\n modal.setBody(getBody(contextid, e.data.ocinstanceid, e.data.seriesid, formData));\n }\n }\n }]);\n}\n\n/**\n * Displays an errormessage.\n *\n * @param {string} message\n */\nfunction displayError(message) {\n var context = {\n announce: true,\n closebutton: true,\n extraclasses: \"\",\n message: message\n };\n\n Templates.render(\"core/notification_error\", context).then(function(m) {\n $('#user-notifications').append(m);\n return;\n }).fail(function() {\n Notification.alert(message, message);\n });\n}\n\n/**\n * Loads series titles.\n *\n * @param {int} contextid\n * @param {int} ocinstanceid\n * @param {any} series\n * @param {any} seriestable\n * @param {any} row\n */\nfunction loadSeriesTitles(contextid, ocinstanceid, series, seriestable, row) {\n Ajax.call([{\n methodname: 'block_opencast_get_series_titles',\n args: {contextid: contextid, ocinstanceid: ocinstanceid, series: JSON.stringify(series)},\n done: function(data) {\n var titles = JSON.parse(data);\n if (seriestable !== null) {\n seriestable.getRows().forEach(function(row) {\n row.update({\"seriesname\": titles[row.getData().series]});\n });\n } else {\n row.update({\"seriesname\": titles[row.getData().series]});\n }\n\n },\n fail: function(error) {\n // Show error.\n if (seriestable !== null) {\n seriestable.getRows().forEach(function(row) {\n row.update({\"seriesname\": error.message});\n });\n } else {\n row.update({\"seriesname\": error.message});\n }\n }\n }]);\n}\n\nexport const init = (contextid, ocinstanceid, createseries, series, numseriesallowed) => {\n\n // Load strings\n var strings = [\n {key: 'seriesname', component: 'block_opencast'},\n {key: 'form_seriesid', component: 'block_opencast'},\n {key: 'default', component: 'block_opencast'},\n {key: 'noconnectedseries', component: 'block_opencast'},\n {key: 'createseriesforcourse', component: 'block_opencast'},\n {key: 'delete_series', component: 'block_opencast'},\n {key: 'delete_confirm_series', component: 'block_opencast'},\n {key: 'editseries', component: 'block_opencast'},\n {key: 'delete', component: 'moodle'},\n {key: 'loading', component: 'block_opencast'},\n {key: 'importseries', component: 'block_opencast'},\n {key: 'importfailed', component: 'block_opencast'},\n {key: 'form_seriesid', component: 'block_opencast'},\n {key: 'setdefaultseries_heading', component: 'block_opencast'},\n {key: 'setdefaultseries', component: 'block_opencast'}\n ];\n str.get_strings(strings).then(function(jsstrings) {\n // Style hidden input.\n var seriestable = new Tabulator(\"#seriestable\", {\n data: series,\n layout: \"fitColumns\",\n placeholder: jsstrings[3],\n headerSort: false,\n dataLoaded: function(data) {\n // Load series titles.\n loadSeriesTitles(contextid, ocinstanceid, data.map(x => x.series), this);\n },\n columns: [\n {title: jsstrings[0], field: \"seriesname\", editable: false},\n {title: jsstrings[1], field: \"series\", editable: false},\n {\n title: jsstrings[2], field: \"isdefault\",\n hozAlign: \"center\",\n widthGrow: 0,\n formatter: function(cell) {\n var input = document.createElement('input');\n input.type = 'radio';\n input.name = 'defaultseries';\n input.checked = cell.getValue();\n input.classList.add('ignoredirty');\n input.addEventListener('click', function(e) {\n e.preventDefault();\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: jsstrings[13],\n body: jsstrings[14]\n })\n .then(function(modal) {\n modal.getRoot().on(ModalEvents.hidden, function() {\n modal.destroy();\n });\n\n modal.getRoot().on(ModalEvents.save, function() {\n Ajax.call([{\n methodname: 'block_opencast_set_default_series',\n args: {contextid: contextid, ocinstanceid: ocinstanceid,\n seriesid: cell.getRow().getData().series},\n done: function() {\n modal.destroy();\n cell.getTable().getRows().forEach(function(row) {\n if (row === cell.getRow()) {\n row.update({'isdefault': 1});\n } else {\n row.update({'isdefault': 0});\n }\n });\n },\n fail: function(e) {\n modal.destroy();\n displayError(e.message);\n }\n }]);\n });\n modal.show();\n return;\n }).catch(Notification.exception);\n });\n return input;\n }\n },\n {\n title: \"\", width: 40, headerSort: false, hozAlign: \"center\", formatter:\n function() {\n return '';\n },\n cellClick: function(_, cell) {\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: jsstrings[7],\n body: getBody(contextid, ocinstanceid, cell.getRow().getCell(\"series\").getValue())\n })\n .then(function(modal) {\n modal.setSaveButtonText(jsstrings[7]);\n modal.setLarge();\n\n // Reset modal on every open event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n modal.destroy();\n });\n\n // We want to hide the submit buttons every time it is opened.\n modal.getRoot().on(ModalEvents.shown, function() {\n modal.getRoot().append('');\n });\n\n modal.getRoot().on(ModalEvents.save, function(e) {\n e.preventDefault();\n modal.getRoot().find('form').submit();\n });\n modal.getRoot().on('submit', 'form', {\n 'modal': modal,\n 'contextid': contextid,\n 'ocinstanceid': ocinstanceid,\n 'seriesid': cell.getRow().getCell(\"series\").getValue(),\n 'numseriesallowed': numseriesallowed,\n 'edited': true\n }, submitFormAjax);\n\n modal.show();\n return;\n }).catch(Notification.exception);\n }\n },\n {\n title: \"\", width: 40, headerSort: false, hozAlign: \"center\", formatter:\n function() {\n return '';\n },\n cellClick: function(e, cell) {\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: jsstrings[5],\n body: jsstrings[6]\n })\n .then(function(modal) {\n modal.setSaveButtonText(jsstrings[8]);\n modal.getRoot().on(ModalEvents.save, function() {\n Ajax.call([{\n methodname: 'block_opencast_unlink_series',\n args: {contextid: contextid, ocinstanceid: ocinstanceid,\n seriesid: cell.getRow().getData().series},\n done: function(result) {\n modal.destroy();\n let res = JSON.parse(result);\n if (res.error) {\n displayError(res.message);\n } else {\n cell.getRow().delete();\n const createseries = $(\"#createseries\");\n const importseries = $(\"#importseries\");\n createseries?.show();\n createseries?.removeClass('d-none');\n importseries?.show();\n importseries?.removeClass('d-none');\n }\n },\n fail: function(e) {\n modal.destroy();\n displayError(e.message);\n }\n }]);\n });\n modal.show();\n return;\n }).catch(Notification.exception);\n }\n }\n ],\n });\n\n window.seriestable = seriestable;\n\n // Create new series in modal\n // Button for connection a new series\n $('#createseries')?.click(function() {\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: jsstrings[4],\n body: getBody(contextid, ocinstanceid, '', undefined)\n })\n .then(function(modal) {\n modal.setSaveButtonText(jsstrings[4]);\n modal.setLarge();\n\n modal.getRoot().on(ModalEvents.hidden, function() {\n modal.destroy();\n });\n\n // We want to hide the submit buttons every time it is opened.\n modal.getRoot().on(ModalEvents.shown, function() {\n modal.getRoot().append('');\n });\n\n modal.getRoot().on(ModalEvents.save, function(e) {\n e.preventDefault();\n modal.getRoot().find('form').submit();\n });\n modal.getRoot().on('submit', 'form', {\n 'modal': modal,\n 'contextid': contextid,\n 'ocinstanceid': ocinstanceid,\n 'seriesid': '',\n 'numseriesallowed': numseriesallowed,\n 'edited': false\n }, submitFormAjax);\n\n modal.show();\n return;\n }).catch(Notification.exception);\n\n });\n\n // Import new series in modal\n $('#importseries')?.click(function() {\n let context = {\n label: jsstrings[12],\n required: false,\n advanced: false,\n element: {\n wrapperid: \"importseriesid_wrapper\",\n name: 'importseriesid',\n id: 'importseriesid',\n type: 'text',\n size: 40,\n value: ''\n }\n };\n\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: jsstrings[10],\n body: Templates.render(\"core_form/element-text\", context)\n })\n .then(function(modal) {\n modal.setSaveButtonText(jsstrings[10]);\n modal.setLarge();\n\n modal.getRoot().on(ModalEvents.hidden, function() {\n modal.destroy();\n });\n\n modal.getRoot().on(ModalEvents.save, function(e) {\n e.preventDefault();\n var seriesid = $('#importseriesid').val();\n\n // Submit form.\n Ajax.call([{\n methodname: 'block_opencast_import_series',\n args: {contextid: contextid, ocinstanceid: ocinstanceid, seriesid: seriesid},\n done: function(newseries) {\n modal.destroy();\n if (seriestable !== undefined) {\n var s = JSON.parse(newseries);\n seriestable.addRow({'seriesname': s.title, 'series': s.id, 'isdefault': s.isdefault});\n\n if (seriestable.getRows().length >= numseriesallowed) {\n $(\"#createseries\")?.hide();\n $(\"#importseries\")?.hide();\n }\n }\n },\n fail: function() {\n modal.destroy();\n displayError(jsstrings[11]);\n }\n }]);\n });\n\n modal.show();\n return;\n }).catch(Notification.exception);\n });\n\n // Perform click on createseries\n if (createseries) {\n $('#createseries').trigger('click');\n }\n return;\n }).catch(Notification.exception);\n};\n\n"],"names":["getBody","contextid","ocinstanceid","seriesid","formdata","params","jsonformdata","Fragment","loadFragment","submitFormAjax","e","preventDefault","modal","data","seriestable","window","edited","numseriesallowed","changeEvent","document","createEvent","initEvent","getRoot","find","each","index","element","dispatchEvent","invalid","$","merge","length","first","focus","formData","serialize","seriestitle","val","call","methodname","args","done","newseries","destroy","getRows","r","getData","series","update","s","JSON","parse","addRow","isdefault","hide","fail","er","errorcode","displayError","message","setBody","context","announce","closebutton","extraclasses","render","then","m","append","alert","createseries","str","get_strings","key","component","jsstrings","Tabulator","layout","placeholder","headerSort","dataLoaded","row","stringify","titles","forEach","error","loadSeriesTitles","map","x","this","columns","title","field","editable","hozAlign","widthGrow","formatter","cell","input","createElement","type","name","checked","getValue","classList","add","addEventListener","create","ModalFactory","types","SAVE_CANCEL","body","on","ModalEvents","hidden","save","getRow","getTable","show","catch","Notification","exception","width","cellClick","_","getCell","setSaveButtonText","setLarge","shown","submit","result","res","delete","importseries","removeClass","click","undefined","label","required","advanced","wrapperid","id","size","value","Templates","trigger"],"mappings":";;;;;;;cA0CSA,QAAQC,UAAWC,aAAcC,SAAUC,eACxB,IAAbA,WACPA,SAAW,QAGXC,OAAS,CAACH,aAAcA,aAAcC,SAAUA,SAAUG,aAAcF,iBACrEG,kBAASC,aAAa,iBAAkB,cAAeP,UAAWI,iBAMpEI,eAAeC,GACpBA,EAAEC,qBACEC,MAAQF,EAAEG,KAAKD,MACfX,UAAYS,EAAEG,KAAKZ,UACnBa,YAAcC,OAAOD,YACrBE,OAASN,EAAEG,KAAKG,OAChBC,iBAAmBP,EAAEG,KAAKI,iBAE1BC,YAAcC,SAASC,YAAY,cACvCF,YAAYG,UAAU,UAAU,GAAM,GAGtCT,MAAMU,UAAUC,KAAK,UAAUC,MAAK,SAASC,MAAOC,SAChDA,QAAQC,cAAcT,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ACvBmC,EAAIC,KAAKC,MAAMT,cACnB5B,YAAYsC,OAAO,YAAeH,EAAE0C,aAAiB1C,EAAE4F,aAAiB5F,EAAEI,YAEtEvC,YAAY8B,UAAUb,QAAUd,iDAC9B,qCAAkBqC,uCAClB,qCAAkBA,SAIhCC,KAAM,WACF3C,MAAM+B,UACNe,aAAaiB,UAAU,YAKnC/D,MAAM0G,UAEPC,MAAMC,sBAAaC,cAI1BnD,kCACE,iBAAiB2E,QAAQ,YAGhC1B,MAAMC,sBAAaC"} \ No newline at end of file +{"version":3,"file":"block_manage_series.min.js","sources":["../src/block_manage_series.js"],"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 * Javascript to initialise the opencast block settings.\n *\n * @module block/opencast\n * @copyright 2021 Tamara Gunkel, University of Münster\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Tabulator from 'block_opencast/tabulator';\nimport $ from 'jquery';\nimport * as str from 'core/str';\nimport ModalFactory from 'core/modal_factory';\nimport ModalEvents from 'core/modal_events';\nimport Fragment from 'core/fragment';\nimport Ajax from 'core/ajax';\nimport Templates from 'core/templates';\nimport Notification from 'core/notification';\n\n/**\n * Get the Body.\n *\n * @param {string} contextid\n * @param {string} ocinstanceid\n * @param {string} seriesid\n * @param {string|undefined} formdata\n * @return {Deferred} new promise that is resolved with the html and js of the Body.\n */\nfunction getBody(contextid, ocinstanceid, seriesid, formdata) {\n if (typeof formdata === 'undefined') {\n formdata = \"\";\n }\n\n var params = {ocinstanceid: ocinstanceid, seriesid: seriesid, jsonformdata: formdata};\n return Fragment.loadFragment('block_opencast', 'series_form', contextid, params);\n}\n\n/**\n * @param {any} e\n */\nfunction submitFormAjax(e) {\n e.preventDefault();\n var modal = e.data.modal;\n var contextid = e.data.contextid;\n var seriestable = window.seriestable;\n var edited = e.data.edited;\n var numseriesallowed = e.data.numseriesallowed;\n\n var changeEvent = document.createEvent('HTMLEvents');\n changeEvent.initEvent('change', true, true);\n\n // Run validation functions.\n modal.getRoot().find(':input').each(function(index, element) {\n element.dispatchEvent(changeEvent);\n });\n\n // Check if there are invalid fields.\n var invalid = $.merge(\n modal.getRoot().find('[aria-invalid=\"true\"]'),\n modal.getRoot().find('.error')\n );\n\n if (invalid.length) {\n invalid.first().focus();\n return;\n }\n\n // Convert all the form elements values to a serialised string.\n var formData = modal.getRoot().find('form').serialize();\n var seriestitle = $('.modal #id_title').val();\n\n // Submit form.\n Ajax.call([{\n methodname: 'block_opencast_submit_series_form',\n args: {contextid: contextid, ocinstanceid: e.data.ocinstanceid, seriesid: e.data.seriesid, jsonformdata: formData},\n done: function(newseries) {\n modal.destroy();\n var stringkey = 'createseriesforcourse_succeeded';\n if (edited) {\n let row = seriestable.getRows().find(r => r.getData().series === e.data.seriesid);\n row.update({\"seriesname\": seriestitle});\n stringkey = 'editseries_succeeded';\n } else {\n var s = JSON.parse(newseries);\n seriestable.addRow({'seriesname': s.seriestitle, 'series': s.series, 'isdefault': s.isdefault});\n\n if (seriestable.getRows().length >= numseriesallowed) {\n $(\"#createseries\")?.hide();\n $(\"#importseries\")?.hide();\n }\n\n }\n // We now notify the user about the successful series creation or edit.\n str.get_string(stringkey, 'block_opencast')\n .done(function(result) {\n Notification.addNotification({\n message: result,\n type: 'success'\n });\n })\n .fail(Notification.exception);\n },\n fail: function(er) {\n if (er.errorcode === 'metadataseriesupdatefailed') {\n modal.destroy();\n displayError(er.message);\n } else {\n modal.setBody(getBody(contextid, e.data.ocinstanceid, e.data.seriesid, formData));\n }\n }\n }]);\n}\n\n/**\n * Displays an errormessage.\n *\n * @param {string} message\n */\nfunction displayError(message) {\n var context = {\n announce: true,\n closebutton: true,\n extraclasses: \"\",\n message: message\n };\n\n Templates.render(\"core/notification_error\", context).then(function(m) {\n $('#user-notifications').append(m);\n return;\n }).fail(function() {\n Notification.alert(message, message);\n });\n}\n\n/**\n * Loads series titles.\n *\n * @param {int} contextid\n * @param {int} ocinstanceid\n * @param {any} series\n * @param {any} seriestable\n * @param {any} row\n */\nfunction loadSeriesTitles(contextid, ocinstanceid, series, seriestable, row) {\n Ajax.call([{\n methodname: 'block_opencast_get_series_titles',\n args: {contextid: contextid, ocinstanceid: ocinstanceid, series: JSON.stringify(series)},\n done: function(data) {\n var titles = JSON.parse(data);\n if (seriestable !== null) {\n seriestable.getRows().forEach(function(row) {\n row.update({\"seriesname\": titles[row.getData().series]});\n });\n } else {\n row.update({\"seriesname\": titles[row.getData().series]});\n }\n\n },\n fail: function(error) {\n // Show error.\n if (seriestable !== null) {\n seriestable.getRows().forEach(function(row) {\n row.update({\"seriesname\": error.message});\n });\n } else {\n row.update({\"seriesname\": error.message});\n }\n }\n }]);\n}\n\nexport const init = (contextid, ocinstanceid, createseries, series, numseriesallowed) => {\n\n // Load strings\n var strings = [\n {key: 'seriesname', component: 'block_opencast'},\n {key: 'form_seriesid', component: 'block_opencast'},\n {key: 'default', component: 'block_opencast'},\n {key: 'noconnectedseries', component: 'block_opencast'},\n {key: 'createseriesforcourse', component: 'block_opencast'},\n {key: 'delete_series', component: 'block_opencast'},\n {key: 'delete_confirm_series', component: 'block_opencast'},\n {key: 'editseries', component: 'block_opencast'},\n {key: 'delete', component: 'moodle'},\n {key: 'loading', component: 'block_opencast'},\n {key: 'importseries', component: 'block_opencast'},\n {key: 'importfailed', component: 'block_opencast'},\n {key: 'form_seriesid', component: 'block_opencast'},\n {key: 'setdefaultseries_heading', component: 'block_opencast'},\n {key: 'setdefaultseries', component: 'block_opencast'},\n {key: 'setdefaultseriessucceeded', component: 'block_opencast'},\n {key: 'cantdeletedefaultseries_modaltitle', component: 'block_opencast'},\n {key: 'cantdeletedefaultseries', component: 'block_opencast'},\n {key: 'delete_series_succeeded', component: 'block_opencast'},\n {key: 'importseries_succeeded', component: 'block_opencast'},\n ];\n str.get_strings(strings).then(function(jsstrings) {\n // Style hidden input.\n var seriestable = new Tabulator(\"#seriestable\", {\n data: series,\n layout: \"fitColumns\",\n placeholder: jsstrings[3],\n headerSort: false,\n dataLoaded: function(data) {\n // Load series titles.\n loadSeriesTitles(contextid, ocinstanceid, data.map(x => x.series), this);\n },\n columns: [\n {title: jsstrings[0], field: \"seriesname\", editable: false},\n {title: jsstrings[1], field: \"series\", editable: false},\n {\n title: jsstrings[2], field: \"isdefault\",\n hozAlign: \"center\",\n widthGrow: 0,\n formatter: function(cell) {\n var input = document.createElement('input');\n input.type = 'radio';\n input.name = 'defaultseries';\n input.checked = cell.getValue();\n input.classList.add('ignoredirty');\n input.addEventListener('change', function() {\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: jsstrings[13],\n body: jsstrings[14]\n })\n .then(function(modal) {\n modal.getRoot().on(ModalEvents.hidden, function() {\n modal.destroy();\n });\n\n modal.getRoot().on(ModalEvents.save, function() {\n Ajax.call([{\n methodname: 'block_opencast_set_default_series',\n args: {contextid: contextid, ocinstanceid: ocinstanceid,\n seriesid: cell.getRow().getData().series},\n done: function() {\n modal.destroy();\n cell.getTable().getRows().forEach(function(row) {\n if (row === cell.getRow()) {\n row.update({'isdefault': 1});\n } else {\n row.update({'isdefault': 0});\n }\n });\n // We now notify the user about the successful update.\n Notification.addNotification({\n message: jsstrings[15],\n type: 'success'\n });\n },\n fail: function(e) {\n modal.destroy();\n displayError(e.message);\n }\n }]);\n });\n modal.show();\n return;\n }).catch(Notification.exception);\n });\n return input;\n }\n },\n {\n title: \"\", width: 40, headerSort: false, hozAlign: \"center\", formatter:\n function() {\n return '';\n },\n cellClick: function(_, cell) {\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: jsstrings[7],\n body: getBody(contextid, ocinstanceid, cell.getRow().getCell(\"series\").getValue())\n })\n .then(function(modal) {\n modal.setSaveButtonText(jsstrings[7]);\n modal.setLarge();\n\n // Reset modal on every open event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n modal.destroy();\n });\n\n // We want to hide the submit buttons every time it is opened.\n modal.getRoot().on(ModalEvents.shown, function() {\n modal.getRoot().append('');\n });\n\n modal.getRoot().on(ModalEvents.save, function(e) {\n e.preventDefault();\n modal.getRoot().find('form').submit();\n });\n modal.getRoot().on('submit', 'form', {\n 'modal': modal,\n 'contextid': contextid,\n 'ocinstanceid': ocinstanceid,\n 'seriesid': cell.getRow().getCell(\"series\").getValue(),\n 'numseriesallowed': numseriesallowed,\n 'edited': true\n }, submitFormAjax);\n\n modal.show();\n return;\n }).catch(Notification.exception);\n }\n },\n {\n title: \"\", width: 40, headerSort: false, hozAlign: \"center\", formatter:\n function() {\n return '';\n },\n cellClick: function(e, cell) {\n // We prevent default series deletion at js level as well.\n if (cell.getRow().getData().isdefault === 1) {\n Notification.alert(jsstrings[16], jsstrings[17]);\n return;\n }\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: jsstrings[5],\n body: jsstrings[6]\n })\n .then(function(modal) {\n modal.setSaveButtonText(jsstrings[8]);\n modal.getRoot().on(ModalEvents.save, function() {\n Ajax.call([{\n methodname: 'block_opencast_unlink_series',\n args: {contextid: contextid, ocinstanceid: ocinstanceid,\n seriesid: cell.getRow().getData().series},\n done: function(result) {\n modal.destroy();\n let res = JSON.parse(result);\n if (res.error) {\n displayError(res.message);\n } else {\n cell.getRow().delete();\n const createseries = $(\"#createseries\");\n const importseries = $(\"#importseries\");\n createseries?.show();\n createseries?.removeClass('d-none');\n importseries?.show();\n importseries?.removeClass('d-none');\n // We now notify the user about the successful deletion.\n Notification.addNotification({\n message: jsstrings[18],\n type: 'success'\n });\n }\n },\n fail: function(e) {\n modal.destroy();\n displayError(e.message);\n }\n }]);\n });\n modal.show();\n return;\n }).catch(Notification.exception);\n }\n }\n ],\n });\n\n window.seriestable = seriestable;\n\n // Create new series in modal\n // Button for connection a new series\n $('#createseries')?.click(function() {\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: jsstrings[4],\n body: getBody(contextid, ocinstanceid, '', undefined)\n })\n .then(function(modal) {\n modal.setSaveButtonText(jsstrings[4]);\n modal.setLarge();\n\n modal.getRoot().on(ModalEvents.hidden, function() {\n modal.destroy();\n });\n\n // We want to hide the submit buttons every time it is opened.\n modal.getRoot().on(ModalEvents.shown, function() {\n modal.getRoot().append('');\n });\n\n modal.getRoot().on(ModalEvents.save, function(e) {\n e.preventDefault();\n modal.getRoot().find('form').submit();\n });\n modal.getRoot().on('submit', 'form', {\n 'modal': modal,\n 'contextid': contextid,\n 'ocinstanceid': ocinstanceid,\n 'seriesid': '',\n 'numseriesallowed': numseriesallowed,\n 'edited': false\n }, submitFormAjax);\n\n modal.show();\n return;\n }).catch(Notification.exception);\n\n });\n\n // Import new series in modal\n $('#importseries')?.click(function() {\n let context = {\n label: jsstrings[12],\n required: false,\n advanced: false,\n element: {\n wrapperid: \"importseriesid_wrapper\",\n name: 'importseriesid',\n id: 'importseriesid',\n type: 'text',\n size: 40,\n value: ''\n }\n };\n\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: jsstrings[10],\n body: Templates.render(\"core_form/element-text\", context)\n })\n .then(function(modal) {\n modal.setSaveButtonText(jsstrings[10]);\n modal.setLarge();\n\n modal.getRoot().on(ModalEvents.hidden, function() {\n modal.destroy();\n });\n\n modal.getRoot().on(ModalEvents.save, function(e) {\n e.preventDefault();\n var seriesid = $('#importseriesid').val();\n\n // Submit form.\n Ajax.call([{\n methodname: 'block_opencast_import_series',\n args: {contextid: contextid, ocinstanceid: ocinstanceid, seriesid: seriesid},\n done: function(newseries) {\n modal.destroy();\n if (seriestable !== undefined) {\n var s = JSON.parse(newseries);\n seriestable.addRow({'seriesname': s.title, 'series': s.id, 'isdefault': s.isdefault});\n\n if (seriestable.getRows().length >= numseriesallowed) {\n $(\"#createseries\")?.hide();\n $(\"#importseries\")?.hide();\n }\n\n // We now notify the user about the successful series import.\n Notification.addNotification({\n message: jsstrings[19],\n type: 'success'\n });\n }\n },\n fail: function(er) {\n modal.destroy();\n var message = jsstrings[11];\n if (er.errorcode === 'importseries_alreadyexists') {\n message = er.message;\n }\n displayError(message);\n }\n }]);\n });\n\n modal.show();\n return;\n }).catch(Notification.exception);\n });\n\n // Perform click on createseries\n if (createseries) {\n $('#createseries').trigger('click');\n }\n return;\n }).catch(Notification.exception);\n};\n\n"],"names":["getBody","contextid","ocinstanceid","seriesid","formdata","params","jsonformdata","Fragment","loadFragment","submitFormAjax","e","preventDefault","modal","data","seriestable","window","edited","numseriesallowed","changeEvent","document","createEvent","initEvent","getRoot","find","each","index","element","dispatchEvent","invalid","$","merge","length","first","focus","formData","serialize","seriestitle","val","call","methodname","args","done","newseries","destroy","stringkey","getRows","r","getData","series","update","s","JSON","parse","addRow","isdefault","hide","str","get_string","result","addNotification","message","type","fail","Notification","exception","er","errorcode","displayError","setBody","context","announce","closebutton","extraclasses","render","then","m","append","alert","createseries","get_strings","key","component","jsstrings","Tabulator","layout","placeholder","headerSort","dataLoaded","row","stringify","titles","forEach","error","loadSeriesTitles","map","x","this","columns","title","field","editable","hozAlign","widthGrow","formatter","cell","input","createElement","name","checked","getValue","classList","add","addEventListener","create","ModalFactory","types","SAVE_CANCEL","body","on","ModalEvents","hidden","save","getRow","getTable","show","catch","width","cellClick","_","getCell","setSaveButtonText","setLarge","shown","submit","res","delete","importseries","removeClass","click","undefined","label","required","advanced","wrapperid","id","size","value","Templates","trigger"],"mappings":";;;;;;;cA0CSA,QAAQC,UAAWC,aAAcC,SAAUC,eACxB,IAAbA,WACPA,SAAW,QAGXC,OAAS,CAACH,aAAcA,aAAcC,SAAUA,SAAUG,aAAcF,iBACrEG,kBAASC,aAAa,iBAAkB,cAAeP,U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sE,QAAQ,YAGhCvB,MAAM9D,sBAAaC"} \ No newline at end of file diff --git a/amd/src/block_manage_series.js b/amd/src/block_manage_series.js index 510a63dd..99c44879 100644 --- a/amd/src/block_manage_series.js +++ b/amd/src/block_manage_series.js @@ -89,9 +89,11 @@ function submitFormAjax(e) { args: {contextid: contextid, ocinstanceid: e.data.ocinstanceid, seriesid: e.data.seriesid, jsonformdata: formData}, done: function(newseries) { modal.destroy(); + var stringkey = 'createseriesforcourse_succeeded'; if (edited) { let row = seriestable.getRows().find(r => r.getData().series === e.data.seriesid); row.update({"seriesname": seriestitle}); + stringkey = 'editseries_succeeded'; } else { var s = JSON.parse(newseries); seriestable.addRow({'seriesname': s.seriestitle, 'series': s.series, 'isdefault': s.isdefault}); @@ -100,7 +102,17 @@ function submitFormAjax(e) { $("#createseries")?.hide(); $("#importseries")?.hide(); } + } + // We now notify the user about the successful series creation or edit. + str.get_string(stringkey, 'block_opencast') + .done(function(result) { + Notification.addNotification({ + message: result, + type: 'success' + }); + }) + .fail(Notification.exception); }, fail: function(er) { if (er.errorcode === 'metadataseriesupdatefailed') { @@ -189,7 +201,12 @@ export const init = (contextid, ocinstanceid, createseries, series, numseriesall {key: 'importfailed', component: 'block_opencast'}, {key: 'form_seriesid', component: 'block_opencast'}, {key: 'setdefaultseries_heading', component: 'block_opencast'}, - {key: 'setdefaultseries', component: 'block_opencast'} + {key: 'setdefaultseries', component: 'block_opencast'}, + {key: 'setdefaultseriessucceeded', component: 'block_opencast'}, + {key: 'cantdeletedefaultseries_modaltitle', component: 'block_opencast'}, + {key: 'cantdeletedefaultseries', component: 'block_opencast'}, + {key: 'delete_series_succeeded', component: 'block_opencast'}, + {key: 'importseries_succeeded', component: 'block_opencast'}, ]; str.get_strings(strings).then(function(jsstrings) { // Style hidden input. @@ -215,8 +232,7 @@ export const init = (contextid, ocinstanceid, createseries, series, numseriesall input.name = 'defaultseries'; input.checked = cell.getValue(); input.classList.add('ignoredirty'); - input.addEventListener('click', function(e) { - e.preventDefault(); + input.addEventListener('change', function() { ModalFactory.create({ type: ModalFactory.types.SAVE_CANCEL, title: jsstrings[13], @@ -241,6 +257,11 @@ export const init = (contextid, ocinstanceid, createseries, series, numseriesall row.update({'isdefault': 0}); } }); + // We now notify the user about the successful update. + Notification.addNotification({ + message: jsstrings[15], + type: 'success' + }); }, fail: function(e) { modal.destroy(); @@ -304,6 +325,11 @@ export const init = (contextid, ocinstanceid, createseries, series, numseriesall return ''; }, cellClick: function(e, cell) { + // We prevent default series deletion at js level as well. + if (cell.getRow().getData().isdefault === 1) { + Notification.alert(jsstrings[16], jsstrings[17]); + return; + } ModalFactory.create({ type: ModalFactory.types.SAVE_CANCEL, title: jsstrings[5], @@ -329,6 +355,11 @@ export const init = (contextid, ocinstanceid, createseries, series, numseriesall createseries?.removeClass('d-none'); importseries?.show(); importseries?.removeClass('d-none'); + // We now notify the user about the successful deletion. + Notification.addNotification({ + message: jsstrings[18], + type: 'success' + }); } }, fail: function(e) { @@ -434,11 +465,21 @@ export const init = (contextid, ocinstanceid, createseries, series, numseriesall $("#createseries")?.hide(); $("#importseries")?.hide(); } + + // We now notify the user about the successful series import. + Notification.addNotification({ + message: jsstrings[19], + type: 'success' + }); } }, - fail: function() { + fail: function(er) { modal.destroy(); - displayError(jsstrings[11]); + var message = jsstrings[11]; + if (er.errorcode === 'importseries_alreadyexists') { + message = er.message; + } + displayError(message); } }]); }); diff --git a/classes/external.php b/classes/external.php index 06ec77d9..f78fc109 100644 --- a/classes/external.php +++ b/classes/external.php @@ -261,6 +261,16 @@ public static function import_series(int $contextid, int $ocinstanceid, string $ throw new moodle_exception('maxseriesreached', 'block_opencast'); } + // Check if the series id already exists in this course. + $importingseriesid = $params['seriesid']; + $existingseries = array_filter($courseseries, function ($courseserie) use ($importingseriesid) { + return $courseserie->series === $importingseriesid; + }); + + if (count($existingseries) > 0) { + throw new moodle_exception('importseries_alreadyexists', 'block_opencast'); + } + // Perform ACL change. $apibridge = apibridge::get_instance($params['ocinstanceid']); $result = $apibridge->import_series_to_course_with_acl_change($course->id, $params['seriesid'], $USER->id); @@ -293,20 +303,36 @@ public static function unlink_series(int $contextid, int $ocinstanceid, string $ 'seriesid' => $series, ]); + $unlinkall = $params['seriesid'] === 'all'; + $context = context::instance_by_id($params['contextid']); self::validate_context($context); require_capability('block/opencast:manageseriesforcourse', $context); list($unused, $course, $cm) = get_context_info_array($context->id); - if ($params['seriesid'] === 'all') { + // In case the request comes from block deletion remove all mappings. + if ($unlinkall) { $mappings = seriesmapping::get_records(['courseid' => $course->id]); } else { + // Otherwise, the request comes from normal series deletion page. $mappings = seriesmapping::get_records(['ocinstanceid' => $params['ocinstanceid'], 'courseid' => $course->id, 'series' => $params['seriesid']]); } foreach ($mappings as $mapping) { + $isdefault = $mapping->get('isdefault'); + // We need to check the uniqueness of the mapping record when it is a single mapping removal. + if ($isdefault && !$unlinkall) { + // Prevent deletion of default series. + // By checking the number of default series, + // it is still possible to correct the faulty scenario of having multi-default series in a course. + if (seriesmapping::count_records(['ocinstanceid' => $params['ocinstanceid'], + 'courseid' => $course->id, 'isdefault' => true, ]) === 1) { + throw new moodle_exception('cantdeletedefaultseries', 'block_opencast'); + } + } + if (!$mapping->delete()) { throw new moodle_exception('delete_series_failed', 'block_opencast'); } @@ -349,7 +375,9 @@ public static function set_default_series(int $contextid, int $ocinstanceid, str 'courseid' => $course->id, 'isdefault' => true, ]); // Series is already set as default. - if ($olddefaultseries->get('series') == $params['seriesid']) { + // We provide an exception here to fix the problem of having a course with no default series, which should not happen, + // by letting it pass through when the old default does not exist. + if (!empty($olddefaultseries) && $olddefaultseries->get('series') == $params['seriesid']) { return true; } @@ -357,16 +385,20 @@ public static function set_default_series(int $contextid, int $ocinstanceid, str $mapping = seriesmapping::get_record(['ocinstanceid' => $params['ocinstanceid'], 'courseid' => $course->id, 'series' => $params['seriesid'], ], true); - if ($mapping) { + // Remove default flag from old series first. + $canbeupdated = empty($olddefaultseries); + if (!empty($olddefaultseries)) { + $olddefaultseries->set('isdefault', false); + if ($olddefaultseries->update()) { + $canbeupdated = true; + } + } + + // Now, we go for the actual update. + if ($canbeupdated && $mapping) { $mapping->set('isdefault', true); if ($mapping->update()) { - // Remove default flag from old series. - if ($olddefaultseries) { - $olddefaultseries->set('isdefault', false); - if ($olddefaultseries->update()) { - return true; - } - } + return true; } } diff --git a/classes/local/ltimodulemanager.php b/classes/local/ltimodulemanager.php index afca4da8..62182b20 100644 --- a/classes/local/ltimodulemanager.php +++ b/classes/local/ltimodulemanager.php @@ -443,7 +443,7 @@ public static function build_lti_modinfo($pluginid, $course, $title, $sectionid, $moduleinfo->availability = $availability; // Apply completion defaults. - $module = $DB->get_record('modules', ['name' => 'opencast']); + $module = $DB->get_record('modules', ['name' => 'lti'], '*', MUST_EXIST); $defaults = manager::get_default_completion($course, $module); if ($module) { foreach ($defaults as $key => $value) { diff --git a/lang/en/block_opencast.php b/lang/en/block_opencast.php index f715cad5..df169aa7 100644 --- a/lang/en/block_opencast.php +++ b/lang/en/block_opencast.php @@ -198,7 +198,8 @@ $string['cachedef_videodata'] = 'Caches the result of the opencast api for the opencast-block.'; $string['cachevalidtime'] = 'Cache valid time'; $string['cachevalidtime_desc'] = 'Time in seconds, before the cache for the video data of each course is refreshed.'; -$string['cantdeletedefaultseries'] = 'You cannot delete the default series. Please choose another default series before deleting this series.'; +$string['cantdeletedefaultseries'] = 'You cannot delete the default series. Please choose another series as default for this course before deleting this series.'; +$string['cantdeletedefaultseries_modaltitle'] = 'Cannot Delete Default Series'; $string['catalog_params_noarray'] = "Parameters have to be either empty or a JSON representation of an array or an object."; $string['catalog_static_params_empty'] = "Read only fields need to define a text in the parameters field."; $string['catalogparam'] = 'Parameters in JSON-Format'; @@ -240,6 +241,7 @@ $string['created'] = 'Created at'; $string['createdby'] = 'Uploaded by'; $string['createseriesforcourse'] = 'Create new series'; +$string['createseriesforcourse_succeeded'] = 'A new series has been successfully created.'; $string['creator'] = 'Presenter(s)'; $string['cronsettings'] = 'Settings for upload jobs'; $string['date'] = 'Start Date'; @@ -255,6 +257,7 @@ $string['delete_role'] = 'Delete role'; $string['delete_series'] = 'Delete series'; $string['delete_series_failed'] = 'Deleting the series failed. Please try again later or contact an administrator.'; +$string['delete_series_succeeded'] = 'The series has been successfully deleted.'; $string['deleteaclgroup'] = 'Delete video from this list.'; $string['deletecheck_title_modal'] = 'Remove Opencast Block?'; $string['deletedraft'] = 'Delete a video before transfer to Opencast'; @@ -308,6 +311,7 @@ $string['editorendpointurl'] = 'Opencast Editor Endpoint'; $string['editorendpointurl_desc'] = 'The editor endpoint to access the editor. The mediapackage ID will be added at the end of the url.'; $string['editseries'] = 'Edit series'; +$string['editseries_succeeded'] = 'The series has been successfully updated.'; $string['embeddedasactivity'] = 'Embedded as activity'; $string['embeddedasactivitywolink'] = 'Embedded as activity without linked series'; $string['empty_catalogname'] = 'This field must not be empty'; @@ -425,6 +429,8 @@ $string['importmode'] = 'Import mode'; $string['importmodedesc'] = 'In order to define an approach to import videos into a course, a mode should be seleted. The default mode is Duplicating Events in which a new series would be created and events will be avaible in the series by using a dupliaction workflow.
ACL Change approach on the other hand will use the same seriesid among courses but series and events\' ACLs are changes to grant access from the course which imports the videos.
NOTE: At the moment, the selection of events in import wizards (course and manual) for "ACL Change" is NOT possible, due to avoiding further complications in terms of permissions in Opencast.'; $string['importseries'] = 'Import series'; +$string['importseries_alreadyexists'] = 'The series you are trying to import is already present. Please choose a different series.'; +$string['importseries_succeeded'] = 'The series has been successfully imported.'; $string['importvideos_aclprocessingexplanation'] = 'The seriesid of the selected course will be used in this course and the series\' ACL as well as ACLs of its videos will be changed accordingly.'; $string['importvideos_errornotenabledorworking'] = 'The import videos feature is not enabled or not working'; $string['importvideos_importbuttontitle'] = 'Import videos'; @@ -747,6 +753,7 @@ $string['setdefaultseries'] = 'Do you really want to use this series as new default series?'; $string['setdefaultseries_heading'] = 'Set default series'; $string['setdefaultseriesfailed'] = 'Changing the default series failed. Please try again later or contact an administrator.'; +$string['setdefaultseriessucceeded'] = 'The default series has been successfully changed.'; $string['setting_permanent'] = 'Is permanent'; $string['settings'] = 'Opencast Videos'; $string['shared_settings'] = 'Shared settings'; diff --git a/styles.css b/styles.css index 086e1b80..0610bceb 100644 --- a/styles.css +++ b/styles.css @@ -118,3 +118,12 @@ table.opencast-videos-table.generaltable thead th.oc-sortable-alignment > i { float: left; margin: 4px 0 1px 3px; } + +/* Styles for Series Table */ +#seriestable .tabulator-row .tabulator-cell { + cursor: default !important; /* stylelint-disable-line */ +} + +#seriestable .tabulator-row .tabulator-cell input[type="radio"]:not(:checked) { + cursor: pointer !important; /* stylelint-disable-line */ +} diff --git a/tests/behat/block_opencast_manageseries.feature b/tests/behat/block_opencast_manageseries.feature index 8dd74ec1..ddc56437 100644 --- a/tests/behat/block_opencast_manageseries.feature +++ b/tests/behat/block_opencast_manageseries.feature @@ -45,9 +45,8 @@ Feature: Manage series as Teacher And I set the field "Rights" to "Some user" And I select "ALLRIGHTS" from the "License" singleselect And I click on "Create new series" "button" in the ".modal" "css_element" - And I wait "2" seconds - Then I should see "My new series" - And I should see "84bab8de-5688-46a1-9af0-5ce9122eeb6a" + And I wait "1" seconds + Then I should see "A new series has been successfully created." @javascript Scenario: Teachers should be able to edit an existing series @@ -60,9 +59,8 @@ Feature: Manage series as Teacher And I set the field "Rights" to "Some user" And I select "ALLRIGHTS" from the "License" singleselect And I click on "Edit series" "button" - And I wait "2" seconds - Then I should not see "Updating the series metadata failed" - And I should see "Another series title" + And I wait "1" seconds + Then I should see "The series has been successfully updated." @javascript Scenario: Teachers should not be able to create/import series if the maximum number of series is reached @@ -75,36 +73,45 @@ Feature: Manage series as Teacher And I should not see "Import series" @javascript - Scenario: Teachers should not be able to select a different default series + Scenario: Teachers should be able to select a different default series Given I create a second series When I click on "Go to overview..." "link" And I click on "Manage series" "link" And I click on ".tabulator-row-even input[name=\"defaultseries\"]" "css_element" Then I should see "Do you really want to use this series as new default series" When I click on "Save changes" "button" - And I wait "2" seconds - Then I should not see "Changing the default series failed" + And I wait "1" seconds + Then I should see "The default series has been successfully changed." @javascript - Scenario: Teachers should be able to delete a series + Scenario: Teachers should be able to delete a series but should not be able to delete the default series Given I create a second series When I click on "Go to overview..." "link" And I click on "Manage series" "link" And I click on ".tabulator-row-even i.fa-trash" "css_element" Then I should see "Are you sure you want to delete this series" When I click on "Delete" "button" in the ".modal" "css_element" - And I wait "2" seconds - Then I should not see "Another series" + And I wait "1" seconds + Then I should see "The series has been successfully deleted." + When I click on ".tabulator-row-odd i.fa-trash" "css_element" + Then I should see "Cannot Delete Default Series" + When I click on "OK" "button" in the ".modal" "css_element" + Then I should see "1234-1234-1234-1234-1234" @javascript - Scenario: Teachers should be able to import a series + Scenario: Teachers should be able to import a series but should not be able to import a series twice When I click on "Go to overview..." "link" And I click on "Manage series" "link" And I click on "Import series" "button" And I set the field "Series ID" to "1111-1111-1111-1111-1111" And I click on "Import series" "button" in the ".modal" "css_element" - And I wait "2" seconds - Then I should not see "The series could not be imported" + And I wait "1" seconds + Then I should see "The series has been successfully imported." + When I click on "Import series" "button" + And I set the field "Series ID" to "1111-1111-1111-1111-1111" + And I click on "Import series" "button" in the ".modal" "css_element" + And I wait "1" seconds + Then I should see "The series you are trying to import is already present. Please choose a different series." @javascript Scenario: When manually deleting a block, teacher will be asked to decide whether to delete seriesmapping in a confirmation.