Merge branch 'MDL-73011' of https://github.com/paulholden/moodle
This commit is contained in:
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("core/dynamic_tabs",["exports","jquery","core/templates","core/notification","core/pending","core/str","core/local/repository/dynamic_tabs","core_form/changechecker"],function(a,b,c,d,e,f,g,h){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=i(b);c=i(c);d=i(d);e=i(e);function i(a){return a&&a.__esModule?a:{default:a}}function j(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);if(b)d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable});c.push.apply(c,d)}return c}function k(a){for(var b=1,c;b<arguments.length;b++){c=null!=arguments[b]?arguments[b]:{};if(b%2){j(Object(c),!0).forEach(function(b){l(a,b,c[b])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(a,Object.getOwnPropertyDescriptors(c))}else{j(Object(c)).forEach(function(b){Object.defineProperty(a,b,Object.getOwnPropertyDescriptor(c,b))})}}return a}function l(a,b,c){if(b in a){Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0})}else{a[b]=c}return a}function m(a,b){return r(a)||q(a,b)||o(a,b)||n()}function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(a,b){if(!a)return;if("string"==typeof a)return p(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return p(a,b)}function p(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);c<b;c++){d[c]=a[c]}return d}function q(a,b){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(a)))return;var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function r(a){if(Array.isArray(a))return a}var s={dynamicTabs:".dynamictabs",activeTab:".dynamictabs .nav-link.active",allActiveTabs:".dynamictabs .nav-link[data-toggle=\"tab\"]:not(.disabled)",tabContent:".dynamictabs .tab-pane [data-tab-content]",tabToggle:"a[data-toggle=\"tab\"]",tabPane:".dynamictabs .tab-pane",forTabName:function(a){return".dynamictabs [data-tab-content=\"".concat(a,"\"]")},forTabId:function(a){return".dynamictabs [data-toggle=\"tab\"][href=\"#".concat(a,"\"]")}},t=function(){var a=(0,b.default)(s.tabToggle);a.on("click",function(a){if(!(0,h.isAnyWatchedFormDirty)()){return}a.preventDefault();a.stopPropagation();(0,f.get_strings)([{key:"changesmade",component:"moodle"},{key:"changesmadereallygoaway",component:"moodle"},{key:"confirm",component:"moodle"}]).then(function(c){var e=m(c,3),f=e[0],g=e[1],i=e[2];return d.default.confirm(f,g,i,null,function(){(0,h.resetAllFormDirtyStates)();(0,b.default)(a.target).trigger(a.type)})}).catch(d.default.exception)});a.on("shown.bs.tab",function(){var a=(0,b.default)((0,b.default)(this).attr("href"));if(1!==a.length){return}x(a.attr("id"))});if(!B()){var c=document.querySelector(s.allActiveTabs);if(c){A(c.getAttribute("aria-controls"))}else{var e=document.querySelector(s.tabPane);if(e){e.classList.add("active","show");x(e.getAttribute("id"))}}}};a.init=t;var u=function(a){return c.default.render("core/loading",{}).then(function(b,d){return c.default.replaceNodeContents(a,b,d)}).catch(d.default.exception)},v=function(){var a=document.querySelector(s.activeTab);return(null===a||void 0===a?void 0:a.getAttribute("aria-controls"))||null},w=function(){var a=document.querySelector(s.tabContent);return(null===a||void 0===a?void 0:a.dataset.tabContent)||null},x=function(a){var b,f,h=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{};a=null!==(b=null!==(f=a)&&void 0!==f?f:v())&&void 0!==b?b:w();var i=document.querySelector(s.forTabName(a));if(!i){return}var j=new e.default("core/dynamic_tabs:loadTab:"+a),l=i.closest(s.dynamicTabs),m=k({reportid:l.dataset.reportid,id:l.dataset.id},h),n="";i.textContent="";u(i).then(function(){return(0,g.getContent)(i.dataset.tabClass,JSON.stringify(m))}).then(function(a){n=a.javascript;return c.default.render(a.template,JSON.parse(a.content))}).then(function(a,b){return c.default.replaceNodeContents(i,a,b+n)}).then(function(){j.resolve();return null}).catch(d.default.exception)},y=function(a){return document.querySelector(s.forTabId(a))},z=function(a){return document.getElementById(a)},A=function(a){var b=y(a);if(!b){return!1}x(a);b.classList.add("active");z(a).classList.add("active","show");return!0},B=function(){var a=document.location.hash;if(a.match(/^#\w+$/g)){return A(a.replace(/^#/g,""))}return!1}});
|
||||
define ("core/dynamic_tabs",["exports","jquery","core/templates","core/loadingicon","core/notification","core/pending","core/str","core/local/repository/dynamic_tabs","core_form/changechecker"],function(a,b,c,d,e,f,g,h,i){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=j(b);c=j(c);e=j(e);f=j(f);function j(a){return a&&a.__esModule?a:{default:a}}function k(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);if(b)d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable});c.push.apply(c,d)}return c}function l(a){for(var b=1,c;b<arguments.length;b++){c=null!=arguments[b]?arguments[b]:{};if(b%2){k(Object(c),!0).forEach(function(b){m(a,b,c[b])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(a,Object.getOwnPropertyDescriptors(c))}else{k(Object(c)).forEach(function(b){Object.defineProperty(a,b,Object.getOwnPropertyDescriptor(c,b))})}}return a}function m(a,b,c){if(b in a){Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0})}else{a[b]=c}return a}function n(a,b){return s(a)||r(a,b)||p(a,b)||o()}function o(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(a,b){if(!a)return;if("string"==typeof a)return q(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return q(a,b)}function q(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);c<b;c++){d[c]=a[c]}return d}function r(a,b){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(a)))return;var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function s(a){if(Array.isArray(a))return a}var t={dynamicTabs:".dynamictabs",activeTab:".dynamictabs .nav-link.active",allActiveTabs:".dynamictabs .nav-link[data-toggle=\"tab\"]:not(.disabled)",tabContent:".dynamictabs .tab-pane [data-tab-content]",tabToggle:"a[data-toggle=\"tab\"]",tabPane:".dynamictabs .tab-pane",forTabName:function(a){return".dynamictabs [data-tab-content=\"".concat(a,"\"]")},forTabId:function(a){return".dynamictabs [data-toggle=\"tab\"][href=\"#".concat(a,"\"]")}},u=function(){var a=(0,b.default)(t.tabToggle);a.on("click",function(a){if(!(0,i.isAnyWatchedFormDirty)()){return}a.preventDefault();a.stopPropagation();(0,g.get_strings)([{key:"changesmade",component:"moodle"},{key:"changesmadereallygoaway",component:"moodle"},{key:"confirm",component:"moodle"}]).then(function(c){var d=n(c,3),f=d[0],g=d[1],h=d[2];return e.default.confirm(f,g,h,null,function(){(0,i.resetAllFormDirtyStates)();(0,b.default)(a.target).trigger(a.type)})}).catch(e.default.exception)});a.on("show.bs.tab",function(){var a=v();if(a){var b=document.querySelector(t.forTabName(a));b.textContent=""}}).on("shown.bs.tab",function(){var a=(0,b.default)((0,b.default)(this).attr("href"));if(1!==a.length){return}x(a.attr("id"))});if(!B()){var c=document.querySelector(t.allActiveTabs);if(c){A(c.getAttribute("aria-controls"))}else{var d=document.querySelector(t.tabPane);if(d){d.classList.add("active","show");x(d.getAttribute("id"))}}}};a.init=u;var v=function(){var a=document.querySelector(t.activeTab);return(null===a||void 0===a?void 0:a.getAttribute("aria-controls"))||null},w=function(){var a=document.querySelector(t.tabContent);return(null===a||void 0===a?void 0:a.dataset.tabContent)||null},x=function(a){var b,g,i=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{};a=null!==(b=null!==(g=a)&&void 0!==g?g:v())&&void 0!==b?b:w();var j=document.querySelector(t.forTabName(a));if(!j){return}var k=new f.default("core/dynamic_tabs:loadTab:"+a),m=j.closest(t.dynamicTabs),n=l({reportid:m.dataset.reportid,id:m.dataset.id},i),o="";(0,d.addIconToContainer)(j).then(function(){return(0,h.getContent)(j.dataset.tabClass,JSON.stringify(n))}).then(function(a){o=a.javascript;return c.default.render(a.template,JSON.parse(a.content))}).then(function(a,b){return c.default.replaceNodeContents(j,a,b+o)}).then(function(){k.resolve();return null}).catch(e.default.exception)},y=function(a){return document.querySelector(t.forTabId(a))},z=function(a){return document.getElementById(a)},A=function(a){var b=y(a);if(!b){return!1}x(a);b.classList.add("active");z(a).classList.add("active","show");return!0},B=function(){var a=document.location.hash;if(a.match(/^#\w+$/g)){return A(a.replace(/^#/g,""))}return!1}});
|
||||
//# sourceMappingURL=dynamic_tabs.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
+19
-23
@@ -23,6 +23,7 @@
|
||||
|
||||
import $ from 'jquery';
|
||||
import Templates from 'core/templates';
|
||||
import {addIconToContainer} from 'core/loadingicon';
|
||||
import Notification from 'core/notification';
|
||||
import Pending from 'core/pending';
|
||||
import {get_strings as getStrings} from 'core/str';
|
||||
@@ -69,15 +70,24 @@ export const init = () => {
|
||||
).catch(Notification.exception);
|
||||
});
|
||||
|
||||
// This code listens to Bootstrap event 'shown.bs.tab' which is triggered using JQuery and
|
||||
// This code listens to Bootstrap events 'show.bs.tab' and 'shown.bs.tab' which is triggered using JQuery and
|
||||
// can not be converted yet to native events.
|
||||
tabToggle.on('shown.bs.tab', function() {
|
||||
const tab = $($(this).attr('href'));
|
||||
if (tab.length !== 1) {
|
||||
return;
|
||||
}
|
||||
loadTab(tab.attr('id'));
|
||||
});
|
||||
tabToggle
|
||||
.on('show.bs.tab', function() {
|
||||
// Clean content from previous tab.
|
||||
const previousTabName = getActiveTabName();
|
||||
if (previousTabName) {
|
||||
const previousTab = document.querySelector(SELECTORS.forTabName(previousTabName));
|
||||
previousTab.textContent = '';
|
||||
}
|
||||
})
|
||||
.on('shown.bs.tab', function() {
|
||||
const tab = $($(this).attr('href'));
|
||||
if (tab.length !== 1) {
|
||||
return;
|
||||
}
|
||||
loadTab(tab.attr('id'));
|
||||
});
|
||||
|
||||
if (!openTabFromHash()) {
|
||||
const tabs = document.querySelector(SELECTORS.allActiveTabs);
|
||||
@@ -94,19 +104,6 @@ export const init = () => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Show "loading" template instead of a node
|
||||
*
|
||||
* @param {HTMLElement} node
|
||||
* @return {Promise}
|
||||
*/
|
||||
const indicateNodeIsLoading = (node) => {
|
||||
return Templates.render('core/loading', {})
|
||||
.then((html, js) => {
|
||||
return Templates.replaceNodeContents(node, html, js);
|
||||
}).catch(Notification.exception);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns id/name of the currently active tab
|
||||
*
|
||||
@@ -150,9 +147,8 @@ const loadTab = (tabName, additionalData = {}) => {
|
||||
...additionalData
|
||||
};
|
||||
let tabjs = '';
|
||||
tab.textContent = '';
|
||||
|
||||
indicateNodeIsLoading(tab)
|
||||
addIconToContainer(tab)
|
||||
.then(() => {
|
||||
return getContent(tab.dataset.tabClass, JSON.stringify(wsData));
|
||||
})
|
||||
|
||||
@@ -31,17 +31,16 @@ Feature: Configure access to reports based on intended audience
|
||||
Then I click on "Add audience 'Manually added users'" "link"
|
||||
And I should see "Added audience 'Manually added users'"
|
||||
And I set the field "Add users manually" to "User 1,User 3"
|
||||
# It would be better to reference the report table directly, but we can't because of MDL-73011.
|
||||
And I click on "Save changes" "button" in the "[role=tabpanel].active" "css_element"
|
||||
And I press "Save changes"
|
||||
And I should see "Audience saved"
|
||||
And I should see "User 1"
|
||||
And I should not see "User 2"
|
||||
And I should see "User 3"
|
||||
And I should not see "Add an audience to this report"
|
||||
And I click on the "Access" dynamic tab
|
||||
And I should see "User 1" in the "[role=tabpanel].active" "css_element"
|
||||
And I should not see "User 2" in the "[role=tabpanel].active" "css_element"
|
||||
And I should see "User 3" in the "[role=tabpanel].active" "css_element"
|
||||
And I should see "User 1" in the "reportbuilder-table" "table"
|
||||
And I should not see "User 2" in the "reportbuilder-table" "table"
|
||||
And I should see "User 3" in the "reportbuilder-table" "table"
|
||||
|
||||
Scenario: Configure report audience with has system role audience type
|
||||
Given the following "roles" exist:
|
||||
@@ -55,15 +54,14 @@ Feature: Configure access to reports based on intended audience
|
||||
When I click on "Add audience 'Assigned system role'" "link"
|
||||
And I should see "Added audience 'Assigned system role'"
|
||||
And I set the field "Select a role" to "Test role"
|
||||
# It would be better to reference the report table directly, but we can't because of MDL-73011.
|
||||
And I click on "Save changes" "button" in the "[role=tabpanel].active" "css_element"
|
||||
And I press "Save changes"
|
||||
Then I should see "Audience saved"
|
||||
And I should see "Test role"
|
||||
And I should not see "Add an audience to this report"
|
||||
And I click on the "Access" dynamic tab
|
||||
And I should not see "User 1" in the "[role=tabpanel].active" "css_element"
|
||||
And I should see "User 2" in the "[role=tabpanel].active" "css_element"
|
||||
And I should not see "User 3" in the "[role=tabpanel].active" "css_element"
|
||||
And I should not see "User 1" in the "reportbuilder-table" "table"
|
||||
And I should see "User 2" in the "reportbuilder-table" "table"
|
||||
And I should not see "User 3" in the "reportbuilder-table" "table"
|
||||
|
||||
Scenario: Configure report audience with Member of cohort audience type
|
||||
Given the following "cohorts" exist:
|
||||
@@ -77,19 +75,18 @@ Feature: Configure access to reports based on intended audience
|
||||
When I click on "Add audience 'Member of cohort'" "link"
|
||||
And I should see "Added audience 'Member of cohort'"
|
||||
And I set the field "Select members from cohort" to "Cohort1"
|
||||
# It would be better to reference the report table directly, but we can't because of MDL-73011.
|
||||
And I click on "Save changes" "button" in the "[role=tabpanel].active" "css_element"
|
||||
And I press "Save changes"
|
||||
Then I should see "Audience saved"
|
||||
And I should see "Cohort1"
|
||||
And I should not see "Add an audience to this report"
|
||||
And I click on the "Access" dynamic tab
|
||||
And I should not see "User 1" in the "[role=tabpanel].active" "css_element"
|
||||
And I should not see "User 2" in the "[role=tabpanel].active" "css_element"
|
||||
And I should see "User 3" in the "[role=tabpanel].active" "css_element"
|
||||
And I should not see "User 1" in the "reportbuilder-table" "table"
|
||||
And I should not see "User 2" in the "reportbuilder-table" "table"
|
||||
And I should see "User 3" in the "reportbuilder-table" "table"
|
||||
|
||||
Scenario: Configure report audience with Member of cohort audience type with no cohorts available
|
||||
Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
|
||||
And I click on the "Audience" dynamic tab
|
||||
When I click on the "Audience" dynamic tab
|
||||
Then "Add audience 'All users'" "link" should exist
|
||||
# This audience type should be disabled because there are no cohorts available.
|
||||
And "Add audience 'Member of cohort'" "link" should not exist
|
||||
@@ -98,8 +95,7 @@ Feature: Configure access to reports based on intended audience
|
||||
Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
|
||||
And I click on the "Audience" dynamic tab
|
||||
And I click on "Add audience 'All users'" "link"
|
||||
# It would be better to reference the report table directly, but we can't because of MDL-73011.
|
||||
And I click on "Save changes" "button" in the "[role=tabpanel].active" "css_element"
|
||||
And I press "Save changes"
|
||||
When I click on "Delete audience 'All users'" "button"
|
||||
And I click on "Delete" "button" in the "Delete audience 'All users'" "dialogue"
|
||||
Then I should see "Deleted audience 'All users'"
|
||||
@@ -111,21 +107,20 @@ Feature: Configure access to reports based on intended audience
|
||||
And I should see "Nothing to display"
|
||||
And I click on the "Audience" dynamic tab
|
||||
And I should see "Add an audience to this report"
|
||||
Then I click on "Add audience 'Manually added users'" "link"
|
||||
And I click on "Add audience 'Manually added users'" "link"
|
||||
And I set the field "Add users manually" to "User 1,User 3"
|
||||
# It would be better to reference the report table directly, but we can't because of MDL-73011.
|
||||
And I click on "Save changes" "button" in the "[role=tabpanel].active" "css_element"
|
||||
And I press "Edit audience 'Manually added users'"
|
||||
And I press "Save changes"
|
||||
When I press "Edit audience 'Manually added users'"
|
||||
And I set the field "Add users manually" to "User 2"
|
||||
And I click on "Save changes" "button" in the "[role=tabpanel].active" "css_element"
|
||||
And I should see "Audience saved"
|
||||
And I should not see "User 1" in the "[role=tabpanel].active" "css_element"
|
||||
And I should see "User 2" in the "[role=tabpanel].active" "css_element"
|
||||
And I should not see "User 3" in the "[role=tabpanel].active" "css_element"
|
||||
And I press "Save changes"
|
||||
Then I should see "Audience saved"
|
||||
And I should not see "User 1"
|
||||
And I should see "User 2"
|
||||
And I should not see "User 3"
|
||||
And I click on the "Access" dynamic tab
|
||||
And I should not see "User 1" in the "[role=tabpanel].active" "css_element"
|
||||
And I should see "User 2" in the "[role=tabpanel].active" "css_element"
|
||||
And I should not see "User 3" in the "[role=tabpanel].active" "css_element"
|
||||
And I should not see "User 1" in the "reportbuilder-table" "table"
|
||||
And I should see "User 2" in the "reportbuilder-table" "table"
|
||||
And I should not see "User 3" in the "reportbuilder-table" "table"
|
||||
|
||||
Scenario: View report as a user with no edit capability and set in the report audience
|
||||
Given the following "core_reportbuilder > Reports" exist:
|
||||
@@ -156,8 +151,7 @@ Feature: Configure access to reports based on intended audience
|
||||
And I should see "Add an audience to this report"
|
||||
Then I click on "Add audience 'Manually added users'" "link"
|
||||
And I set the field "Add users manually" to "User 1"
|
||||
# It would be better to reference the report table directly, but we can't because of MDL-73011.
|
||||
And I click on "Save changes" "button" in the "[role=tabpanel].active" "css_element"
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
And I log in as "user1"
|
||||
And I navigate to "Reports > Report builder > Custom reports" in site administration
|
||||
@@ -201,8 +195,7 @@ Feature: Configure access to reports based on intended audience
|
||||
And I should see "Add an audience to this report"
|
||||
Then I click on "Add audience 'Manually added users'" "link"
|
||||
And I set the field "Add users manually" to "User 1"
|
||||
# It would be better to reference the report table directly, but we can't because of MDL-73011.
|
||||
And I click on "Save changes" "button" in the "[role=tabpanel].active" "css_element"
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
And I log in as "user1"
|
||||
And I navigate to "Reports > Report builder > Custom reports" in site administration
|
||||
|
||||
Reference in New Issue
Block a user