mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Merge branch 'MDL-69336-master' of git://github.com/mickhawkins/moodle
This commit is contained in:
commit
98579dd7b3
5 changed files with 65 additions and 18 deletions
2
lib/table/amd/build/dynamic.min.js
vendored
2
lib/table/amd/build/dynamic.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -336,12 +336,13 @@ export const getLastInitial = tableRoot => getTableData(tableRoot).tableLastInit
|
||||||
* @param {HTMLElement} tableRoot
|
* @param {HTMLElement} tableRoot
|
||||||
* @param {String} columnToHide
|
* @param {String} columnToHide
|
||||||
* @param {Bool} refreshContent
|
* @param {Bool} refreshContent
|
||||||
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
export const hideColumn = (tableRoot, columnToHide, refreshContent = true) => {
|
export const hideColumn = (tableRoot, columnToHide, refreshContent = true) => {
|
||||||
const hiddenColumns = JSON.parse(tableRoot.dataset.tableHiddenColumns);
|
const hiddenColumns = JSON.parse(tableRoot.dataset.tableHiddenColumns);
|
||||||
hiddenColumns.push(columnToHide);
|
hiddenColumns.push(columnToHide);
|
||||||
|
|
||||||
updateTable(tableRoot, {hiddenColumns}, refreshContent);
|
return updateTable(tableRoot, {hiddenColumns}, refreshContent);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -350,12 +351,13 @@ export const hideColumn = (tableRoot, columnToHide, refreshContent = true) => {
|
||||||
* @param {HTMLElement} tableRoot
|
* @param {HTMLElement} tableRoot
|
||||||
* @param {String} columnToShow
|
* @param {String} columnToShow
|
||||||
* @param {Bool} refreshContent
|
* @param {Bool} refreshContent
|
||||||
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
export const showColumn = (tableRoot, columnToShow, refreshContent = true) => {
|
export const showColumn = (tableRoot, columnToShow, refreshContent = true) => {
|
||||||
let hiddenColumns = JSON.parse(tableRoot.dataset.tableHiddenColumns);
|
let hiddenColumns = JSON.parse(tableRoot.dataset.tableHiddenColumns);
|
||||||
hiddenColumns = hiddenColumns.filter(columnName => columnName !== columnToShow);
|
hiddenColumns = hiddenColumns.filter(columnName => columnName !== columnToShow);
|
||||||
|
|
||||||
updateTable(tableRoot, {hiddenColumns}, refreshContent);
|
return updateTable(tableRoot, {hiddenColumns}, refreshContent);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1444,23 +1444,19 @@ class flexible_table {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now, update the column attributes for collapsed columns
|
$this->set_hide_show_preferences();
|
||||||
foreach (array_keys($this->columns) as $column) {
|
|
||||||
if (!empty($this->prefs['collapse'][$column])) {
|
|
||||||
$this->column_style[$column]['width'] = '10px';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now, update the column attributes for collapsed columns
|
|
||||||
foreach (array_keys($this->columns) as $column) {
|
|
||||||
if (!empty($this->prefs['collapse'][$column])) {
|
|
||||||
$this->column_style[$column]['width'] = '10px';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->set_sorting_preferences();
|
$this->set_sorting_preferences();
|
||||||
$this->set_initials_preferences();
|
$this->set_initials_preferences();
|
||||||
|
|
||||||
|
// Now, reduce the width of collapsed columns and remove the width from columns that should be expanded.
|
||||||
|
foreach (array_keys($this->columns) as $column) {
|
||||||
|
if (!empty($this->prefs['collapse'][$column])) {
|
||||||
|
$this->column_style[$column]['width'] = '10px';
|
||||||
|
} else {
|
||||||
|
unset($this->column_style[$column]['width']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($this->baseurl)) {
|
if (empty($this->baseurl)) {
|
||||||
debugging('You should set baseurl when using flexible_table.');
|
debugging('You should set baseurl when using flexible_table.');
|
||||||
global $PAGE;
|
global $PAGE;
|
||||||
|
|
49
user/tests/behat/table_column_visibility.feature
Normal file
49
user/tests/behat/table_column_visibility.feature
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
@core @core_user
|
||||||
|
Feature: The visibility of table columns can be toggled
|
||||||
|
In order to customise my view of participants data
|
||||||
|
As a user
|
||||||
|
I need to be able to hide and show columns in the participants table
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given the following "courses" exist:
|
||||||
|
| fullname | shortname | category | groupmode |
|
||||||
|
| Course 1 | C1 | 0 | 1 |
|
||||||
|
And the following "users" exist:
|
||||||
|
| username | firstname | lastname | email |
|
||||||
|
| t1 | Agatha | T | agatha@example.com |
|
||||||
|
| s1 | Matilda | W | matilda@example.com |
|
||||||
|
| s2 | Mick | H | mick@example.com |
|
||||||
|
And the following "course enrolments" exist:
|
||||||
|
| user | course | role |
|
||||||
|
| t1 | C1 | editingteacher |
|
||||||
|
| s1 | C1 | student |
|
||||||
|
| s2 | C1 | student |
|
||||||
|
|
||||||
|
@javascript
|
||||||
|
Scenario: The visibility of columns can be individually toggled within the participants table
|
||||||
|
Given I log in as "t1"
|
||||||
|
And I am on "Course 1" course homepage
|
||||||
|
And I navigate to course participants
|
||||||
|
And I should see "Email address" in the "participants" "table"
|
||||||
|
And I should see "matilda@example.com" in the "participants" "table"
|
||||||
|
And I should see "Roles" in the "participants" "table"
|
||||||
|
And I should see "Student" in the "participants" "table"
|
||||||
|
When I follow "Hide Email address"
|
||||||
|
Then I should not see "Email address" in the "participants" "table"
|
||||||
|
And I should not see "matilda@example.com" in the "participants" "table"
|
||||||
|
And I should see "Roles" in the "participants" "table"
|
||||||
|
And I should see "Student" in the "participants" "table"
|
||||||
|
And I follow "Hide Roles"
|
||||||
|
And I should not see "Roles" in the "participants" "table"
|
||||||
|
And I should not see "Student" in the "participants" "table"
|
||||||
|
And I should not see "matilda@example.com" in the "participants" "table"
|
||||||
|
And I follow "Show Email address"
|
||||||
|
And I should see "Email address" in the "participants" "table"
|
||||||
|
And I should see "matilda@example.com" in the "participants" "table"
|
||||||
|
And I should not see "Roles" in the "participants" "table"
|
||||||
|
And I should not see "Student" in the "participants" "table"
|
||||||
|
And I follow "Show Roles"
|
||||||
|
And I should see "Roles" in the "participants" "table"
|
||||||
|
And I should see "Student" in the "participants" "table"
|
||||||
|
And I should see "Email address" in the "participants" "table"
|
||||||
|
And I should see "matilda@example.com" in the "participants" "table"
|
Loading…
Add table
Add a link
Reference in a new issue