Commit 01f89499 authored by ilya's avatar ilya
Browse files

Merge branch 'MDL-73011' of https://github.com/paulholden/moodle

parents 5efc19da c0ceaef7
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment