Merge branch 'MDL-72650-master' of https://github.com/HuongNV13/moodle

This commit is contained in:
Jun Pataleta 2021-12-22 09:21:51 +08:00
commit b180acb3f2
27 changed files with 77 additions and 104 deletions

View File

@ -1,2 +1,2 @@
define ("block_myoverview/selectors",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;a.default={courseView:{region:"[data-region=\"courses-view\"]",regionContent:"[data-region=\"course-view-content\"]"},FILTERS:"[data-region=\"filter\"]",FILTER_OPTION:"[data-filter]",DISPLAY_OPTION:"[data-display-option]",ACTION_HIDE_COURSE:"[data-action=\"hide-course\"]",ACTION_SHOW_COURSE:"[data-action=\"show-course\"]",ACTION_ADD_FAVOURITE:"[data-action=\"add-favourite\"]",ACTION_REMOVE_FAVOURITE:"[data-action=\"remove-favourite\"]",FAVOURITE_ICON:"[data-region=\"favourite-icon\"]",ICON_IS_FAVOURITE:"[data-region=\"is-favourite\"]",ICON_NOT_FAVOURITE:"[data-region=\"not-favourite\"]",region:{selectBlock:"[data-region=\"myoverview\"]",clearIcon:"[data-region=\"clear-icon\"]",searchIcon:"[data-region=\"search-icon\"]",searchInput:"[data-region=\"search-input\"]"}};return a.default});
define ("block_myoverview/selectors",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;a.default={courseView:{region:"[data-region=\"courses-view\"]",regionContent:"[data-region=\"course-view-content\"]"},FILTERS:"[data-region=\"filter\"]",FILTER_OPTION:"[data-filter]",DISPLAY_OPTION:"[data-display-option]",ACTION_HIDE_COURSE:"[data-action=\"hide-course\"]",ACTION_SHOW_COURSE:"[data-action=\"show-course\"]",ACTION_ADD_FAVOURITE:"[data-action=\"add-favourite\"]",ACTION_REMOVE_FAVOURITE:"[data-action=\"remove-favourite\"]",FAVOURITE_ICON:"[data-region=\"favourite-icon\"]",ICON_IS_FAVOURITE:"[data-region=\"is-favourite\"]",ICON_NOT_FAVOURITE:"[data-region=\"not-favourite\"]",region:{selectBlock:"[data-region=\"myoverview\"]",clearIcon:"[data-action=\"clearsearch\"]",searchInput:"[data-action=\"search\"]"}};return a.default});
//# sourceMappingURL=selectors.min.js.map

View File

