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

File diff suppressed because one or more lines are too long

View file

@ -48,63 +48,78 @@ export const init = () => {
*/
const registerListenerEvents = (contentBank) => {
// The search.
const fileArea = document.querySelector(selectors.regions.filearea);
const shownItems = fileArea.querySelectorAll(selectors.elements.listitem);
contentBank.addEventListener('click', e => {
const viewList = contentBank.querySelector(selectors.actions.viewlist);
const viewGrid = contentBank.querySelector(selectors.actions.viewgrid);
// The view buttons.
const viewGrid = contentBank.querySelector(selectors.actions.viewgrid);
const viewList = contentBank.querySelector(selectors.actions.viewlist);
// View as Grid button.
if (e.target.closest(selectors.actions.viewgrid)) {
contentBank.classList.remove('view-list');
contentBank.classList.add('view-grid');
viewGrid.classList.add('active');
viewList.classList.remove('active');
setViewListPreference(false);
viewGrid.addEventListener('click', () => {
contentBank.classList.remove('view-list');
contentBank.classList.add('view-grid');
viewGrid.classList.add('active');
viewList.classList.remove('active');
setViewListPreference(false);
});
return;
}
viewList.addEventListener('click', () => {
contentBank.classList.remove('view-grid');
contentBank.classList.add('view-list');
viewList.classList.add('active');
viewGrid.classList.remove('active');
setViewListPreference(true);
});
// View as List button.
if (e.target.closest(selectors.actions.viewlist)) {
contentBank.classList.remove('view-grid');
contentBank.classList.add('view-list');
viewList.classList.add('active');
viewGrid.classList.remove('active');
setViewListPreference(true);
// Sort by file name alphabetical
const sortByName = contentBank.querySelector(selectors.actions.sortname);
sortByName.addEventListener('click', () => {
const ascending = updateSortButtons(contentBank, sortByName);
updateSortOrder(fileArea, shownItems, 'data-file', ascending);
});
return;
}
// Sort by date.
const sortByDate = contentBank.querySelector(selectors.actions.sortdate);
sortByDate.addEventListener('click', () => {
const ascending = updateSortButtons(contentBank, sortByDate);
updateSortOrder(fileArea, shownItems, 'data-timemodified', ascending);
});
// TODO: This should _not_ use `document`. Every query should be constrained to the content bank container.
const fileArea = document.querySelector(selectors.regions.filearea);
const shownItems = fileArea.querySelectorAll(selectors.elements.listitem);
// Sort by size.
const sortBySize = contentBank.querySelector(selectors.actions.sortsize);
sortBySize.addEventListener('click', () => {
const ascending = updateSortButtons(contentBank, sortBySize);
updateSortOrder(fileArea, shownItems, 'data-bytes', ascending);
});
if (fileArea && shownItems) {
// Sort by type.
const sortByType = contentBank.querySelector(selectors.actions.sorttype);
sortByType.addEventListener('click', () => {
const ascending = updateSortButtons(contentBank, sortByType);
updateSortOrder(fileArea, shownItems, 'data-type', ascending);
});
// Sort by file name alphabetical
const sortByName = e.target.closest(selectors.actions.sortname);
if (sortByName) {
const ascending = updateSortButtons(contentBank, sortByName);
updateSortOrder(fileArea, shownItems, 'data-file', ascending);
return;
}
// Sort by author.
const sortByAuthor = contentBank.querySelector(selectors.actions.sortauthor);
sortByAuthor.addEventListener('click', () => {
const ascending = updateSortButtons(contentBank, sortByAuthor);
updateSortOrder(fileArea, shownItems, 'data-author', ascending);
// Sort by date.
const sortByDate = e.target.closest(selectors.actions.sortdate);
if (sortByDate) {
const ascending = updateSortButtons(contentBank, sortByDate);
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>
</div>
<div class="cb-content-wrapper d-flex px-2" data-region="filearea">
<div class="cb-heading bg-white">
<div class="cb-file cb-column d-flex">
<div class="title">{{#str}} contentname, contentbank {{/str}}</div>
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="contentname" data-action="sortname"
title="{{#str}} sortbyx, core, {{#str}} contentname, 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"
title="{{#str}} sortbyx, core, {{#str}} lastmodified, 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-size cb-column d-flex">
<div class="title">{{#str}} size, contentbank {{/str}}</div>
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="size" data-action="sortsize"
title="{{#str}} sortbyx, core, {{#str}} size, 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-type cb-column d-flex">
<div class="title">{{#str}} type, contentbank {{/str}}</div>
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="type" data-action="sorttype"
title="{{#str}} sortbyx, core, {{#str}} type, 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-author cb-column d-flex last">
<div class="title">{{#str}} author, contentbank {{/str}}</div>
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="author" data-action="sortauthor"
title="{{#str}} sortbyx, core, {{#str}} author, 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>
{{#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 }}}');">
{{#contents.0}}
<div class="cb-content-wrapper d-flex px-2" data-region="filearea">
<div class="cb-heading bg-white">
<div class="cb-file cb-column d-flex">
<div class="title">{{#str}} contentname, contentbank {{/str}}</div>
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="contentname" data-action="sortname"
title="{{#str}} sortbyx, core, {{#str}} contentname, 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"
title="{{#str}} sortbyx, core, {{#str}} lastmodified, 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-size cb-column d-flex">
<div class="title">{{#str}} size, contentbank {{/str}}</div>
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="size" data-action="sortsize"
title="{{#str}} sortbyx, core, {{#str}} size, 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-type cb-column d-flex">
<div class="title">{{#str}} type, contentbank {{/str}}</div>
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="type" data-action="sorttype"
title="{{#str}} sortbyx, core, {{#str}} type, 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-author cb-column d-flex last">
<div class="title">{{#str}} author, contentbank {{/str}}</div>
<button class="btn btn-sm cb-btnsort dir-none ml-auto" data-string="author" data-action="sortauthor"
title="{{#str}} sortbyx, core, {{#str}} author, 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>
<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}}
{{#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>
<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 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 }}}
{{/contents}}
</div>
{{/contents.0}}
{{^contents.0}}
<div class="cb-content-wrapper d-flex flex-wrap p-2" data-region="filearea">
<div class="w-100 p-3 text-center text-muted">
{{#str}} nocontentavailable, core_contentbank {{/str}}
</div>
</div>
{{/contents}}
</div>
{{/contents.0}}
</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['lastmodified'] = 'Last modified';
$string['name'] = 'Content';
$string['nocontentavailable'] = 'No content available';
$string['nocontenttypes'] = 'No content types available';
$string['nopermissiontodelete'] = 'You do not have permission to delete content.';
$string['nopermissiontomanage'] = 'You do not have permission to manage content.';