Merge branch 'MDL-68688-310' of git://github.com/aanabit/moodle into MOODLE_310_STABLE

This commit is contained in:
Sara Arjona 2020-09-16 17:03:27 +02:00
commit bf127517b3
5 changed files with 152 additions and 127 deletions

View file

@ -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){var c=document.querySelector(b.default.regions.filearea),d=c.querySelectorAll(b.default.elements.listitem),e=a.querySelector(b.default.actions.viewgrid),f=a.querySelector(b.default.actions.viewlist);e.addEventListener("click",function(){a.classList.remove("view-list");a.classList.add("view-grid");e.classList.add("active");f.classList.remove("active");j(!1)});f.addEventListener("click",function(){a.classList.remove("view-grid");a.classList.add("view-list");f.classList.add("active");e.classList.remove("active");j(!0)});var g=a.querySelector(b.default.actions.sortname);g.addEventListener("click",function(){var b=k(a,g);m(c,d,"data-file",b)});var h=a.querySelector(b.default.actions.sortdate);h.addEventListener("click",function(){var b=k(a,h);m(c,d,"data-timemodified",b)});var i=a.querySelector(b.default.actions.sortsize);i.addEventListener("click",function(){var b=k(a,i);m(c,d,"data-bytes",b)});var l=a.querySelector(b.default.actions.sorttype);l.addEventListener("click",function(){var b=k(a,l);m(c,d,"data-type",b)});var n=a.querySelector(b.default.actions.sortauthor);n.addEventListener("click",function(){var b=k(a,n);m(c,d,"data-author",b)})},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","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)})}});
//# sourceMappingURL=sort.min.js.map //# sourceMappingURL=sort.min.js.map

File diff suppressed because one or more lines are too long

View file

@ -48,63 +48,78 @@ export const init = () => {
*/ */
const registerListenerEvents = (contentBank) => { const registerListenerEvents = (contentBank) => {
// The search. contentBank.addEventListener('click', e => {
const fileArea = document.querySelector(selectors.regions.filearea); const viewList = contentBank.querySelector(selectors.actions.viewlist);
const shownItems = fileArea.querySelectorAll(selectors.elements.listitem); const viewGrid = contentBank.querySelector(selectors.actions.viewgrid);
// The view buttons. // View as Grid button.
const viewGrid = contentBank.querySelector(selectors.actions.viewgrid); if (e.target.closest(selectors.actions.viewgrid)) {
const viewList = contentBank.querySelector(selectors.actions.viewlist); contentBank.classList.remove('view-list');
contentBank.classList.add('view-grid');
viewGrid.classList.add('active');
viewList.classList.remove('active');
setViewListPreference(false);
viewGrid.addEventListener('click', () => { return;
contentBank.classList.remove('view-list'); }
contentBank.classList.add('view-grid');
viewGrid.classList.add('active');
viewList.classList.remove('active');
setViewListPreference(false);
});
viewList.addEventListener('click', () => { // View as List button.
contentBank.classList.remove('view-grid'); if (e.target.closest(selectors.actions.viewlist)) {
contentBank.classList.add('view-list'); contentBank.classList.remove('view-grid');
viewList.classList.add('active'); contentBank.classList.add('view-list');
viewGrid.classList.remove('active'); viewList.classList.add('active');
setViewListPreference(true); viewGrid.classList.remove('active');
}); setViewListPreference(true);
// Sort by file name alphabetical return;
const sortByName = contentBank.querySelector(selectors.actions.sortname); }
sortByName.addEventListener('click', () => {
const ascending = updateSortButtons(contentBank, sortByName);
updateSortOrder(fileArea, shownItems, 'data-file', ascending);
});
// Sort by date. // TODO: This should _not_ use `document`. Every query should be constrained to the content bank container.
const sortByDate = contentBank.querySelector(selectors.actions.sortdate); const fileArea = document.querySelector(selectors.regions.filearea);
sortByDate.addEventListener('click', () => { const shownItems = fileArea.querySelectorAll(selectors.elements.listitem);
const ascending = updateSortButtons(contentBank, sortByDate);
updateSortOrder(fileArea, shownItems, 'data-timemodified', ascending);
});
// Sort by size. if (fileArea && shownItems) {
const sortBySize = contentBank.querySelector(selectors.actions.sortsize);
sortBySize.addEventListener('click', () => {
const ascending = updateSortButtons(contentBank, sortBySize);
updateSortOrder(fileArea, shownItems, 'data-bytes', ascending);
});
// Sort by type. // Sort by file name alphabetical
const sortByType = contentBank.querySelector(selectors.actions.sorttype); const sortByName = e.target.closest(selectors.actions.sortname);
sortByType.addEventListener('click', () => { if (sortByName) {
const ascending = updateSortButtons(contentBank, sortByType); const ascending = updateSortButtons(contentBank, sortByName);
updateSortOrder(fileArea, shownItems, 'data-type', ascending); updateSortOrder(fileArea, shownItems, 'data-file', ascending);
}); return;
}
// Sort by author. // Sort by date.
const sortByAuthor = contentBank.querySelector(selectors.actions.sortauthor); const sortByDate = e.target.closest(selectors.actions.sortdate);
sortByAuthor.addEventListener('click', () => { if (sortByDate) {
const ascending = updateSortButtons(contentBank, sortByAuthor); const ascending = updateSortButtons(contentBank, sortByDate);
updateSortOrder(fileArea, shownItems, 'data-author', ascending); updateSortOrder(fileArea, shownItems, 'data-timemodified', ascending);
return;
}
// Sort by size.
const sortBySize = e.target.closest(selectors.actions.sortsize);
if (sortBySize) {
const ascending = updateSortButtons(contentBank, sortBySize);
updateSortOrder(fileArea, shownItems, 'data-bytes', ascending);
return;
}
// Sort by type.
const sortByType = e.target.closest(selectors.actions.sorttype);
if (sortByType) {
const ascending = updateSortButtons(contentBank, sortByType);
updateSortOrder(fileArea, shownItems, 'data-type', ascending);
return;
}
// Sort by author.
const sortByAuthor = e.target.closest(selectors.actions.sortauthor);
if (sortByAuthor) {
const ascending = updateSortButtons(contentBank, sortByAuthor);
updateSortOrder(fileArea, shownItems, 'data-author', ascending);
}
return;
}
}); });
}; };