@ -1 +1 @@
{"version":3,"sources":["../src/selectors.js"],"names":["courseView","region","regionContent","FILTERS","FILTER_OPTION","DISPLAY_OPTION","ACTION_HIDE_COURSE","ACTION_SHOW_COURSE","ACTION_ADD_FAVOURITE","ACTION_REMOVE_FAVOURITE","FAVOURITE_ICON","ICON_IS_FAVOURITE","ICON_NOT_FAVOURITE","selectBlock","clearIcon","searchIcon","searchInput"],"mappings":"sJAsBe,CACXA,UAAU,CAAE,CACRC,MAAM,CAAE,gCADA,CAERC,aAAa,CAAE,uCAFP,CADD,CAKXC,OAAO,CAAE,0BALE,CAMXC,aAAa,CAAE,eANJ,CAOXC,cAAc,CAAE,uBAPL,CAQXC,kBAAkB,CAAE,+BART,CASXC,kBAAkB,CAAE,+BATT,CAUXC,oBAAoB,CAAE,iCAVX,CAWXC,uBAAuB,CAAE,oCAXd,CAYXC,cAAc,CAAE,kCAZL,CAaXC,iBAAiB,CAAE,gCAbR,CAcXC,kBAAkB,CAAE,iCAdT,CAeXX,MAAM,CAAE,CACJY,WAAW,CAAE,8BADT,CAEJC,SAAS,CAAE,8BAFP,CAGJC,UAAU,CAAE,+BAHR,CAIJC,WAAW,CAAE,gCAJT,CAfG,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 * Javascript to initialise the selectors for the myoverview block.\n *\n * @copyright 2018 Peter Dias <peter@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nexport default {\n courseView: {\n region: '[data-region=\"courses-view\"]',\n regionContent: '[data-region=\"course-view-content\"]'\n },\n FILTERS: '[data-region=\"filter\"]',\n FILTER_OPTION: '[data-filter]',\n DISPLAY_OPTION: '[data-display-option]',\n ACTION_HIDE_COURSE: '[data-action=\"hide-course\"]',\n ACTION_SHOW_COURSE: '[data-action=\"show-course\"]',\n ACTION_ADD_FAVOURITE: '[data-action=\"add-favourite\"]',\n ACTION_REMOVE_FAVOURITE: '[data-action=\"remove-favourite\"]',\n FAVOURITE_ICON: '[data-region=\"favourite-icon\"]',\n ICON_IS_FAVOURITE: '[data-region=\"is-favourite\"]',\n ICON_NOT_FAVOURITE: '[data-region=\"not-favourite\"]',\n region: {\n selectBlock: '[data-region=\"myoverview\"]',\n clearIcon: '[data-region=\"clear-icon\"]',\n searchIcon: '[data-region=\"search-icon\"]',\n searchInput: '[data-region=\"search-input\"]',\n },\n};\n"],"file":"selectors.min.js"}
{"version":3,"sources":["../src/selectors.js"],"names":["courseView","region","regionContent","FILTERS","FILTER_OPTION","DISPLAY_OPTION","ACTION_HIDE_COURSE","ACTION_SHOW_COURSE","ACTION_ADD_FAVOURITE","ACTION_REMOVE_FAVOURITE","FAVOURITE_ICON","ICON_IS_FAVOURITE","ICON_NOT_FAVOURITE","selectBlock","clearIcon","searchInput"],"mappings":"sJAsBe,CACXA,UAAU,CAAE,CACRC,MAAM,CAAE,gCADA,CAERC,aAAa,CAAE,uCAFP,CADD,CAKXC,OAAO,CAAE,0BALE,CAMXC,aAAa,CAAE,eANJ,CAOXC,cAAc,CAAE,uBAPL,CAQXC,kBAAkB,CAAE,+BART,CASXC,kBAAkB,CAAE,+BATT,CAUXC,oBAAoB,CAAE,iCAVX,CAWXC,uBAAuB,CAAE,oCAXd,CAYXC,cAAc,CAAE,kCAZL,CAaXC,iBAAiB,CAAE,gCAbR,CAcXC,kBAAkB,CAAE,iCAdT,CAeXX,MAAM,CAAE,CACJY,WAAW,CAAE,8BADT,CAEJC,SAAS,CAAE,+BAFP,CAGJC,WAAW,CAAE,0BAHT,CAfG,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 * Javascript to initialise the selectors for the myoverview block.\n *\n * @copyright 2018 Peter Dias <peter@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nexport default {\n courseView: {\n region: '[data-region=\"courses-view\"]',\n regionContent: '[data-region=\"course-view-content\"]'\n },\n FILTERS: '[data-region=\"filter\"]',\n FILTER_OPTION: '[data-filter]',\n DISPLAY_OPTION: '[data-display-option]',\n ACTION_HIDE_COURSE: '[data-action=\"hide-course\"]',\n ACTION_SHOW_COURSE: '[data-action=\"show-course\"]',\n ACTION_ADD_FAVOURITE: '[data-action=\"add-favourite\"]',\n ACTION_REMOVE_FAVOURITE: '[data-action=\"remove-favourite\"]',\n FAVOURITE_ICON: '[data-region=\"favourite-icon\"]',\n ICON_IS_FAVOURITE: '[data-region=\"is-favourite\"]',\n ICON_NOT_FAVOURITE: '[data-region=\"not-favourite\"]',\n region: {\n selectBlock: '[data-region=\"myoverview\"]',\n clearIcon: '[data-action=\"clearsearch\"]',\n searchInput: '[data-action=\"search\"]',\n },\n};\n"],"file":"selectors.min.js"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("block_myoverview/view_nav",["exports","jquery","core/custom_interaction_events","block_myoverview/repository","block_myoverview/view","block_myoverview/selectors"],function(a,b,c,d,f,g){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=j(b);c=i(c);d=i(d);f=i(f);g=j(g);function h(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;h=function(){return a};return a}function i(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=h();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function j(a){return a&&a.__esModule?a:{default:a}}var k=function(a,b){var c=null;if("display"===a){c="block_myoverview_user_view_preference"}else if("sort"===a){c="block_myoverview_user_sort_preference"}else if("customfieldvalue"===a){c="block_myoverview_user_grouping_customfieldvalue_preference"}else{c="block_myoverview_user_grouping_preference"}d.updateUserPreferences({preferences:[{type:c,value:b}]})},l=function(a){var d=a.find(g.default.FILTERS);c.define(d,[c.events.activate]);d.on(c.events.activate,g.default.FILTER_OPTION,function(c,d){var e=(0,b.default)(c.target);if(e.hasClass("active")){return}var h=e.attr("data-filter"),i=e.attr("data-pref"),j=e.attr("data-customfieldvalue");a.find(g.default.courseView.region).attr("data-"+h,e.attr("data-value"));k(h,i);if(j){a.find(g.default.courseView.region).attr("data-customfieldvalue",j);k("customfieldvalue",j)}var l=document.querySelector(g.default.region.selectBlock),m=l.querySelector(g.default.region.searchInput);if(""!==m.value){var n=l.querySelector(g.default.region.clearIcon),o=l.querySelector(g.default.region.searchIcon);m.value="";f.clearSearch(o,n,a)}else{f.init(a)}d.originalEvent.preventDefault()});d.on(c.events.activate,g.default.DISPLAY_OPTION,function(c,d){var e=(0,b.default)(c.target);if(e.hasClass("active")){return}var h=e.attr("data-display-option"),i=e.attr("data-pref");a.find(g.default.courseView.region).attr("data-display",e.attr("data-value"));k(h,i);f.reset(a);d.originalEvent.preventDefault()})},m=function(a){a=(0,b.default)(a);l(a)};a.init=m});
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("block_myoverview/view_nav",["exports","jquery","core/custom_interaction_events","block_myoverview/repository","block_myoverview/view","block_myoverview/selectors"],function(a,b,c,d,f,g){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=j(b);c=i(c);d=i(d);f=i(f);g=j(g);function h(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;h=function(){return a};return a}function i(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=h();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function j(a){return a&&a.__esModule?a:{default:a}}var k=function(a,b){var c=null;if("display"===a){c="block_myoverview_user_view_preference"}else if("sort"===a){c="block_myoverview_user_sort_preference"}else if("customfieldvalue"===a){c="block_myoverview_user_grouping_customfieldvalue_preference"}else{c="block_myoverview_user_grouping_preference"}d.updateUserPreferences({preferences:[{type:c,value:b}]})},l=function(a){var d=a.find(g.default.FILTERS);c.define(d,[c.events.activate]);d.on(c.events.activate,g.default.FILTER_OPTION,function(c,d){var e=(0,b.default)(c.target);if(e.hasClass("active")){return}var h=e.attr("data-filter"),i=e.attr("data-pref"),j=e.attr("data-customfieldvalue");a.find(g.default.courseView.region).attr("data-"+h,e.attr("data-value"));k(h,i);if(j){a.find(g.default.courseView.region).attr("data-customfieldvalue",j);k("customfieldvalue",j)}var l=document.querySelector(g.default.region.selectBlock),m=l.querySelector(g.default.region.searchInput);if(""!==m.value){var n=l.querySelector(g.default.region.clearIcon);m.value="";f.clearSearch(n,a)}else{f.init(a)}d.originalEvent.preventDefault()});d.on(c.events.activate,g.default.DISPLAY_OPTION,function(c,d){var e=(0,b.default)(c.target);if(e.hasClass("active")){return}var h=e.attr("data-display-option"),i=e.attr("data-pref");a.find(g.default.courseView.region).attr("data-display",e.attr("data-value"));k(h,i);f.reset(a);d.originalEvent.preventDefault()})},m=function(a){a=(0,b.default)(a);l(a)};a.init=m});
//# sourceMappingURL=view_nav.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -37,8 +37,7 @@ export default {
ICON_NOT_FAVOURITE: '[data-region="not-favourite"]',
region: {
selectBlock: '[data-region="myoverview"]',
clearIcon: '[data-region="clear-icon"]',
searchIcon: '[data-region="search-icon"]',
searchInput: '[data-region="search-input"]',
clearIcon: '[data-action="clearsearch"]',
searchInput: '[data-action="search"]',
},
};

View File

@ -767,18 +767,18 @@ const registerEventListeners = (root, page) => {
// Searching functionality event handlers.
const input = page.querySelector(SELECTORS.region.searchInput);
const clearIcon = page.querySelector(SELECTORS.region.clearIcon);
const searchIcon = page.querySelector(SELECTORS.region.searchIcon);
clearIcon.addEventListener('click', () => {
input.value = '';
clearSearch(searchIcon, clearIcon, root);
input.focus();
clearSearch(clearIcon, root);
});
input.addEventListener('input', debounce(() => {
if (input.value === '') {
clearSearch(searchIcon, clearIcon, root);
clearSearch(clearIcon, root);
} else {
activeSearch(searchIcon, clearIcon);
activeSearch(clearIcon);
initializePagedContent(root, searchFunctionalityCurry(), input.value.trim());
}
}, 300));
@ -787,25 +787,21 @@ const registerEventListeners = (root, page) => {
/**
* Reset the search icon and trigger the init for the block.
*
* @param {HTMLElement} searchIcon Our search icon to manipulate.
* @param {HTMLElement} clearIcon Our closing icon to manipulate.
* @param {Object} root The myoverview block container element.
*/
export const clearSearch = (searchIcon, clearIcon, root) => {
searchIcon.classList.remove('d-none');
clearIcon.parentElement.classList.add('d-none');
export const clearSearch = (clearIcon, root) => {
clearIcon.classList.add('d-none');
init(root);
};
/**
* Change the searching icon to its' active state.
*
* @param {HTMLElement} searchIcon Our search icon to manipulate.
* @param {HTMLElement} clearIcon Our closing icon to manipulate.
*/
const activeSearch = (searchIcon, clearIcon) => {
searchIcon.classList.add('d-none');
clearIcon.parentElement.classList.remove('d-none');
const activeSearch = (clearIcon) => {
clearIcon.classList.remove('d-none');
};
/**

View File

@ -94,10 +94,9 @@ const registerSelector = root => {
const input = page.querySelector(SELECTORS.region.searchInput);
if (input.value !== '') {
const clearIcon = page.querySelector(SELECTORS.region.clearIcon);
const searchIcon = page.querySelector(SELECTORS.region.searchIcon);
input.value = '';
// Triggers the init so wont need to call it again.
View.clearSearch(searchIcon, clearIcon, root);
View.clearSearch(clearIcon, root);
} else {
View.init(root);
}

View File

@ -51,7 +51,6 @@ $string['availablegroupings'] = 'Available filters';
$string['availablegroupings_desc'] = 'Course filters which are available for selection by users. If none are selected, all courses will be displayed.';
$string['card'] = 'Card';
$string['cards'] = 'Cards';
$string['clearsearch'] = "Clear search";
$string['courseprogress'] = 'Course progress:';
$string['completepercent'] = '{$a}% complete';
$string['customfield'] = 'Custom field';
@ -88,6 +87,9 @@ $string['hiddencourses'] = 'Archived';
$string['show'] = 'Unarchive';
$string['privacy:request:preference:set'] = 'The value of the setting \'{$a->name}\' was \'{$a->value}\'';
// Deprecated since Moodle 4.0.
$string['clearsearch'] = "Clear search";
// Deprecated since Moodle 3.7.
$string['complete'] = 'complete';
$string['nocourses'] = 'No courses';

View File

@ -1,2 +1,3 @@
nocourses,block_myoverview
complete,block_myoverview
clearsearch,block_myoverview

View File

@ -22,27 +22,13 @@
Example context (json):
{}
}}
<div class="searchbar input-group mb-1 mr-1 p-0 col-lg-3 col-md-6 col-sm-8 col-12" role="search">
<label for="searchinput">
<span class="sr-only">{{#str}} searchcourses, block_myoverview {{/str}}</span>
</label>
<input type="text"
data-region="search-input"
id="searchinput"
class="form-control searchinput border-right-0 h-100 px-3 py-2"
placeholder="{{#str}} search, core {{/str}}"
name="search"
autocomplete="off"
>
<div class="input-group-append">
<div data-region="search-icon" class="input-group-text">
{{#pix}} a/search, core {{/pix}}
</div>
<div class="clear input-group-text d-none">
<button class="btn p-0" data-region="clear-icon">
<span class="d-flex" aria-hidden="true">{{#pix}} e/cancel, core {{/pix}}</span>
<span class="sr-only">{{#str}} clearsearch, block_myoverview {{/str}}</span>
</button>
</div>
</div>
<div class="mb-1 mr-1">
{{< core/search_input_auto }}
{{$label}}{{#str}}
searchcourses, block_myoverview
{{/str}}{{/label}}
{{$placeholder}}{{#str}}
search, core
{{/str}}{{/placeholder}}
{{/ core/search_input_auto }}
</div>

View File

@ -41,20 +41,20 @@ Feature: My overview block searching
Scenario: The search should return no courses if I am not enrolled in any
When I am on the "My courses" page logged in as "student2"
Then I should see "No courses" in the "Course overview" "block"
And I set the field "Search courses" to "Fake example"
And I set the field "Search courses" in the "Course overview" "block" to "Fake example"
And I should see "No courses" in the "Course overview" "block"
And I log out
Scenario: Single page search
Given I am on the "My courses" page logged in as "student1"
And I set the field "Search courses" to "Course 0"
And I set the field "Search courses" in the "Course overview" "block" to "Course 0"
Then I should see "Course 01" in the "Course overview" "block"
And I should not see "Course 13" in the "Course overview" "block"
And I log out
Scenario: Paginated search
Given I am on the "My courses" page logged in as "student1"
And I set the field "Search courses" to "Course"
And I set the field "Search courses" in the "Course overview" "block" to "Course"
And I should see "Course 01" in the "Course overview" "block"
And I should not see "Course 13" in the "Course overview" "block"
And I click on "[data-control='next']" "css_element" in the "Course overview" "block"

View File

@ -1,2 +1,2 @@
define ("block_timeline/event_list",["jquery","core/notification","core/templates","core/str","core/user_date","block_timeline/calendar_events_repository","core/pending"],function(a,b,c,d,e,f,g){var h=!1,i={EMPTY_MESSAGE:"[data-region=\"empty-message\"]",ROOT:"[data-region=\"event-list-container\"]",EVENT_LIST_CONTENT:"[data-region=\"event-list-content\"]",EVENT_LIST_WRAPPER:"[data-region=\"event-list-wrapper\"]",EVENT_LIST_LOADING_PLACEHOLDER:"[data-region=\"event-list-loading-placeholder\"]",TIMELINE_BLOCK:"[data-region=\"timeline\"]",TIMELINE_SEARCH:"[data-region=\"search-input\"]",MORE_ACTIVITIES_BUTTON:"[data-action=\"more-events\"]",MORE_ACTIVITIES_BUTTON_CONTAINER:"[data-region=\"more-events-button-container\"]"},j={EVENT_LIST_CONTENT:"block_timeline/event-list-content",MORE_ACTIVITIES_BUTTON:"block_timeline/event-list-loadmore",LOADING_ICON:"core/loading"},k=function(a){a.find(i.EVENT_LIST_CONTENT).addClass("hidden");a.find(i.EMPTY_MESSAGE).removeClass("hidden")},l=function(a){a.find(i.EVENT_LIST_CONTENT).removeClass("hidden");a.find(i.EMPTY_MESSAGE).addClass("hidden")},m=function(a){a.find(i.EVENT_LIST_CONTENT).empty()},n=function(a){var b={},c={courseview:h,eventsbyday:[]};a.forEach(function(a){var c=a.timeusermidnight;if(b[c]){b[c].push(a)}else{b[c]=[a]}});Object.keys(b).forEach(function(a){var d=b[a];c.eventsbyday.push({dayTimestamp:a,events:d})});return c},o=function(a){var b=n(a),d=j.EVENT_LIST_CONTENT;return c.render(d,b)},p=function(a,b,c,d,e,g,h){var i=d!=void 0?a+d*86400:!1,j={starttime:a+c*86400,limit:b};if(e){j.aftereventid=e}if(i){j.endtime=i}if(h){j.searchvalue=h}if(g){j.courseid=g;return f.queryByCourse(j)}else{return f.queryByTime(j)}},q=function(a,c,d,e,f,g,h,i,j){return r(a,d,e,f,g,h,i,j).then(function(a){if(a.calendarEvents.length){var b=a.calendarEvents.at(-1).id,d=a.calendarEvents.at(-1).timeusermidnight;c.resolve({hasContent:!0,lastId:b,lastTimeStamp:d,loadedAll:a.loadedAll});return o(a.calendarEvents,e)}else{c.resolve({hasContent:!1,lastId:0,lastTimeStamp:0,loadedAll:!0});return a.calendarEvents}}).catch(b.exception)},r=function(a,b,c,d,f,g,h,i){var j=p(c,b+1,g,h,d,f,i),k=[],l=!0;return j.then(function(d){if(!d.events.length){return{calendarEvents:k,loadedAll:l}}var f=document.querySelector("[data-filtername='overdue']"),g=f&&f.getAttribute("aria-current");k=d.events.filter(function(a){if("open"==a.eventtype||"opensubmission"==a.eventtype){var b=e.getUserMidnightForTimestamp(a.timesort,c);return b>c}return!g||a.overdue});l=k.length<=b;if(!l){k.pop()}if(k.length){var h=k.at(-1).id;u(a,h)}return{calendarEvents:k,loadedAll:l}})},s=function(d){var e=parseInt(d.attr("data-midnight"),10),f=d.attr("data-course-id"),g=parseInt(d.attr("data-days-offset"),10),h=d.attr("data-days-limit"),k=t(d),l=d.find(i.EVENT_LIST_WRAPPER),m=d.closest(i.TIMELINE_BLOCK).find(i.TIMELINE_SEARCH).val(),n=r(d,10,e,k,f,g,h,m);n.then(function(e){if(e.calendarEvents.length){var f=o(e.calendarEvents),g=v(d);f.then(function(b,f){b=a(b);b.find("[data-timestamp=\"".concat(g,"\"]")).remove();c.appendNodeContents(l,b.html(),f);if(!e.loadedAll){c.render(j.MORE_ACTIVITIES_BUTTON,{}).then(function(a){l.append(a);w(d,e.calendarEvents.at(-1).timeusermidnight);z(d);return a}).catch(function(){return!1})}return b}).catch(b.exception)}return e}).then(function(){return y(d)}).catch(b.exception)},t=function(a){return parseInt(a.attr("data-lazyload-offset"),10)},u=function(a,b){a.attr("data-lazyload-offset",b)},v=function(a){return parseInt(a.attr("data-timestamp"),10)},w=function(a,b){a.attr("data-timestamp",b)},x=function(a){var b=a.find(i.MORE_ACTIVITIES_BUTTON);b.prop("disabled",!0);c.render(j.LOADING_ICON,{}).then(function(a){b.append(a);return a}).catch(function(){return!1})},y=function(a){var b=a.find(i.MORE_ACTIVITIES_BUTTON_CONTAINER);b.remove()},z=function(a){var b=a.find(i.MORE_ACTIVITIES_BUTTON);b.on("click",function(){x(a);s(a)})};return{init:function init(d){var e=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},f=new g("block/timeline:event-init");d=a(d);h=!!e.courseview;var n=a.Deferred(),o=d.find(i.EVENT_LIST_CONTENT),p=d.find(i.EVENT_LIST_LOADING_PLACEHOLDER),r=d.attr("data-course-id"),s=parseInt(d.attr("data-days-offset"),10),t=d.attr("data-days-limit"),u=parseInt(d.attr("data-midnight"),10),v=d.closest(i.TIMELINE_BLOCK).find(i.TIMELINE_SEARCH).val();m(d);l(d);p.removeClass("hidden");if(t!=void 0){t=parseInt(t,10)}return q(d,n,5,u,0,r,s,t,v).then(function(b,e){n.then(function(f){if(!f.hasContent){p.addClass("hidden");return k(d)}b=a(b);b.addClass("hidden");c.replaceNodeContents(o,b,e);b.removeClass("hidden");p.addClass("hidden");if(!f.loadedAll){c.render(j.MORE_ACTIVITIES_BUTTON,{courseview:h}).then(function(a){o.append(a);w(d,f.lastTimeStamp);z(d);return a}).catch(function(){return!1})}return f}).catch(function(){return!1});return b}).then(function(){return f.resolve()}).catch(b.exception)},rootSelector:i.ROOT}});
define ("block_timeline/event_list",["jquery","core/notification","core/templates","core/str","core/user_date","block_timeline/calendar_events_repository","core/pending"],function(a,b,c,d,e,f,g){var h=!1,i={EMPTY_MESSAGE:"[data-region=\"empty-message\"]",ROOT:"[data-region=\"event-list-container\"]",EVENT_LIST_CONTENT:"[data-region=\"event-list-content\"]",EVENT_LIST_WRAPPER:"[data-region=\"event-list-wrapper\"]",EVENT_LIST_LOADING_PLACEHOLDER:"[data-region=\"event-list-loading-placeholder\"]",TIMELINE_BLOCK:"[data-region=\"timeline\"]",TIMELINE_SEARCH:"[data-action=\"search\"]",MORE_ACTIVITIES_BUTTON:"[data-action=\"more-events\"]",MORE_ACTIVITIES_BUTTON_CONTAINER:"[data-region=\"more-events-button-container\"]"},j={EVENT_LIST_CONTENT:"block_timeline/event-list-content",MORE_ACTIVITIES_BUTTON:"block_timeline/event-list-loadmore",LOADING_ICON:"core/loading"},k=function(a){a.find(i.EVENT_LIST_CONTENT).addClass("hidden");a.find(i.EMPTY_MESSAGE).removeClass("hidden")},l=function(a){a.find(i.EVENT_LIST_CONTENT).removeClass("hidden");a.find(i.EMPTY_MESSAGE).addClass("hidden")},m=function(a){a.find(i.EVENT_LIST_CONTENT).empty()},n=function(a){var b={},c={courseview:h,eventsbyday:[]};a.forEach(function(a){var c=a.timeusermidnight;if(b[c]){b[c].push(a)}else{b[c]=[a]}});Object.keys(b).forEach(function(a){var d=b[a];c.eventsbyday.push({dayTimestamp:a,events:d})});return c},o=function(a){var b=n(a),d=j.EVENT_LIST_CONTENT;return c.render(d,b)},p=function(a,b,c,d,e,g,h){var i=d!=void 0?a+d*86400:!1,j={starttime:a+c*86400,limit:b};if(e){j.aftereventid=e}if(i){j.endtime=i}if(h){j.searchvalue=h}if(g){j.courseid=g;return f.queryByCourse(j)}else{return f.queryByTime(j)}},q=function(a,c,d,e,f,g,h,i,j){return r(a,d,e,f,g,h,i,j).then(function(a){if(a.calendarEvents.length){var b=a.calendarEvents.at(-1).id,d=a.calendarEvents.at(-1).timeusermidnight;c.resolve({hasContent:!0,lastId:b,lastTimeStamp:d,loadedAll:a.loadedAll});return o(a.calendarEvents,e)}else{c.resolve({hasContent:!1,lastId:0,lastTimeStamp:0,loadedAll:!0});return a.calendarEvents}}).catch(b.exception)},r=function(a,b,c,d,f,g,h,i){var j=p(c,b+1,g,h,d,f,i),k=[],l=!0;return j.then(function(d){if(!d.events.length){return{calendarEvents:k,loadedAll:l}}var f=document.querySelector("[data-filtername='overdue']"),g=f&&f.getAttribute("aria-current");k=d.events.filter(function(a){if("open"==a.eventtype||"opensubmission"==a.eventtype){var b=e.getUserMidnightForTimestamp(a.timesort,c);return b>c}return!g||a.overdue});l=k.length<=b;if(!l){k.pop()}if(k.length){var h=k.at(-1).id;u(a,h)}return{calendarEvents:k,loadedAll:l}})},s=function(d){var e=parseInt(d.attr("data-midnight"),10),f=d.attr("data-course-id"),g=parseInt(d.attr("data-days-offset"),10),h=d.attr("data-days-limit"),k=t(d),l=d.find(i.EVENT_LIST_WRAPPER),m=d.closest(i.TIMELINE_BLOCK).find(i.TIMELINE_SEARCH).val(),n=r(d,10,e,k,f,g,h,m);n.then(function(e){if(e.calendarEvents.length){var f=o(e.calendarEvents),g=v(d);f.then(function(b,f){b=a(b);b.find("[data-timestamp=\"".concat(g,"\"]")).remove();c.appendNodeContents(l,b.html(),f);if(!e.loadedAll){c.render(j.MORE_ACTIVITIES_BUTTON,{}).then(function(a){l.append(a);w(d,e.calendarEvents.at(-1).timeusermidnight);z(d);return a}).catch(function(){return!1})}return b}).catch(b.exception)}return e}).then(function(){return y(d)}).catch(b.exception)},t=function(a){return parseInt(a.attr("data-lazyload-offset"),10)},u=function(a,b){a.attr("data-lazyload-offset",b)},v=function(a){return parseInt(a.attr("data-timestamp"),10)},w=function(a,b){a.attr("data-timestamp",b)},x=function(a){var b=a.find(i.MORE_ACTIVITIES_BUTTON);b.prop("disabled",!0);c.render(j.LOADING_ICON,{}).then(function(a){b.append(a);return a}).catch(function(){return!1})},y=function(a){var b=a.find(i.MORE_ACTIVITIES_BUTTON_CONTAINER);b.remove()},z=function(a){var b=a.find(i.MORE_ACTIVITIES_BUTTON);b.on("click",function(){x(a);s(a)})};return{init:function init(d){var e=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},f=new g("block/timeline:event-init");d=a(d);h=!!e.courseview;var n=a.Deferred(),o=d.find(i.EVENT_LIST_CONTENT),p=d.find(i.EVENT_LIST_LOADING_PLACEHOLDER),r=d.attr("data-course-id"),s=parseInt(d.attr("data-days-offset"),10),t=d.attr("data-days-limit"),u=parseInt(d.attr("data-midnight"),10),v=d.closest(i.TIMELINE_BLOCK).find(i.TIMELINE_SEARCH).val();m(d);l(d);p.removeClass("hidden");if(t!=void 0){t=parseInt(t,10)}return q(d,n,5,u,0,r,s,t,v).then(function(b,e){n.then(function(f){if(!f.hasContent){p.addClass("hidden");return k(d)}b=a(b);b.addClass("hidden");c.replaceNodeContents(o,b,e);b.removeClass("hidden");p.addClass("hidden");if(!f.loadedAll){c.render(j.MORE_ACTIVITIES_BUTTON,{courseview:h}).then(function(a){o.append(a);w(d,f.lastTimeStamp);z(d);return a}).catch(function(){return!1})}return f}).catch(function(){return!1});return b}).then(function(){return f.resolve()}).catch(b.exception)},rootSelector:i.ROOT}});
//# sourceMappingURL=event_list.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
define ("block_timeline/view_courses",["jquery","core/notification","core/custom_interaction_events","core/templates","block_timeline/event_list","core_course/repository","block_timeline/calendar_events_repository"],function(a,b,c,d,e,f,g){var h={MORE_COURSES_BUTTON:"[data-action=\"more-courses\"]",MORE_COURSES_BUTTON_CONTAINER:"[data-region=\"more-courses-button-container\"]",NO_COURSES_EMPTY_MESSAGE:"[data-region=\"no-courses-empty-message\"]",COURSES_LIST:"[data-region=\"courses-list\"]",COURSE_ITEMS_LOADING_PLACEHOLDER:"[data-region=\"course-items-loading-placeholder\"]",COURSE_EVENTS_CONTAINER:"[data-region=\"course-events-container\"]",COURSE_NAME:"[data-region=\"course-name\"]",LOADING_ICON:".loading-icon",TIMELINE_BLOCK:"[data-region=\"timeline\"]",TIMELINE_SEARCH:"[data-region=\"search-input\"]"},i={COURSE_ITEMS:"block_timeline/course-items",LOADING_ICON:"core/loading"},j=5,k=86400,l={courseview:!0},m=function(a){a.find(h.COURSE_ITEMS_LOADING_PLACEHOLDER).addClass("hidden")},n=function(a){a.find(h.MORE_COURSES_BUTTON_CONTAINER).addClass("hidden")},o=function(a){a.find(h.MORE_COURSES_BUTTON_CONTAINER).removeClass("hidden")},p=function(a){var b=a.find(h.MORE_COURSES_BUTTON);b.prop("disabled",!0);d.render(i.LOADING_ICON,{}).then(function(a){b.append(a);return a}).catch(function(){return!1})},q=function(a){var b=a.find(h.MORE_COURSES_BUTTON);b.prop("disabled",!1);b.find(h.LOADING_ICON).remove()},r=function(a){a.find(h.NO_COURSES_EMPTY_MESSAGE).removeClass("hidden")},s=function(a,b){var c=a.find(h.COURSES_LIST);d.appendNodeContents(c,b,"")},t=function(a){return 0<a.find(h.COURSE_EVENTS_CONTAINER).length},u=function(a){return parseInt(a.attr("data-offset"),10)},v=function(a,b){a.attr("data-offset",b)},w=function(a){return parseInt(a.attr("data-limit"),10)},x=function(a){return parseInt(a.attr("data-days-offset"),10)},y=function(a){var b=a.attr("data-days-limit");return b!=void 0?parseInt(b,10):void 0},z=function(a){return parseInt(a.attr("data-midnight"),10)},A=function(a){var b=z(a),c=x(a);return b+c*k},B=function(a){var b=z(a),c=y(a);return c!=void 0?b+c*k:!1},C=function(a,b,c,d,e){var f={courseids:a,starttime:b,limit:c};if(d){f.endtime=d}if(e){f.searchvalue=e}return g.queryByCourses(f)},D=function(a){return a.data("last-event-load-time")},E=function(a,b){a.data("last-event-load-time",b)},F=function(a,b){return D(a)>b},G=function(a,b,c,d){var e=a.map(function(a){return a.id});return C(e,b,j+1,c,d)},H=function(a,b,c,e,f){return d.render(i.COURSE_ITEMS,{courses:a,midnight:c,hasdaysoffset:!0,hasdayslimit:f!=void 0,daysoffset:e,dayslimit:f,nodayslimit:f==void 0,courseview:!0}).then(function(a){m(b);if(a){s(b,a)}else{if(!t(b)){r(b)}}return a}).then(function(c){if(a.length<2){n(b)}else{o(b)}return c}).catch(function(){m(b)})},I=function(c){var d=u(c),g=w(c);return f.getEnrolledCoursesByTimelineClassification("inprogress",g,d,"fullname asc").then(function(b){var d=Date.now(),f=b.courses,g=b.nextoffset,i=x(c),j=y(c),k=z(c),m=A(c),n=B(c),o=c.closest(h.TIMELINE_BLOCK).find(h.TIMELINE_SEARCH).val();v(c,g);var p=G(f,m,n,o),q=H(f,c,k,i,j);return a.when(p,q).then(function(a){if(F(c,d)){return a}f.forEach(function(a){var b=a.id,d=c.find("[data-region=\"course-events-container\"][data-course-id=\""+b+"\"]"),f=d.find(e.rootSelector);e.init(f,l)});return a})}).catch(b.exception)},J=function(c){var d=Date.now(),f=A(c),g=B(c),i=c.find(h.COURSE_EVENTS_CONTAINER),k=i.map(function(){return a(this).attr("data-course-id")}).get(),m=c.closest(h.TIMELINE_BLOCK).find(h.TIMELINE_SEARCH).val();E(c,d);return C(k,f,j+1,g,m).then(function(b){if(F(c,d)){return b}i.each(function(b,c){c=a(c);var d=c.find(e.rootSelector);e.init(d,l)});return b}).catch(b.exception)},K=function(a){c.define(a,[c.events.activate]);a.on(c.events.activate,h.MORE_COURSES_BUTTON,function(b,c){p(a);I(a).then(function(){q(a)}).catch(function(){q(a)});if(c){c.originalEvent.preventDefault();c.originalEvent.stopPropagation()}b.stopPropagation()})},L=function(a){if(!a.attr("data-seen")){if(t(a)){J(a)}else{I(a)}a.attr("data-seen",!0)}};return{init:function init(b){b=a(b);E(b,Date.now());if(b.hasClass("active")){I(b);b.attr("data-seen",!0)}K(b)},reset:function reset(a){a.removeAttr("data-seen");if(a.hasClass("active")){L(a)}},shown:L}});
define ("block_timeline/view_courses",["jquery","core/notification","core/custom_interaction_events","core/templates","block_timeline/event_list","core_course/repository","block_timeline/calendar_events_repository"],function(a,b,c,d,e,f,g){var h={MORE_COURSES_BUTTON:"[data-action=\"more-courses\"]",MORE_COURSES_BUTTON_CONTAINER:"[data-region=\"more-courses-button-container\"]",NO_COURSES_EMPTY_MESSAGE:"[data-region=\"no-courses-empty-message\"]",COURSES_LIST:"[data-region=\"courses-list\"]",COURSE_ITEMS_LOADING_PLACEHOLDER:"[data-region=\"course-items-loading-placeholder\"]",COURSE_EVENTS_CONTAINER:"[data-region=\"course-events-container\"]",COURSE_NAME:"[data-region=\"course-name\"]",LOADING_ICON:".loading-icon",TIMELINE_BLOCK:"[data-region=\"timeline\"]",TIMELINE_SEARCH:"[data-action=\"search\"]"},i={COURSE_ITEMS:"block_timeline/course-items",LOADING_ICON:"core/loading"},j=5,k=86400,l={courseview:!0},m=function(a){a.find(h.COURSE_ITEMS_LOADING_PLACEHOLDER).addClass("hidden")},n=function(a){a.find(h.MORE_COURSES_BUTTON_CONTAINER).addClass("hidden")},o=function(a){a.find(h.MORE_COURSES_BUTTON_CONTAINER).removeClass("hidden")},p=function(a){var b=a.find(h.MORE_COURSES_BUTTON);b.prop("disabled",!0);d.render(i.LOADING_ICON,{}).then(function(a){b.append(a);return a}).catch(function(){return!1})},q=function(a){var b=a.find(h.MORE_COURSES_BUTTON);b.prop("disabled",!1);b.find(h.LOADING_ICON).remove()},r=function(a){a.find(h.NO_COURSES_EMPTY_MESSAGE).removeClass("hidden")},s=function(a,b){var c=a.find(h.COURSES_LIST);d.appendNodeContents(c,b,"")},t=function(a){return 0<a.find(h.COURSE_EVENTS_CONTAINER).length},u=function(a){return parseInt(a.attr("data-offset"),10)},v=function(a,b){a.attr("data-offset",b)},w=function(a){return parseInt(a.attr("data-limit"),10)},x=function(a){return parseInt(a.attr("data-days-offset"),10)},y=function(a){var b=a.attr("data-days-limit");return b!=void 0?parseInt(b,10):void 0},z=function(a){return parseInt(a.attr("data-midnight"),10)},A=function(a){var b=z(a),c=x(a);return b+c*k},B=function(a){var b=z(a),c=y(a);return c!=void 0?b+c*k:!1},C=function(a,b,c,d,e){var f={courseids:a,starttime:b,limit:c};if(d){f.endtime=d}if(e){f.searchvalue=e}return g.queryByCourses(f)},D=function(a){return a.data("last-event-load-time")},E=function(a,b){a.data("last-event-load-time",b)},F=function(a,b){return D(a)>b},G=function(a,b,c,d){var e=a.map(function(a){return a.id});return C(e,b,j+1,c,d)},H=function(a,b,c,e,f){return d.render(i.COURSE_ITEMS,{courses:a,midnight:c,hasdaysoffset:!0,hasdayslimit:f!=void 0,daysoffset:e,dayslimit:f,nodayslimit:f==void 0,courseview:!0}).then(function(a){m(b);if(a){s(b,a)}else{if(!t(b)){r(b)}}return a}).then(function(c){if(a.length<2){n(b)}else{o(b)}return c}).catch(function(){m(b)})},I=function(c){var d=u(c),g=w(c);return f.getEnrolledCoursesByTimelineClassification("inprogress",g,d,"fullname asc").then(function(b){var d=Date.now(),f=b.courses,g=b.nextoffset,i=x(c),j=y(c),k=z(c),m=A(c),n=B(c),o=c.closest(h.TIMELINE_BLOCK).find(h.TIMELINE_SEARCH).val();v(c,g);var p=G(f,m,n,o),q=H(f,c,k,i,j);return a.when(p,q).then(function(a){if(F(c,d)){return a}f.forEach(function(a){var b=a.id,d=c.find("[data-region=\"course-events-container\"][data-course-id=\""+b+"\"]"),f=d.find(e.rootSelector);e.init(f,l)});return a})}).catch(b.exception)},J=function(c){var d=Date.now(),f=A(c),g=B(c),i=c.find(h.COURSE_EVENTS_CONTAINER),k=i.map(function(){return a(this).attr("data-course-id")}).get(),m=c.closest(h.TIMELINE_BLOCK).find(h.TIMELINE_SEARCH).val();E(c,d);return C(k,f,j+1,g,m).then(function(b){if(F(c,d)){return b}i.each(function(b,c){c=a(c);var d=c.find(e.rootSelector);e.init(d,l)});return b}).catch(b.exception)},K=function(a){c.define(a,[c.events.activate]);a.on(c.events.activate,h.MORE_COURSES_BUTTON,function(b,c){p(a);I(a).then(function(){q(a)}).catch(function(){q(a)});if(c){c.originalEvent.preventDefault();c.originalEvent.stopPropagation()}b.stopPropagation()})},L=function(a){if(!a.attr("data-seen")){if(t(a)){J(a)}else{I(a)}a.attr("data-seen",!0)}};return{init:function init(b){b=a(b);E(b,Date.now());if(b.hasClass("active")){I(b);b.attr("data-seen",!0)}K(b)},reset:function reset(a){a.removeAttr("data-seen");if(a.hasClass("active")){L(a)}},shown:L}});
//# sourceMappingURL=view_courses.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
define ("block_timeline/view_nav",["jquery","core/custom_interaction_events","block_timeline/view","core/ajax","core/notification","core/utils"],function(a,b,c,d,e,f){var g={TIMELINE_DAY_FILTER:"[data-region=\"day-filter\"]",TIMELINE_DAY_FILTER_OPTION:"[data-from]",TIMELINE_VIEW_SELECTOR:"[data-region=\"view-selector\"]",DATA_DAYS_OFFSET:"[data-days-offset]",DATA_DAYS_LIMIT:"[data-days-limit]",TIMELINE_SEARCH_INPUT:"[data-region=\"search-input\"]",TIMELINE_SEARCH_CLEAR_ICON:"[data-region=\"clear-icon\"]",TIMELINE_SEARCH_SEARCH_ICON:"[data-region=\"search-icon\"]"},h=function(a,b){d.call([{methodname:"core_user_update_user_preferences",args:{preferences:[{type:a,value:b}]}}])[0].fail(e.exception)},i=function(d,f){var i=d.find(g.TIMELINE_DAY_FILTER);b.define(i,[b.events.activate]);i.on(b.events.activate,g.TIMELINE_DAY_FILTER_OPTION,function(b,e){var i=a(b.currentTarget).data("filtername");h("block_timeline_user_filter_preference",i);var j=a(b.target).closest(g.TIMELINE_DAY_FILTER_OPTION);if("true"==j.attr("aria-current")){return}var k=j.attr("data-from"),l=j.attr("data-to"),m=d.find(g.DATA_DAYS_OFFSET);m.attr("data-days-offset",k);if(l!=void 0){m.attr("data-days-limit",l)}else{m.removeAttr("data-days-limit")}c.reset(f);e.originalEvent.preventDefault()})},j=function(d,f){var i=d.find(g.TIMELINE_VIEW_SELECTOR);i.on("shown shown.bs.tab",function(b){c.shown(f);a(b.target).removeClass("active")});b.define(i,[b.events.activate]);i.on(b.events.activate,"[data-toggle='tab']",function(b){var c=a(b.currentTarget).data("filtername");h("block_timeline_user_sort_preference",c)})},k=function(a,b){var c=a.find(g.TIMELINE_SEARCH_INPUT),d=a.find(g.TIMELINE_SEARCH_SEARCH_ICON),e=a.find(g.TIMELINE_SEARCH_CLEAR_ICON);c.on("input",f.debounce(function(){if(""!==c.val()){l(d,e,b)}else{m(d,e,b)}},300));e.on("click",function(){c.val("");m(d,e,b)})},l=function(a,b,d){a.addClass("d-none");b.parent().removeClass("d-none");c.reset(d)},m=function(a,b,d){a.removeClass("d-none");b.parent().addClass("d-none");c.reset(d)};return{init:function init(b,c){b=a(b);i(b,c);j(b,c);k(b,c)}}});
define ("block_timeline/view_nav",["jquery","core/custom_interaction_events","block_timeline/view","core/ajax","core/notification","core/utils"],function(a,b,c,d,e,f){var g={TIMELINE_DAY_FILTER:"[data-region=\"day-filter\"]",TIMELINE_DAY_FILTER_OPTION:"[data-from]",TIMELINE_VIEW_SELECTOR:"[data-region=\"view-selector\"]",DATA_DAYS_OFFSET:"[data-days-offset]",DATA_DAYS_LIMIT:"[data-days-limit]",TIMELINE_SEARCH_INPUT:"[data-action=\"search\"]",TIMELINE_SEARCH_CLEAR_ICON:"[data-action=\"clearsearch\"]"},h=function(a,b){d.call([{methodname:"core_user_update_user_preferences",args:{preferences:[{type:a,value:b}]}}])[0].fail(e.exception)},i=function(d,f){var i=d.find(g.TIMELINE_DAY_FILTER);b.define(i,[b.events.activate]);i.on(b.events.activate,g.TIMELINE_DAY_FILTER_OPTION,function(b,e){var i=a(b.currentTarget).data("filtername");h("block_timeline_user_filter_preference",i);var j=a(b.target).closest(g.TIMELINE_DAY_FILTER_OPTION);if("true"==j.attr("aria-current")){return}var k=j.attr("data-from"),l=j.attr("data-to"),m=d.find(g.DATA_DAYS_OFFSET);m.attr("data-days-offset",k);if(l!=void 0){m.attr("data-days-limit",l)}else{m.removeAttr("data-days-limit")}c.reset(f);e.originalEvent.preventDefault()})},j=function(d,f){var i=d.find(g.TIMELINE_VIEW_SELECTOR);i.on("shown shown.bs.tab",function(b){c.shown(f);a(b.target).removeClass("active")});b.define(i,[b.events.activate]);i.on(b.events.activate,"[data-toggle='tab']",function(b){var c=a(b.currentTarget).data("filtername");h("block_timeline_user_sort_preference",c)})},k=function(a,b){var c=a.find(g.TIMELINE_SEARCH_INPUT),d=a.find(g.TIMELINE_SEARCH_CLEAR_ICON);c.on("input",f.debounce(function(){if(""!==c.val()){l(d,b)}else{m(d,b)}},300));d.on("click",function(){c.val("");m(d,b);c.focus()})},l=function(a,b){a.removeClass("d-none");c.reset(b)},m=function(a,b){a.addClass("d-none");c.reset(b)};return{init:function init(b,c){b=a(b);i(b,c);j(b,c);k(b,c)}}});
//# sourceMappingURL=view_nav.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -51,7 +51,7 @@ function(
EVENT_LIST_WRAPPER: '[data-region="event-list-wrapper"]',
EVENT_LIST_LOADING_PLACEHOLDER: '[data-region="event-list-loading-placeholder"]',
TIMELINE_BLOCK: '[data-region="timeline"]',
TIMELINE_SEARCH: '[data-region="search-input"]',
TIMELINE_SEARCH: '[data-action="search"]',
MORE_ACTIVITIES_BUTTON: '[data-action="more-events"]',
MORE_ACTIVITIES_BUTTON_CONTAINER: '[data-region="more-events-button-container"]'
};

View File

@ -50,7 +50,7 @@ function(
COURSE_NAME: '[data-region="course-name"]',
LOADING_ICON: '.loading-icon',
TIMELINE_BLOCK: '[data-region="timeline"]',
TIMELINE_SEARCH: '[data-region="search-input"]'
TIMELINE_SEARCH: '[data-action="search"]'
};
var TEMPLATES = {

View File

@ -44,9 +44,8 @@ function(
TIMELINE_VIEW_SELECTOR: '[data-region="view-selector"]',
DATA_DAYS_OFFSET: '[data-days-offset]',
DATA_DAYS_LIMIT: '[data-days-limit]',
TIMELINE_SEARCH_INPUT: '[data-region="search-input"]',
TIMELINE_SEARCH_CLEAR_ICON: '[data-region="clear-icon"]',
TIMELINE_SEARCH_SEARCH_ICON: '[data-region="search-icon"]'
TIMELINE_SEARCH_INPUT: '[data-action="search"]',
TIMELINE_SEARCH_CLEAR_ICON: '[data-action="clearsearch"]',
};
/**
@ -158,44 +157,40 @@ function(
*/
const registerSearch = (root, timelineViewRoot) => {
const searchInput = root.find(SELECTORS.TIMELINE_SEARCH_INPUT);
const searchIcon = root.find(SELECTORS.TIMELINE_SEARCH_SEARCH_ICON);
const clearSearchIcon = root.find(SELECTORS.TIMELINE_SEARCH_CLEAR_ICON);
searchInput.on('input', Utils.debounce(() => {
if (searchInput.val() !== '') {
activeSearchState(searchIcon, clearSearchIcon, timelineViewRoot);
activeSearchState(clearSearchIcon, timelineViewRoot);
} else {
clearSearchState(searchIcon, clearSearchIcon, timelineViewRoot);
clearSearchState(clearSearchIcon, timelineViewRoot);
}
}, 300));
clearSearchIcon.on('click', () => {
searchInput.val('');
clearSearchState(searchIcon, clearSearchIcon, timelineViewRoot);
clearSearchState(clearSearchIcon, timelineViewRoot);
searchInput.focus();
});
};
/**
* Change the search icon to clear icon.
* Show the clear search icon.
*
* @param {object} searchIcon Search icon element.
* @param {object} clearSearchIcon Clear search icon element.
* @param {object} timelineViewRoot The root element for the timeline view
*/
const activeSearchState = (searchIcon, clearSearchIcon, timelineViewRoot) => {
searchIcon.addClass('d-none');
clearSearchIcon.parent().removeClass('d-none');
const activeSearchState = (clearSearchIcon, timelineViewRoot) => {
clearSearchIcon.removeClass('d-none');
View.reset(timelineViewRoot);
};
/**
* Change the clear search icon to search icon.
* Hide the clear search icon.
*
* @param {object} searchIcon Search icon element.
* @param {object} clearSearchIcon Clear search icon element.
* @param {object} timelineViewRoot The root element for the timeline view
*/
const clearSearchState = (searchIcon, clearSearchIcon, timelineViewRoot) => {
searchIcon.removeClass('d-none');
clearSearchIcon.parent().addClass('d-none');
const clearSearchState = (clearSearchIcon, timelineViewRoot) => {
clearSearchIcon.addClass('d-none');
View.reset(timelineViewRoot);
};

View File

@ -27,7 +27,6 @@ $string['ariadayfilteroption'] = '{$a} filter option';
$string['ariaeventlistitem'] = '{$a->name} activity in {$a->course} is due on {$a->date}';
$string['ariaviewselector'] = 'Sort timeline items';
$string['ariaviewselectoroption'] = '{$a} sort option';
$string['clearsearch'] = 'Clear search';
$string['duedate'] = 'Due date';
$string['moreactivities'] = 'Show more activities';
$string['morecourses'] = 'Show more courses';

View File

@ -1,3 +1,12 @@
#block-region-side-pre .block_timeline .nav-search {
flex: 0 0 100%;
max-width: 100%;
}
.block_timeline .input-group.searchbar {
width: 100%;
}
#block-region-side-pre .block_timeline h6.event-action {
flex-basis: 100%;
}

View File

@ -32,7 +32,7 @@
<div class="mr-auto mb-1">
{{> block_timeline/nav-view-selector }}
</div>
<div class="col-md-6 col-sm-8 col-12 mb-1 d-flex justify-content-end">
<div class="col-md-6 col-sm-8 col-12 mb-1 d-flex justify-content-end nav-search">
{{> block_timeline/nav-search }}
</div>
</div>

View File

@ -22,26 +22,13 @@
Example context (json):
{}
}}
<div class="searchbar input-group mb-3" role='search'>
<label for='timelinesearchinput'>
<span class='sr-only'>{{#str}} searchevents, block_timeline {{/str}}</span>
</label>
<input type="text"
data-region="search-input"
id="timelinesearchinput"
class="form-control"
placeholder="{{#str}} searchevents, block_timeline {{/str}}"
name="search"
autocomplete="off">
<div class="input-group-append">
<div data-region="search-icon" class="input-group-text">
{{#pix}} a/search, core {{/pix}}
</div>
<div class="clear input-group d-none">
<button class="btn btn-outline-secondary" type="button" data-region="clear-icon">
<span class="d-flex" aria-hidden="true">{{#pix}} e/cancel, core {{/pix}}</span>
<span class="sr-only">{{#str}} clearsearch, block_timeline {{/str}}</span>
</button>
</div>
</div>
<div class="w-100">
{{< core/search_input_auto }}
{{$label}}{{#str}}
searchevents, block_timeline
{{/str}}{{/label}}
{{$placeholder}}{{#str}}
searchevents, block_timeline
{{/str}}{{/placeholder}}
{{/ core/search_input_auto }}
</div>

View File

@ -33,14 +33,14 @@ Feature: The timeline block allows users to search for upcoming activities
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
When I set the field "Search by activity type or name" to "Fake example"
When I set the field "Search" in the "Timeline" "block" to "Fake example"
Then I should see "No activities require action" in the "Timeline" "block"
Scenario: Search for Course name
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
When I set the field "Search by activity type or name" to "Course 1"
When I set the field "Search" in the "Timeline" "block" to "Course 1"
Then I should see "Test choice 2" in the "Timeline" "block"
And I should see "Test choice 5" in the "Timeline" "block"
And I should see "Test feedback 2" in the "Timeline" "block"
@ -54,7 +54,7 @@ Feature: The timeline block allows users to search for upcoming activities
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
When I set the field "Search by activity type or name" to "Test choice 1"
When I set the field "Search" in the "Timeline" "block" to "Test choice 1"
And I wait until "Test choice 2" "text" does not exist
Then I should see "Test choice 1" in the "Timeline" "block"
And I should not see "Test choice 2" in the "Timeline" "block"
@ -70,7 +70,7 @@ Feature: The timeline block allows users to search for upcoming activities
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
When I set the field "Search by activity type or name" to "feedback"
When I set the field "Search" in the "Timeline" "block" to "feedback"
Then I should see "Test feedback 1" in the "Timeline" "block"
And I should see "Test feedback 2" in the "Timeline" "block"
And I should see "Test feedback 3" in the "Timeline" "block"
@ -84,7 +84,7 @@ Feature: The timeline block allows users to search for upcoming activities
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
When I set the field "Search by activity type or name" to "choice"
When I set the field "Search" in the "Timeline" "block" to "choice"
Then I should see "Test choice 1" in the "Timeline" "block"
And I should see "Test choice 2" in the "Timeline" "block"
And I should see "Test choice 3" in the "Timeline" "block"