Merge branch 'MDL-70438-311' of git://github.com/sarjona/moodle into MOODLE_311_STABLE
This commit is contained in:
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("core_contentbank/actions",["jquery","core/ajax","core/notification","core/str","core/templates","core/url","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f,g,h){var k={DELETE_CONTENT:"[data-action=\"deletecontent\"]",RENAME_CONTENT:"[data-action=\"renamecontent\"]"},l=function(){this.registerEvents()};l.prototype.registerEvents=function(){a(k.DELETE_CONTENT).click(function(b){b.preventDefault();var e=a(this).data("contentname"),f=a(this).data("contentid"),j=a(this).data("contextid"),k="";d.get_strings([{key:"deletecontent",component:"core_contentbank"},{key:"deletecontentconfirm",component:"core_contentbank",param:{name:e}},{key:"delete",component:"core"}]).then(function(a){var b=a[0],c=a[1];k=a[2];return g.create({title:b,body:c,type:g.types.SAVE_CANCEL,large:!0})}).done(function(a){a.setSaveButtonText(k);a.getRoot().on(h.save,function(){return i(f,j)});a.getRoot().on(h.hidden,function(){a.destroy()});a.show()}).catch(c.exception)});a(k.RENAME_CONTENT).click(function(b){b.preventDefault();var f=a(this).data("contentname"),i=a(this).data("contentid"),k="";d.get_strings([{key:"renamecontent",component:"core_contentbank"},{key:"rename",component:"core_contentbank"}]).then(function(a){var b=a[0];k=a[1];return g.create({title:b,body:e.render("core_contentbank/renamecontent",{contentid:i,name:f}),type:g.types.SAVE_CANCEL})}).then(function(b){b.setSaveButtonText(k);b.getRoot().on(h.save,function(b){var e=a("#newname").val().trim();if(e){j(i,e)}else{d.get_strings([{key:"error"},{key:"emptynamenotallowed",component:"core_contentbank"}]).then(function(a){c.alert(a[0],a[1])}).catch(c.exception);b.preventDefault()}});b.getRoot().on(h.hidden,function(){b.destroy()});b.show()}).catch(c.exception)})};function i(a,d){var e="success";b.call([{methodname:"core_contentbank_delete_content",args:{contentids:{contentid:a}}}])[0].then(function(a){if(a.result){return"contentdeleted"}e="error";return"contentnotdeleted"}).done(function(a){var b={contextid:d};if("success"==e){b.statusmsg=a}else{b.errormsg=a}window.location.href=f.relativeUrl("contentbank/index.php",b,!1)}).fail(c.exception)}function j(a,d){var e="success";b.call([{methodname:"core_contentbank_rename_content",args:{contentid:a,name:d}}])[0].then(function(a){if(a.result){return"contentrenamed"}e="error";return a.warnings[0].message}).then(function(b){var d=null;if("success"==e){d={id:a,statusmsg:b};window.location.href=f.relativeUrl("contentbank/view.php",d,!1)}else{c.addNotification({message:b,type:"error"});c.fetchNotifications()}}).catch(c.exception)}return{init:function init(){return new l}}});
|
||||
define ("core_contentbank/actions",["jquery","core/ajax","core/notification","core/str","core/templates","core/url","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f,g,h){var k={DELETE_CONTENT:"[data-action=\"deletecontent\"]",RENAME_CONTENT:"[data-action=\"renamecontent\"]"},l=function(){this.registerEvents()};l.prototype.registerEvents=function(){a(k.DELETE_CONTENT).click(function(b){b.preventDefault();var e=a(this).data("contentname"),f=a(this).data("uses"),j=a(this).data("contentid"),k=a(this).data("contextid"),l="";d.get_strings([{key:"deletecontent",component:"core_contentbank"},{key:"deletecontentconfirm",component:"core_contentbank",param:{name:e}},{key:"deletecontentconfirmlinked",component:"core_contentbank"},{key:"delete",component:"core"}]).then(function(a){var b=a[0],c=a[1];if(0<f){c+=" "+a[2]}l=a[3];return g.create({title:b,body:c,type:g.types.SAVE_CANCEL,large:!0})}).done(function(a){a.setSaveButtonText(l);a.getRoot().on(h.save,function(){return i(j,k)});a.getRoot().on(h.hidden,function(){a.destroy()});a.show()}).catch(c.exception)});a(k.RENAME_CONTENT).click(function(b){b.preventDefault();var f=a(this).data("contentname"),i=a(this).data("contentid"),k="";d.get_strings([{key:"renamecontent",component:"core_contentbank"},{key:"rename",component:"core_contentbank"}]).then(function(a){var b=a[0];k=a[1];return g.create({title:b,body:e.render("core_contentbank/renamecontent",{contentid:i,name:f}),type:g.types.SAVE_CANCEL})}).then(function(b){b.setSaveButtonText(k);b.getRoot().on(h.save,function(b){var e=a("#newname").val().trim();if(e){j(i,e)}else{d.get_strings([{key:"error"},{key:"emptynamenotallowed",component:"core_contentbank"}]).then(function(a){c.alert(a[0],a[1])}).catch(c.exception);b.preventDefault()}});b.getRoot().on(h.hidden,function(){b.destroy()});b.show()}).catch(c.exception)})};function i(a,d){var e="success";b.call([{methodname:"core_contentbank_delete_content",args:{contentids:{contentid:a}}}])[0].then(function(a){if(a.result){return"contentdeleted"}e="error";return"contentnotdeleted"}).done(function(a){var b={contextid:d};if("success"==e){b.statusmsg=a}else{b.errormsg=a}window.location.href=f.relativeUrl("contentbank/index.php",b,!1)}).fail(c.exception)}function j(a,d){var e="success";b.call([{methodname:"core_contentbank_rename_content",args:{contentid:a,name:d}}])[0].then(function(a){if(a.result){return"contentrenamed"}e="error";return a.warnings[0].message}).then(function(b){var d=null;if("success"==e){d={id:a,statusmsg:b};window.location.href=f.relativeUrl("contentbank/view.php",d,!1)}else{c.addNotification({message:b,type:"error"});c.fetchNotifications()}}).catch(c.exception)}return{init:function init(){return new l}}});
|
||||
//# sourceMappingURL=actions.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("core_contentbank/selectors",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;var b=function(a,b){return"[data-".concat(a,"=\"").concat(b,"\"]")},c={regions:{cbcontentname:b("region","cb-content-name"),contentbank:b("region","contentbank"),filearea:b("region","filearea")},actions:{search:b("action","searchcontent"),clearSearch:b("action","clearsearch"),viewgrid:b("action","viewgrid"),viewlist:b("action","viewlist"),sortname:b("action","sortname"),sortdate:b("action","sortdate"),sortsize:b("action","sortsize"),sorttype:b("action","sorttype"),sortauthor:b("action","sortauthor")},elements:{listitem:".cb-listitem",cbnavbarbreadcrumb:".cb-navbar-breadbrumb",cbnavbartotalsearch:".cb-navbar-totalsearch",searchinput:"#searchinput",sortbutton:".cb-btnsort"}};a.default=c;return a.default});
|
||||
define ("core_contentbank/selectors",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;var b=function(a,b){return"[data-".concat(a,"=\"").concat(b,"\"]")},c={regions:{cbcontentname:b("region","cb-content-name"),contentbank:b("region","contentbank"),filearea:b("region","filearea")},actions:{search:b("action","searchcontent"),clearSearch:b("action","clearsearch"),viewgrid:b("action","viewgrid"),viewlist:b("action","viewlist"),sortname:b("action","sortname"),sortuses:b("action","sortuses"),sortdate:b("action","sortdate"),sortsize:b("action","sortsize"),sorttype:b("action","sorttype"),sortauthor:b("action","sortauthor")},elements:{listitem:".cb-listitem",cbnavbarbreadcrumb:".cb-navbar-breadbrumb",cbnavbartotalsearch:".cb-navbar-totalsearch",searchinput:"#searchinput",sortbutton:".cb-btnsort"}};a.default=c;return a.default});
|
||||
//# sourceMappingURL=selectors.min.js.map
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../src/selectors.js"],"names":["getDataSelector","name","value","regions","cbcontentname","contentbank","filearea","actions","search","clearSearch","viewgrid","viewlist","sortname","sortdate","sortsize","sorttype","sortauthor","elements","listitem","cbnavbarbreadcrumb","cbnavbartotalsearch","searchinput","sortbutton"],"mappings":"+IAgCMA,CAAAA,CAAe,CAAG,SAACC,CAAD,CAAOC,CAAP,CAAiB,CACrC,sBAAgBD,CAAhB,eAAyBC,CAAzB,OACH,C,GAEc,CACXC,OAAO,CAAE,CACLC,aAAa,CAAEJ,CAAe,CAAC,QAAD,CAAW,iBAAX,CADzB,CAELK,WAAW,CAAEL,CAAe,CAAC,QAAD,CAAW,aAAX,CAFvB,CAGLM,QAAQ,CAAEN,CAAe,CAAC,QAAD,CAAW,UAAX,CAHpB,CADE,CAMXO,OAAO,CAAE,CACLC,MAAM,CAAER,CAAe,CAAC,QAAD,CAAW,eAAX,CADlB,CAELS,WAAW,CAAET,CAAe,CAAC,QAAD,CAAW,aAAX,CAFvB,CAGLU,QAAQ,CAAEV,CAAe,CAAC,QAAD,CAAW,UAAX,CAHpB,CAILW,QAAQ,CAAEX,CAAe,CAAC,QAAD,CAAW,UAAX,CAJpB,CAKLY,QAAQ,CAAEZ,CAAe,CAAC,QAAD,CAAW,UAAX,CALpB,CAMLa,QAAQ,CAAEb,CAAe,CAAC,QAAD,CAAW,UAAX,CANpB,CAOLc,QAAQ,CAAEd,CAAe,CAAC,QAAD,CAAW,UAAX,CAPpB,CAQLe,QAAQ,CAAEf,CAAe,CAAC,QAAD,CAAW,UAAX,CARpB,CASLgB,UAAU,CAAEhB,CAAe,CAAC,QAAD,CAAW,YAAX,CATtB,CANE,CAiBXiB,QAAQ,CAAE,CACNC,QAAQ,CAAE,cADJ,CAENC,kBAAkB,CAAE,uBAFd,CAGNC,mBAAmB,CAAE,wBAHf,CAINC,WAAW,CAAE,cAJP,CAKNC,UAAU,CAAE,aALN,CAjBC,C","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 <http://www.gnu.org/licenses/>.\n\n/**\n * Define all of the selectors we will be using on the contentbank interface.\n *\n * @module core_contentbank/selectors\n * @package core_contentbank\n * @copyright 2020 Sara Arjona <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * A small helper function to build queryable data selectors.\n *\n * @method getDataSelector\n * @param {String} name\n * @param {String} value\n * @return {string}\n */\nconst getDataSelector = (name, value) => {\n return `[data-${name}=\"${value}\"]`;\n};\n\nexport default {\n regions: {\n cbcontentname: getDataSelector('region', 'cb-content-name'),\n contentbank: getDataSelector('region', 'contentbank'),\n filearea: getDataSelector('region', 'filearea')\n },\n actions: {\n search: getDataSelector('action', 'searchcontent'),\n clearSearch: getDataSelector('action', 'clearsearch'),\n viewgrid: getDataSelector('action', 'viewgrid'),\n viewlist: getDataSelector('action', 'viewlist'),\n sortname: getDataSelector('action', 'sortname'),\n sortdate: getDataSelector('action', 'sortdate'),\n sortsize: getDataSelector('action', 'sortsize'),\n sorttype: getDataSelector('action', 'sorttype'),\n sortauthor: getDataSelector('action', 'sortauthor'),\n },\n elements: {\n listitem: '.cb-listitem',\n cbnavbarbreadcrumb: '.cb-navbar-breadbrumb',\n cbnavbartotalsearch: '.cb-navbar-totalsearch',\n searchinput: '#searchinput',\n sortbutton: '.cb-btnsort'\n },\n};\n"],"file":"selectors.min.js"}
|
||||
{"version":3,"sources":["../src/selectors.js"],"names":["getDataSelector","name","value","regions","cbcontentname","contentbank","filearea","actions","search","clearSearch","viewgrid","viewlist","sortname","sortuses","sortdate","sortsize","sorttype","sortauthor","elements","listitem","cbnavbarbreadcrumb","cbnavbartotalsearch","searchinput","sortbutton"],"mappings":"+IAgCMA,CAAAA,CAAe,CAAG,SAACC,CAAD,CAAOC,CAAP,CAAiB,CACrC,sBAAgBD,CAAhB,eAAyBC,CAAzB,OACH,C,GAEc,CACXC,OAAO,CAAE,CACLC,aAAa,CAAEJ,CAAe,CAAC,QAAD,CAAW,iBAAX,CADzB,CAELK,WAAW,CAAEL,CAAe,CAAC,QAAD,CAAW,aAAX,CAFvB,CAGLM,QAAQ,CAAEN,CAAe,CAAC,QAAD,CAAW,UAAX,CAHpB,CADE,CAMXO,OAAO,CAAE,CACLC,MAAM,CAAER,CAAe,CAAC,QAAD,CAAW,eAAX,CADlB,CAELS,WAAW,CAAET,CAAe,CAAC,QAAD,CAAW,aAAX,CAFvB,CAGLU,QAAQ,CAAEV,CAAe,CAAC,QAAD,CAAW,UAAX,CAHpB,CAILW,QAAQ,CAAEX,CAAe,CAAC,QAAD,CAAW,UAAX,CAJpB,CAKLY,QAAQ,CAAEZ,CAAe,CAAC,QAAD,CAAW,UAAX,CALpB,CAMLa,QAAQ,CAAEb,CAAe,CAAC,QAAD,CAAW,UAAX,CANpB,CAOLc,QAAQ,CAAEd,CAAe,CAAC,QAAD,CAAW,UAAX,CAPpB,CAQLe,QAAQ,CAAEf,CAAe,CAAC,QAAD,CAAW,UAAX,CARpB,CASLgB,QAAQ,CAAEhB,CAAe,CAAC,QAAD,CAAW,UAAX,CATpB,CAULiB,UAAU,CAAEjB,CAAe,CAAC,QAAD,CAAW,YAAX,CAVtB,CANE,CAkBXkB,QAAQ,CAAE,CACNC,QAAQ,CAAE,cADJ,CAENC,kBAAkB,CAAE,uBAFd,CAGNC,mBAAmB,CAAE,wBAHf,CAINC,WAAW,CAAE,cAJP,CAKNC,UAAU,CAAE,aALN,CAlBC,C","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 <http://www.gnu.org/licenses/>.\n\n/**\n * Define all of the selectors we will be using on the contentbank interface.\n *\n * @module core_contentbank/selectors\n * @package core_contentbank\n * @copyright 2020 Sara Arjona <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * A small helper function to build queryable data selectors.\n *\n * @method getDataSelector\n * @param {String} name\n * @param {String} value\n * @return {string}\n */\nconst getDataSelector = (name, value) => {\n return `[data-${name}=\"${value}\"]`;\n};\n\nexport default {\n regions: {\n cbcontentname: getDataSelector('region', 'cb-content-name'),\n contentbank: getDataSelector('region', 'contentbank'),\n filearea: getDataSelector('region', 'filearea')\n },\n actions: {\n search: getDataSelector('action', 'searchcontent'),\n clearSearch: getDataSelector('action', 'clearsearch'),\n viewgrid: getDataSelector('action', 'viewgrid'),\n viewlist: getDataSelector('action', 'viewlist'),\n sortname: getDataSelector('action', 'sortname'),\n sortuses: getDataSelector('action', 'sortuses'),\n sortdate: getDataSelector('action', 'sortdate'),\n sortsize: getDataSelector('action', 'sortsize'),\n sorttype: getDataSelector('action', 'sorttype'),\n sortauthor: getDataSelector('action', 'sortauthor'),\n },\n elements: {\n listitem: '.cb-listitem',\n cbnavbarbreadcrumb: '.cb-navbar-breadbrumb',\n cbnavbartotalsearch: '.cb-navbar-totalsearch',\n searchinput: '#searchinput',\n sortbutton: '.cb-btnsort'\n },\n};\n"],"file":"selectors.min.js"}
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("core_contentbank/sort",["exports","./selectors","core/str","core/prefetch","core/ajax","core/notification"],function(a,b,c,d,e,f){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=g(b);d=g(d);e=g(e);f=g(f);function g(a){return a&&a.__esModule?a:{default:a}}var h=function(){var a=document.querySelector(b.default.regions.contentbank);d.default.prefetchStrings("contentbank",["contentname","lastmodified","size","type","author"]);d.default.prefetchStrings("moodle",["sortbyx","sortbyxreverse"]);i(a)};a.init=h;var i=function(a){a.addEventListener("click",function(c){var d=a.querySelector(b.default.actions.viewlist),e=a.querySelector(b.default.actions.viewgrid);if(c.target.closest(b.default.actions.viewgrid)){a.classList.remove("view-list");a.classList.add("view-grid");e.classList.add("active");d.classList.remove("active");j(!1);return}if(c.target.closest(b.default.actions.viewlist)){a.classList.remove("view-grid");a.classList.add("view-list");d.classList.add("active");e.classList.remove("active");j(!0);return}var f=document.querySelector(b.default.regions.filearea),g=f.querySelectorAll(b.default.elements.listitem);if(f&&g){var h=c.target.closest(b.default.actions.sortname);if(h){var i=k(a,h);m(f,g,"data-file",i);return}var l=c.target.closest(b.default.actions.sortdate);if(l){var n=k(a,l);m(f,g,"data-timemodified",n);return}var o=c.target.closest(b.default.actions.sortsize);if(o){var p=k(a,o);m(f,g,"data-bytes",p);return}var q=c.target.closest(b.default.actions.sorttype);if(q){var r=k(a,q);m(f,g,"data-type",r);return}var s=c.target.closest(b.default.actions.sortauthor);if(s){var t=k(a,s);m(f,g,"data-author",t)}}})},j=function(a){if(!1===a){a=null}var b={methodname:"core_user_update_user_preferences",args:{preferences:[{type:"core_contentbank_view_list",value:a}]}};return e.default.call([b])[0].catch(f.default.exception)},k=function(a,c){var d=a.querySelectorAll(b.default.elements.sortbutton);d.forEach(function(a){if(a!==c){a.classList.remove("dir-asc");a.classList.remove("dir-desc");a.classList.add("dir-none");l(a,!1)}});var e=!0;if(c.classList.contains("dir-none")){c.classList.remove("dir-none");c.classList.add("dir-asc")}else if(c.classList.contains("dir-asc")){c.classList.remove("dir-asc");c.classList.add("dir-desc");e=!1}else if(c.classList.contains("dir-desc")){c.classList.remove("dir-desc");c.classList.add("dir-asc")}l(c,e);return e},l=function(a,b){var d=b?"sortbyxreverse":"sortbyx";return(0,c.get_string)(a.dataset.string,"contentbank").then(function(a){return(0,c.get_string)(d,"core",a)}).then(function(b){a.setAttribute("title",b);return b}).catch()},m=function(a,b,c,d){var e=[].slice.call(b).sort(function(e,a){var b=e.getAttribute(c),f=a.getAttribute(c);if(!isNaN(b)){b=parseInt(b);f=parseInt(f)}if(d){return b>f?1:-1}else{return b<f?1:-1}});e.forEach(function(b){return a.appendChild(b)})}});
|
||||
define ("core_contentbank/sort",["exports","./selectors","core/str","core/prefetch","core/ajax","core/notification"],function(a,b,c,d,e,f){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=g(b);d=g(d);e=g(e);f=g(f);function g(a){return a&&a.__esModule?a:{default:a}}var h=function(){var a=document.querySelector(b.default.regions.contentbank);d.default.prefetchStrings("contentbank",["contentname","uses","lastmodified","size","type","author"]);d.default.prefetchStrings("moodle",["sortbyx","sortbyxreverse"]);i(a)};a.init=h;var i=function(a){a.addEventListener("click",function(c){var d=a.querySelector(b.default.actions.viewlist),e=a.querySelector(b.default.actions.viewgrid);if(c.target.closest(b.default.actions.viewgrid)){a.classList.remove("view-list");a.classList.add("view-grid");e.classList.add("active");d.classList.remove("active");j(!1);return}if(c.target.closest(b.default.actions.viewlist)){a.classList.remove("view-grid");a.classList.add("view-list");d.classList.add("active");e.classList.remove("active");j(!0);return}var f=document.querySelector(b.default.regions.filearea),g=f.querySelectorAll(b.default.elements.listitem);if(f&&g){var h=c.target.closest(b.default.actions.sortname);if(h){var i=k(a,h);m(f,g,"data-file",i);return}var l=c.target.closest(b.default.actions.sortuses);if(l){var n=k(a,l);m(f,g,"data-uses",n);return}var o=c.target.closest(b.default.actions.sortdate);if(o){var p=k(a,o);m(f,g,"data-timemodified",p);return}var q=c.target.closest(b.default.actions.sortsize);if(q){var r=k(a,q);m(f,g,"data-bytes",r);return}var s=c.target.closest(b.default.actions.sorttype);if(s){var t=k(a,s);m(f,g,"data-type",t);return}var u=c.target.closest(b.default.actions.sortauthor);if(u){var v=k(a,u);m(f,g,"data-author",v)}}})},j=function(a){if(!1===a){a=null}var b={methodname:"core_user_update_user_preferences",args:{preferences:[{type:"core_contentbank_view_list",value:a}]}};return e.default.call([b])[0].catch(f.default.exception)},k=function(a,c){var d=a.querySelectorAll(b.default.elements.sortbutton);d.forEach(function(a){if(a!==c){a.classList.remove("dir-asc");a.classList.remove("dir-desc");a.classList.add("dir-none");l(a,!1)}});var e=!0;if(c.classList.contains("dir-none")){c.classList.remove("dir-none");c.classList.add("dir-asc")}else if(c.classList.contains("dir-asc")){c.classList.remove("dir-asc");c.classList.add("dir-desc");e=!1}else if(c.classList.contains("dir-desc")){c.classList.remove("dir-desc");c.classList.add("dir-asc")}l(c,e);return e},l=function(a,b){var d=b?"sortbyxreverse":"sortbyx";return(0,c.get_string)(a.dataset.string,"contentbank").then(function(a){return(0,c.get_string)(d,"core",a)}).then(function(b){a.setAttribute("title",b);return b}).catch()},m=function(a,b,c,d){var e=[].slice.call(b).sort(function(e,a){var b=e.getAttribute(c),f=a.getAttribute(c);if(!isNaN(b)){b=parseInt(b);f=parseInt(f)}if(d){return b>f?1:-1}else{return b<f?1:-1}});e.forEach(function(b){return a.appendChild(b)})}});
|
||||
//# sourceMappingURL=sort.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -57,6 +57,7 @@ function($, Ajax, Notification, Str, Templates, Url, ModalFactory, ModalEvents)
|
||||
e.preventDefault();
|
||||
|
||||
var contentname = $(this).data('contentname');
|
||||
var contentuses = $(this).data('uses');
|
||||
var contentid = $(this).data('contentid');
|
||||
var contextid = $(this).data('contextid');
|
||||
|
||||
@@ -72,6 +73,10 @@ function($, Ajax, Notification, Str, Templates, Url, ModalFactory, ModalEvents)
|
||||
name: contentname,
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'deletecontentconfirmlinked',
|
||||
component: 'core_contentbank',
|
||||
},
|
||||
{
|
||||
key: 'delete',
|
||||
component: 'core'
|
||||
@@ -82,7 +87,10 @@ function($, Ajax, Notification, Str, Templates, Url, ModalFactory, ModalEvents)
|
||||
Str.get_strings(strings).then(function(langStrings) {
|
||||
var modalTitle = langStrings[0];
|
||||
var modalContent = langStrings[1];
|
||||
deleteButtonText = langStrings[2];
|
||||
if (contentuses > 0) {
|
||||
modalContent += ' ' + langStrings[2];
|
||||
}
|
||||
deleteButtonText = langStrings[3];
|
||||
|
||||
return ModalFactory.create({
|
||||
title: modalTitle,
|
||||
|
||||
@@ -46,6 +46,7 @@ export default {
|
||||
viewgrid: getDataSelector('action', 'viewgrid'),
|
||||
viewlist: getDataSelector('action', 'viewlist'),
|
||||
sortname: getDataSelector('action', 'sortname'),
|
||||
sortuses: getDataSelector('action', 'sortuses'),
|
||||
sortdate: getDataSelector('action', 'sortdate'),
|
||||
sortsize: getDataSelector('action', 'sortsize'),
|
||||
sorttype: getDataSelector('action', 'sorttype'),
|
||||
|
||||
@@ -35,7 +35,7 @@ import Notification from 'core/notification';
|
||||
*/
|
||||
export const init = () => {
|
||||
const contentBank = document.querySelector(selectors.regions.contentbank);
|
||||
Prefetch.prefetchStrings('contentbank', ['contentname', 'lastmodified', 'size', 'type', 'author']);
|
||||
Prefetch.prefetchStrings('contentbank', ['contentname', 'uses', 'lastmodified', 'size', 'type', 'author']);
|
||||
Prefetch.prefetchStrings('moodle', ['sortbyx', 'sortbyxreverse']);
|
||||
registerListenerEvents(contentBank);
|
||||
};
|
||||
@@ -88,6 +88,14 @@ const registerListenerEvents = (contentBank) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Sort by uses.
|
||||
const sortByUses = e.target.closest(selectors.actions.sortuses);
|
||||
if (sortByUses) {
|
||||
const ascending = updateSortButtons(contentBank, sortByUses);
|
||||
updateSortOrder(fileArea, shownItems, 'data-uses', ascending);
|
||||
return;
|
||||
}
|
||||
|
||||
// Sort by date.
|
||||
const sortByDate = e.target.closest(selectors.actions.sortdate);
|
||||
if (sortByDate) {
|
||||
|
||||
@@ -310,6 +310,24 @@ abstract class content {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the places where the file associated to this content is used or an empty array if the content has no file.
|
||||
*
|
||||
* @return array of stored_file where current file content is used or empty array if it hasn't any file.
|
||||
* @since 3.11
|
||||
*/
|
||||
public function get_uses(): ?array {
|
||||
$references = [];
|
||||
|
||||
$file = $this->get_file();
|
||||
if ($file != null) {
|
||||
$fs = get_file_storage();
|
||||
$references = $fs->get_references_by_storedfile($file);
|
||||
}
|
||||
|
||||
return $references;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file url related to this content.
|
||||
*
|
||||
|
||||
@@ -92,6 +92,7 @@ class bankcontent implements renderable, templatable {
|
||||
'title' => strtolower($name),
|
||||
'link' => $contenttype->get_view_url($content),
|
||||
'icon' => $contenttype->get_icon($content),
|
||||
'uses' => count($content->get_uses()),
|
||||
'timemodified' => $content->get_timemodified(),
|
||||
'bytes' => $filesize,
|
||||
'size' => display_size($filesize),
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
"title": "resume",
|
||||
"timemodified": 1589792039,
|
||||
"size": "699.3KB",
|
||||
"uses": 3,
|
||||
"bytes": 716126,
|
||||
"type": "Archive (PDF)",
|
||||
"author": "Admin user",
|
||||
@@ -107,6 +108,15 @@ data-region="contentbank">
|
||||
<span class="asc">{{#pix}} t/sort_asc, core, {{#str}}asc, core{{/str}} {{/pix}}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="cb-uses cb-column d-flex">
|
||||
<div class="title">{{#str}} uses, contentbank {{/str}}</div>
|
||||
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="uses" data-action="sortuses"
|
||||
title="{{#str}} sortbyx, core, {{#str}} uses, contentbank {{/str}} {{/str}}">
|
||||
<span class="default">{{#pix}} t/sort, core, {{#str}}sort, core {{/str}} {{/pix}}</span>
|
||||
<span class="desc">{{#pix}} t/sort_desc, core, {{#str}}desc, core{{/str}} {{/pix}}</span>
|
||||
<span class="asc">{{#pix}} t/sort_asc, core, {{#str}}asc, core{{/str}} {{/pix}}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="cb-date cb-column d-flex">
|
||||
<div class="title">{{#str}} lastmodified, contentbank {{/str}}</div>
|
||||
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="lastmodified" data-action="sortdate"
|
||||
@@ -149,6 +159,7 @@ data-region="contentbank">
|
||||
data-file="{{ title }}"
|
||||
data-name="{{ name }}"
|
||||
data-bytes="{{ bytes }}"
|
||||
data-uses="{{ uses }}"
|
||||
data-timemodified="{{ timemodified }}"
|
||||
data-type="{{ type }}"
|
||||
data-author="{{ author }}">
|
||||
@@ -162,6 +173,9 @@ data-region="contentbank">
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="cb-uses cb-column small">
|
||||
{{ uses }}
|
||||
</div>
|
||||
<div class="cb-date cb-column small">
|
||||
{{#userdate}} {{ timemodified }}, {{#str}} strftimedatetimeshort, core_langconfig {{/str}} {{/userdate}}
|
||||
</div>
|
||||
|
||||
@@ -22,6 +22,7 @@ Feature: Delete H5P file from the content bank
|
||||
And I click on "Choose a file..." "button"
|
||||
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
|
||||
And I click on "filltheblanks.h5p" "link"
|
||||
And I set the field "Save as" to "content2delete.h5p"
|
||||
And I click on "Select this file" "button"
|
||||
And I click on "Save changes" "button"
|
||||
|
||||
@@ -29,15 +30,16 @@ Feature: Delete H5P file from the content bank
|
||||
Given I open the action menu in "region-main-settings-menu" "region"
|
||||
And I should see "Delete"
|
||||
When I choose "Delete" in the open action menu
|
||||
And I should see "Are you sure you want to delete the content 'filltheblanks.h5p'"
|
||||
And I should see "Are you sure you want to delete the content 'content2delete.h5p'"
|
||||
And I should not see "The content will only be deleted from the content bank"
|
||||
And I click on "Cancel" "button" in the "Delete content" "dialogue"
|
||||
Then I should see "filltheblanks.h5p"
|
||||
Then I should see "content2delete.h5p"
|
||||
And I open the action menu in "region-main-settings-menu" "region"
|
||||
And I choose "Delete" in the open action menu
|
||||
And I click on "Delete" "button" in the "Delete content" "dialogue"
|
||||
And I wait until the page is ready
|
||||
And I should see "The content has been deleted."
|
||||
And I should not see "filltheblanks.h5p"
|
||||
And I should not see "content2delete.h5p"
|
||||
|
||||
Scenario: Users without the required capability can only delete their own content
|
||||
Given the following "permission overrides" exist:
|
||||
@@ -56,8 +58,8 @@ Feature: Delete H5P file from the content bank
|
||||
And I click on "Save changes" "button"
|
||||
When I click on "Site pages" "list_item" in the "Navigation" "block"
|
||||
And I click on "Content bank" "link" in the "Navigation" "block"
|
||||
And I should see "filltheblanks.h5p"
|
||||
And I follow "filltheblanks.h5p"
|
||||
And I should see "content2delete.h5p"
|
||||
And I follow "content2delete.h5p"
|
||||
Then ".header-actions-container" "css_element" should not exist
|
||||
And I click on "Content bank" "link"
|
||||
And I click on "Upload" "link"
|
||||
@@ -68,3 +70,23 @@ Feature: Delete H5P file from the content bank
|
||||
And I click on "Save changes" "button"
|
||||
And I open the action menu in "region-main-settings-menu" "region"
|
||||
And I should see "Delete"
|
||||
|
||||
Scenario: The number of times a content is used is displayed before removing it
|
||||
Given I follow "Dashboard" in the user menu
|
||||
And I follow "Manage private files..."
|
||||
And I click on "Add..." "button"
|
||||
And I select "Content bank" repository in file picker
|
||||
And I click on "content2delete.h5p" "file" in repository content area
|
||||
And I click on "Link to the file" "radio"
|
||||
And I click on "Select this file" "button"
|
||||
And I click on "Save changes" "button"
|
||||
When I click on "Site pages" "list_item" in the "Navigation" "block"
|
||||
And I click on "Content bank" "link" in the "Navigation" "block"
|
||||
And I follow "content2delete.h5p"
|
||||
And I open the action menu in "region-main-settings-menu" "region"
|
||||
And I choose "Delete" in the open action menu
|
||||
Then I should see "Are you sure you want to delete the content 'content2delete.h5p'"
|
||||
And I should see "The content will only be deleted from the content bank"
|
||||
And I click on "Delete" "button" in the "Delete content" "dialogue"
|
||||
And I should see "The content has been deleted."
|
||||
And I should not see "content2delete.h5p"
|
||||
|
||||
@@ -1,28 +1,65 @@
|
||||
@core @core_contentbank @contentbank_h5p @javascript
|
||||
@core @core_contentbank @contentbank_h5p @_file_upload @javascript
|
||||
Feature: Store the content bank view preference
|
||||
In order to consistantly view the content bank in icons or details view
|
||||
As an admin
|
||||
I need to be able to store my view preference
|
||||
|
||||
Background:
|
||||
Given the following "contentbank content" exist:
|
||||
| contextlevel | reference | contenttype | user | contentname |
|
||||
| System | | contenttype_h5p | admin | filltheblanks.h5p |
|
||||
| System | | contenttype_h5p | admin | mathsbook.h5p |
|
||||
|
||||
Scenario: Admins can order content in the content bank
|
||||
Given I log in as "admin"
|
||||
And I follow "Manage private files..."
|
||||
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
|
||||
And I upload "h5p/tests/fixtures/greeting-card-887.h5p" file to "Files" filemanager
|
||||
And I click on "Save changes" "button"
|
||||
And I am on site homepage
|
||||
And I turn editing mode on
|
||||
And I add the "Navigation" block if not present
|
||||
And I configure the "Navigation" block
|
||||
And I set the following fields to these values:
|
||||
| Page contexts | Display throughout the entire site |
|
||||
And I press "Save changes"
|
||||
And I expand "Site pages" node
|
||||
And I click on "Content bank" "link"
|
||||
And I click on "Upload" "link"
|
||||
And I click on "Choose a file..." "button"
|
||||
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
|
||||
And I click on "filltheblanks.h5p" "link"
|
||||
And I set the field "Save as" to "fib.h5p"
|
||||
And I click on "Select this file" "button"
|
||||
And I click on "Save changes" "button"
|
||||
And I click on "Content bank" "link"
|
||||
And I click on "Upload" "link"
|
||||
And I click on "Choose a file..." "button"
|
||||
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
|
||||
And I click on "greeting-card-887.h5p" "link"
|
||||
And I set the field "Save as" to "greetingcard.h5p"
|
||||
And I click on "Select this file" "button"
|
||||
And I click on "Save changes" "button"
|
||||
|
||||
Scenario: There are several views for displaying contents into the content bank
|
||||
Given I am on site homepage
|
||||
And I click on "Content bank" "link"
|
||||
When I click on "Display content bank with file details" "button"
|
||||
And I should see "Last modified"
|
||||
And I follow "filltheblanks.h5p"
|
||||
Then I should see "Last modified"
|
||||
And I follow "greetingcard.h5p"
|
||||
And I click on "Content bank" "link"
|
||||
And I should see "Last modified"
|
||||
And I click on "Display content bank with icons" "button"
|
||||
And I follow "filltheblanks.h5p"
|
||||
And I follow "greetingcard.h5p"
|
||||
And I click on "Content bank" "link"
|
||||
And I should not see "Last modified"
|
||||
|
||||
Scenario: Display the number of times a content is used in file details view
|
||||
Given I follow "Dashboard" in the user menu
|
||||
And I follow "Manage private files..."
|
||||
And I click on "Add..." "button"
|
||||
And I select "Content bank" repository in file picker
|
||||
And I click on "fib.h5p" "file" in repository content area
|
||||
And I click on "Link to the file" "radio"
|
||||
And I click on "Select this file" "button"
|
||||
And I click on "Save changes" "button"
|
||||
When I am on site homepage
|
||||
And I expand "Site pages" node
|
||||
And I click on "Content bank" "link"
|
||||
And I click on "Display content bank with file details" "button"
|
||||
Then I should see "1" in the "[data-file='fib.h5p'] .cb-uses" "css_element"
|
||||
And I should see "0" in the "[data-file='greetingcard.h5p'] .cb-uses" "css_element"
|
||||
|
||||
@@ -298,4 +298,60 @@ class core_contenttype_content_testcase extends \advanced_testcase {
|
||||
|
||||
$this->assertInstanceOf(get_class($type), $contenttype);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for 'get_uses' behaviour.
|
||||
*
|
||||
* @covers ::get_uses
|
||||
*/
|
||||
public function test_get_uses() {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
$context = context_system::instance();
|
||||
|
||||
// Add some content to the content bank.
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_contentbank');
|
||||
$contents = $generator->generate_contentbank_data('contenttype_testable', 3, 0, $context);
|
||||
$content1 = array_shift($contents);
|
||||
|
||||
// Check content has no references for now.
|
||||
$this->assertCount(0, $content1->get_uses());
|
||||
|
||||
// Add a link to the previous content.
|
||||
$cbfile = $content1->get_file();
|
||||
$cbrecord = array(
|
||||
'contextid' => $cbfile->get_contextid(),
|
||||
'component' => $cbfile->get_component(),
|
||||
'filearea' => $cbfile->get_filearea(),
|
||||
'itemid' => $cbfile->get_itemid(),
|
||||
'filepath' => $cbfile->get_filepath(),
|
||||
'filename' => $cbfile->get_filename(),
|
||||
);
|
||||
$fs = get_file_storage();
|
||||
$ref = $fs->pack_reference($cbrecord);
|
||||
|
||||
$aliasrecord = new stdClass();
|
||||
$aliasrecord->contextid = $context->id;
|
||||
$aliasrecord->component = 'core';
|
||||
$aliasrecord->filearea = 'phpunit';
|
||||
$aliasrecord->filepath = '/foo/';
|
||||
$aliasrecord->filename = 'one.txt';
|
||||
$aliasrecord->itemid = 0;
|
||||
|
||||
$repos = \repository::get_instances(['type' => 'contentbank']);
|
||||
$cbrepo = reset($repos);
|
||||
$this->assertInstanceOf('repository', $cbrepo);
|
||||
|
||||
$alias = $fs->create_file_from_reference($aliasrecord, $cbrepo->id, $ref);
|
||||
|
||||
// Check content now has one reference (the previous alias).
|
||||
$contentuses1 = $content1->get_uses();
|
||||
$this->assertCount(1, $contentuses1);
|
||||
$reffile = reset($contentuses1);
|
||||
$this->assertEquals($alias, $reffile);
|
||||
|
||||
// Check a different content hasn't any reference.
|
||||
$content2 = array_shift($contents);
|
||||
$this->assertCount(0, $content2->get_uses());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
This files describes API changes in core libraries and APIs,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 3.11 ===
|
||||
* Added "get_uses()" method to content class to return places where a content is used.
|
||||
@@ -103,6 +103,7 @@ if ($contenttype->can_delete($content)) {
|
||||
$attributes = [
|
||||
'data-action' => 'deletecontent',
|
||||
'data-contentname' => $content->get_name(),
|
||||
'data-uses' => count($content->get_uses()),
|
||||
'data-contentid' => $content->get_id(),
|
||||
'data-contextid' => $context->id,
|
||||
];
|
||||
|
||||
@@ -45,6 +45,7 @@ $string['errordeletingcontentfromcategory'] = 'Error deleting content from categ
|
||||
$string['errornofile'] = 'A compatible file is needed to create content.';
|
||||
$string['deletecontent'] = 'Delete content';
|
||||
$string['deletecontentconfirm'] = 'Are you sure you want to delete the content <em>\'{$a->name}\'</em> and all associated files? This action cannot be undone.';
|
||||
$string['deletecontentconfirmlinked'] = 'The content will only be deleted from the content bank. Any places which currently link to it will be automatically updated to use a copy of the content instead.';
|
||||
$string['displaydetails'] = 'Display content bank with file details';
|
||||
$string['displayicons'] = 'Display content bank with icons';
|
||||
$string['file'] = 'Upload content';
|
||||
@@ -74,3 +75,4 @@ $string['timecreated'] = 'Time created';
|
||||
$string['type'] = 'Type';
|
||||
$string['unsupported'] = 'This content type is not supported.';
|
||||
$string['upload'] = 'Upload';
|
||||
$string['uses'] = 'Places linked';
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
.cb-heading,
|
||||
.cb-uses,
|
||||
.cb-date,
|
||||
.cb-size,
|
||||
.cb-type,
|
||||
@@ -99,12 +100,13 @@
|
||||
flex: 0 0 40%;
|
||||
max-width: 40%;
|
||||
}
|
||||
.cb-uses,
|
||||
.cb-date,
|
||||
.cb-size,
|
||||
.cb-type,
|
||||
.cb-author {
|
||||
flex: 0 0 15%;
|
||||
max-width: 15%;
|
||||
flex: 0 0 12%;
|
||||
max-width: 12%;
|
||||
}
|
||||
.cb-column.last {
|
||||
border-right: 0;
|
||||
|
||||
@@ -13135,6 +13135,7 @@ table.calendartable caption {
|
||||
margin-bottom: 0.5rem; }
|
||||
|
||||
.content-bank-container.view-grid .cb-heading,
|
||||
.content-bank-container.view-grid .cb-uses,
|
||||
.content-bank-container.view-grid .cb-date,
|
||||
.content-bank-container.view-grid .cb-size,
|
||||
.content-bank-container.view-grid .cb-type,
|
||||
@@ -13176,12 +13177,13 @@ table.calendartable caption {
|
||||
.content-bank-container.view-list .cb-file {
|
||||
flex: 0 0 40%;
|
||||
max-width: 40%; }
|
||||
.content-bank-container.view-list .cb-uses,
|
||||
.content-bank-container.view-list .cb-date,
|
||||
.content-bank-container.view-list .cb-size,
|
||||
.content-bank-container.view-list .cb-type,
|
||||
.content-bank-container.view-list .cb-author {
|
||||
flex: 0 0 15%;
|
||||
max-width: 15%; }
|
||||
flex: 0 0 12%;
|
||||
max-width: 12%; }
|
||||
.content-bank-container.view-list .cb-column.last {
|
||||
border-right: 0; } }
|
||||
|
||||
|
||||
@@ -13349,6 +13349,7 @@ table.calendartable caption {
|
||||
margin-bottom: 0.5rem; }
|
||||
|
||||
.content-bank-container.view-grid .cb-heading,
|
||||
.content-bank-container.view-grid .cb-uses,
|
||||
.content-bank-container.view-grid .cb-date,
|
||||
.content-bank-container.view-grid .cb-size,
|
||||
.content-bank-container.view-grid .cb-type,
|
||||
@@ -13390,12 +13391,13 @@ table.calendartable caption {
|
||||
.content-bank-container.view-list .cb-file {
|
||||
flex: 0 0 40%;
|
||||
max-width: 40%; }
|
||||
.content-bank-container.view-list .cb-uses,
|
||||
.content-bank-container.view-list .cb-date,
|
||||
.content-bank-container.view-list .cb-size,
|
||||
.content-bank-container.view-list .cb-type,
|
||||
.content-bank-container.view-list .cb-author {
|
||||
flex: 0 0 15%;
|
||||
max-width: 15%; }
|
||||
flex: 0 0 12%;
|
||||
max-width: 12%; }
|
||||
.content-bank-container.view-list .cb-column.last {
|
||||
border-right: 0; } }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user