View file

@ -95,87 +95,96 @@ data-region="contentbank">
<div class="cb-navbar-totalsearch d-none"> <div class="cb-navbar-totalsearch d-none">
</div> </div>
</div> </div>
<div class="cb-content-wrapper d-flex px-2" data-region="filearea"> {{#contents.0}}
<div class="cb-heading bg-white"> <div class="cb-content-wrapper d-flex px-2" data-region="filearea">
<div class="cb-file cb-column d-flex"> <div class="cb-heading bg-white">
<div class="title">{{#str}} contentname, contentbank {{/str}}</div> <div class="cb-file cb-column d-flex">
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="contentname" data-action="sortname" <div class="title">{{#str}} contentname, contentbank {{/str}}</div>
title="{{#str}} sortbyx, core, {{#str}} contentname, contentbank {{/str}} {{/str}}"> <button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="contentname" data-action="sortname"
<span class="default">{{#pix}} t/sort, core, {{#str}}sort, core {{/str}} {{/pix}}</span> title="{{#str}} sortbyx, core, {{#str}} contentname, contentbank {{/str}} {{/str}}">
<span class="desc">{{#pix}} t/sort_desc, core, {{#str}}desc, core{{/str}} {{/pix}}</span> <span class="default">{{#pix}} t/sort, core, {{#str}}sort, core {{/str}} {{/pix}}</span>
<span class="asc">{{#pix}} t/sort_asc, core, {{#str}}asc, core{{/str}} {{/pix}}</span> <span class="desc">{{#pix}} t/sort_desc, core, {{#str}}desc, core{{/str}} {{/pix}}</span>
</button> <span class="asc">{{#pix}} t/sort_asc, core, {{#str}}asc, core{{/str}} {{/pix}}</span>
</div> </button>
<div class="cb-date cb-column d-flex"> </div>
<div class="title">{{#str}} lastmodified, contentbank {{/str}}</div> <div class="cb-date cb-column d-flex">
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="lastmodified" data-action="sortdate" <div class="title">{{#str}} lastmodified, contentbank {{/str}}</div>
title="{{#str}} sortbyx, core, {{#str}} lastmodified, contentbank {{/str}} {{/str}}"> <button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="lastmodified" data-action="sortdate"
<span class="default">{{#pix}} t/sort, core, {{#str}}sort, core {{/str}} {{/pix}}</span> title="{{#str}} sortbyx, core, {{#str}} lastmodified, contentbank {{/str}} {{/str}}">
<span class="desc">{{#pix}} t/sort_desc, core, {{#str}}desc, core{{/str}} {{/pix}}</span> <span class="default">{{#pix}} t/sort, core, {{#str}}sort, core {{/str}} {{/pix}}</span>
<span class="asc">{{#pix}} t/sort_asc, core, {{#str}}asc, core{{/str}} {{/pix}}</span> <span class="desc">{{#pix}} t/sort_desc, core, {{#str}}desc, core{{/str}} {{/pix}}</span>
</button> <span class="asc">{{#pix}} t/sort_asc, core, {{#str}}asc, core{{/str}} {{/pix}}</span>
</div> </button>
<div class="cb-size cb-column d-flex"> </div>
<div class="title">{{#str}} size, contentbank {{/str}}</div> <div class="cb-size cb-column d-flex">
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="size" data-action="sortsize" <div class="title">{{#str}} size, contentbank {{/str}}</div>
title="{{#str}} sortbyx, core, {{#str}} size, contentbank {{/str}} {{/str}}"> <button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="size" data-action="sortsize"
<span class="default">{{#pix}} t/sort, core, {{#str}}sort, core {{/str}} {{/pix}}</span> title="{{#str}} sortbyx, core, {{#str}} size, contentbank {{/str}} {{/str}}">
<span class="desc">{{#pix}} t/sort_desc, core, {{#str}}desc, core{{/str}} {{/pix}}</span> <span class="default">{{#pix}} t/sort, core, {{#str}}sort, core {{/str}} {{/pix}}</span>
<span class="asc">{{#pix}} t/sort_asc, core, {{#str}}asc, core{{/str}} {{/pix}}</span> <span class="desc">{{#pix}} t/sort_desc, core, {{#str}}desc, core{{/str}} {{/pix}}</span>
</button> <span class="asc">{{#pix}} t/sort_asc, core, {{#str}}asc, core{{/str}} {{/pix}}</span>
</div> </button>
<div class="cb-type cb-column d-flex"> </div>
<div class="title">{{#str}} type, contentbank {{/str}}</div> <div class="cb-type cb-column d-flex">
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="type" data-action="sorttype" <div class="title">{{#str}} type, contentbank {{/str}}</div>
title="{{#str}} sortbyx, core, {{#str}} type, contentbank {{/str}} {{/str}}"> <button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="type" data-action="sorttype"
<span class="default">{{#pix}} t/sort, core, {{#str}}sort, core {{/str}} {{/pix}}</span> title="{{#str}} sortbyx, core, {{#str}} type, contentbank {{/str}} {{/str}}">
<span class="desc">{{#pix}} t/sort_desc, core, {{#str}}desc, core{{/str}} {{/pix}}</span> <span class="default">{{#pix}} t/sort, core, {{#str}}sort, core {{/str}} {{/pix}}</span>
<span class="asc">{{#pix}} t/sort_asc, core, {{#str}}asc, core{{/str}} {{/pix}}</span> <span class="desc">{{#pix}} t/sort_desc, core, {{#str}}desc, core{{/str}} {{/pix}}</span>
</button> <span class="asc">{{#pix}} t/sort_asc, core, {{#str}}asc, core{{/str}} {{/pix}}</span>
</div> </button>
<div class="cb-author cb-column d-flex last"> </div>
<div class="title">{{#str}} author, contentbank {{/str}}</div> <div class="cb-author cb-column d-flex last">
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="author" data-action="sortauthor" <div class="title">{{#str}} author, contentbank {{/str}}</div>
title="{{#str}} sortbyx, core, {{#str}} author, contentbank {{/str}} {{/str}}"> <button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="author" data-action="sortauthor"
<span class="default">{{#pix}} t/sort, core, {{#str}}sort, core {{/str}} {{/pix}}</span> title="{{#str}} sortbyx, core, {{#str}} author, contentbank {{/str}} {{/str}}">
<span class="desc">{{#pix}} t/sort_desc, core, {{#str}}desc, core{{/str}} {{/pix}}</span> <span class="default">{{#pix}} t/sort, core, {{#str}}sort, core {{/str}} {{/pix}}</span>
<span class="asc">{{#pix}} t/sort_asc, core, {{#str}}asc, core{{/str}} {{/pix}}</span> <span class="desc">{{#pix}} t/sort_desc, core, {{#str}}desc, core{{/str}} {{/pix}}</span>
</button> <span class="asc">{{#pix}} t/sort_asc, core, {{#str}}asc, core{{/str}} {{/pix}}</span>
</div> </button>
</div>
{{#contents}}
<div class="cb-listitem"
data-file="{{{ title }}}"
data-name="{{{ name }}}"
data-bytes="{{ bytes }}"
data-timemodified="{{ timemodified }}"
data-type="{{{ type }}}"
data-author="{{{ author }}}">
<div class="cb-file cb-column position-relative">
<div class="cb-thumbnail" role="img" aria-label="{{{ name }}}"
style="background-image: url('{{{ icon }}}');">
</div> </div>
<a href="{{{ link }}}" class="cb-link stretched-link" title="{{{ name }}}">
<span class="cb-name word-break-all clamp-2" data-region="cb-content-name">
{{{ name }}}
</span>
</a>
</div> </div>
<div class="cb-date cb-column small"> {{#contents}}
{{#userdate}} {{ timemodified }}, {{#str}} strftimedatetimeshort, core_langconfig {{/str}} {{/userdate}} <div class="cb-listitem"
data-file="{{{ title }}}"
data-name="{{{ name }}}"
data-bytes="{{ bytes }}"
data-timemodified="{{ timemodified }}"
data-type="{{{ type }}}"
data-author="{{{ author }}}">
<div class="cb-file cb-column position-relative">
<div class="cb-thumbnail" role="img" aria-label="{{{ name }}}"
style="background-image: url('{{{ icon }}}');">
</div>
<a href="{{{ link }}}" class="cb-link stretched-link" title="{{{ name }}}">
<span class="cb-name word-break-all clamp-2" data-region="cb-content-name">
{{{ name }}}
</span>
</a>
</div>
<div class="cb-date cb-column small">
{{#userdate}} {{ timemodified }}, {{#str}} strftimedatetimeshort, core_langconfig {{/str}} {{/userdate}}
</div>
<div class="cb-size cb-column small">
{{ size }}
</div>
<div class="cb-type cb-column small">
{{{ type }}}
</div>
<div class="cb-type cb-column last small">
{{{ author }}}
</div>
</div> </div>
<div class="cb-size cb-column small"> {{/contents}}
{{ size }} </div>
</div> {{/contents.0}}
<div class="cb-type cb-column small"> {{^contents.0}}
{{{ type }}} <div class="cb-content-wrapper d-flex flex-wrap p-2" data-region="filearea">
</div> <div class="w-100 p-3 text-center text-muted">
<div class="cb-type cb-column last small"> {{#str}} nocontentavailable, core_contentbank {{/str}}
{{{ author }}}
</div> </div>
</div> </div>
{{/contents}} {{/contents.0}}
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -51,6 +51,7 @@ $string['file_help'] = 'Files may be stored in the content bank for use in cours
$string['itemsfound'] = '{$a} items found'; $string['itemsfound'] = '{$a} items found';
$string['lastmodified'] = 'Last modified'; $string['lastmodified'] = 'Last modified';
$string['name'] = 'Content'; $string['name'] = 'Content';
$string['nocontentavailable'] = 'No content available';
$string['nocontenttypes'] = 'No content types available'; $string['nocontenttypes'] = 'No content types available';
$string['nopermissiontodelete'] = 'You do not have permission to delete content.'; $string['nopermissiontodelete'] = 'You do not have permission to delete content.';
$string['nopermissiontomanage'] = 'You do not have permission to manage content.'; $string['nopermissiontomanage'] = 'You do not have permission to manage content.';