mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-33671 core: Remove custom behat selectors
Co-authored-by: Andrew Nicols <andrew@nicols.co.uk>
This commit is contained in:
parent
a216d86c6c
commit
06dc3a6c27
@ -114,7 +114,8 @@ class core_files_renderer extends plugin_renderer_base {
|
||||
array('unknownoriginal', 'repository'), array('confirmdeletefolder', 'repository'),
|
||||
array('confirmdeletefilewithhref', 'repository'), array('confirmrenamefolder', 'repository'),
|
||||
array('confirmrenamefile', 'repository'), array('newfolder', 'repository'), array('edit', 'moodle'),
|
||||
['nofilesselected', 'repository'], ['confirmdeleteselectedfile', 'repository']
|
||||
['nofilesselected', 'repository'], ['confirmdeleteselectedfile', 'repository'],
|
||||
['selectall', 'moodle'], ['deselectall', 'moodle'], ['selectallornone', 'form'],
|
||||
)
|
||||
);
|
||||
if ($this->page->requires->should_create_one_time_item_now('core_file_managertemplate')) {
|
||||
|
@ -221,20 +221,23 @@ class behat_field_manager {
|
||||
}
|
||||
|
||||
// If the type is explictly set on the element pointed to by the label - use it.
|
||||
if ($type = $fieldnode->getParent()->getAttribute('data-fieldtype')) {
|
||||
if ($type == 'tags') {
|
||||
$fieldtype = $fieldnode->getAttribute('data-fieldtype');
|
||||
if ($fieldtype) {
|
||||
if ($fieldtype == 'tags') {
|
||||
return 'autocomplete';
|
||||
}
|
||||
return $type;
|
||||
return $fieldtype;
|
||||
}
|
||||
|
||||
if (!empty($fieldnode->find('xpath', '/ancestor::*[@data-passwordunmaskid]'))) {
|
||||
return 'passwordunmask';
|
||||
}
|
||||
|
||||
// We look for a parent node with 'felement' class.
|
||||
if ($class = $fieldnode->getParent()->getAttribute('class')) {
|
||||
// Fetch the parentnode only once.
|
||||
$parentnode = $fieldnode->getParent();
|
||||
|
||||
// We look for a parent node with 'felement' class.
|
||||
if ($class = $parentnode->getAttribute('class')) {
|
||||
if (strstr($class, 'felement') != false) {
|
||||
// Remove 'felement f' from class value.
|
||||
return substr($class, 10);
|
||||
@ -246,7 +249,7 @@ class behat_field_manager {
|
||||
}
|
||||
}
|
||||
|
||||
return self::get_field_node_type($fieldnode->getParent(), $session);
|
||||
return self::get_field_node_type($parentnode, $session);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -270,7 +270,7 @@ M.form_filemanager.init = function(Y, options) {
|
||||
return this.filemanager.ancestor('.fitem.disabled') != null;
|
||||
},
|
||||
getSelectedFiles: function() {
|
||||
var markedFiles = this.filemanager.all('.mark-for-selection:checked');
|
||||
var markedFiles = this.filemanager.all('[data-togglegroup=file-selections]:checked');
|
||||
var filenames = [];
|
||||
markedFiles.each(function(item) {
|
||||
var fileinfo = this.options.list.find(function(element) {
|
||||
@ -437,6 +437,7 @@ M.form_filemanager.init = function(Y, options) {
|
||||
var params = {
|
||||
selected: Y.JSON.stringify(filenames)
|
||||
};
|
||||
dialogOptions.header = M.util.get_string('confirm', 'moodle');
|
||||
dialogOptions.message = M.util.get_string('confirmdeleteselectedfile', 'repository', filenames.length);
|
||||
dialogOptions.callbackargs = [params];
|
||||
dialogOptions.callback = function(params) {
|
||||
@ -846,6 +847,7 @@ M.form_filemanager.init = function(Y, options) {
|
||||
node.one('.fp-dlg-butcancel').on('click', handle_cancel, this);
|
||||
}
|
||||
this.confirm_dlg.dlgopt = dialog_options;
|
||||
this.confirm_dlg.set('headerContent', dialog_options.header);
|
||||
this.confirm_dlg_node.one('.fp-dlg-text').setContent(dialog_options.message);
|
||||
this.confirm_dlg.show();
|
||||
},
|
||||
|
@ -325,17 +325,26 @@ YUI.add('moodle-core_filepicker', function(Y) {
|
||||
*/
|
||||
var formatCheckbox = function(o) {
|
||||
var el = Y.Node.create('<div/>');
|
||||
var checkbox = Y.Node.create('<input/>');
|
||||
checkbox.setAttribute('type', 'checkbox')
|
||||
.setAttribute('class', 'mark-for-selection')
|
||||
|
||||
var checkbox = Y.Node.create('<input/>')
|
||||
.setAttribute('type', 'checkbox')
|
||||
.setAttribute('data-fieldtype', 'checkbox')
|
||||
.setAttribute('data-fullname', o.data.fullname)
|
||||
.setAttribute('data-action', 'toggle')
|
||||
.setAttribute('data-toggle', 'slave')
|
||||
.setAttribute('data-togglegroup', 'file-selections')
|
||||
.setAttribute('data-toggle-selectall', 'Select all')
|
||||
.setAttribute('data-toggle-deselectall', 'Deselectall');
|
||||
.setAttribute('data-toggle-selectall', M.util.get_string('selectall', 'moodle'))
|
||||
.setAttribute('data-toggle-deselectall', M.util.get_string('deselectall', 'moodle'));
|
||||
|
||||
var checkboxLabel = Y.Node.create('<label>')
|
||||
.setHTML("Select file '" + o.data.fullname + "'")
|
||||
.addClass('sr-only')
|
||||
.setAttrs({
|
||||
for: checkbox.generateID(),
|
||||
});
|
||||
|
||||
el.appendChild(checkbox);
|
||||
el.appendChild(checkboxLabel);
|
||||
return el.getContent();
|
||||
};
|
||||
/** sorting function for table view */
|
||||
@ -363,20 +372,32 @@ YUI.add('moodle-core_filepicker', function(Y) {
|
||||
];
|
||||
|
||||
// Generate a checkbox based on toggleall's specification
|
||||
var checkbox = Y.Node.create('<input/>');
|
||||
var div = Y.Node.create('<div/>');
|
||||
checkbox.setAttribute('type', 'checkbox')
|
||||
.setAttribute('class', 'mark-for-selection')
|
||||
var checkbox = Y.Node.create('<input/>')
|
||||
.setAttribute('type', 'checkbox')
|
||||
// .setAttribute('title', M.util.get_string('selectallornone', 'form'))
|
||||
.setAttribute('data-action', 'toggle')
|
||||
.setAttribute('data-toggle', 'master')
|
||||
.setAttribute('data-togglegroup', 'file-selections');
|
||||
|
||||
var checkboxLabel = Y.Node.create('<label>')
|
||||
.setHTML(M.util.get_string('selectallornone', 'form'))
|
||||
.addClass('sr-only')
|
||||
.setAttrs({
|
||||
for: checkbox.generateID(),
|
||||
});
|
||||
|
||||
div.appendChild(checkboxLabel);
|
||||
div.appendChild(checkbox);
|
||||
|
||||
|
||||
// Enable the selectable checkboxes
|
||||
if (options.disablecheckboxes != undefined && !options.disablecheckboxes) {
|
||||
cols.unshift({
|
||||
key: "", label: div.getContent(),
|
||||
allowHTML: true, formatter: formatCheckbox,
|
||||
key: "",
|
||||
label: div.getContent(),
|
||||
allowHTML: true,
|
||||
formatter: formatCheckbox,
|
||||
sortable: false
|
||||
});
|
||||
}
|
||||
|
@ -176,38 +176,6 @@ class behat_filepicker extends behat_base {
|
||||
$okbutton->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks for deletion the specified file or folder from the specified filemanager field.
|
||||
*
|
||||
* @Given /^I mark for deletion "(?P<file_or_folder_name_string>(?:[^"]|\\")*)" from filemanager$/
|
||||
* @throws ExpectationException Thrown by behat_base::find
|
||||
* @param string $name
|
||||
*/
|
||||
public function i_mark_for_deletion_from_filemanager($name) {
|
||||
$name = behat_context_helper::escape($name);
|
||||
$okbutton = $this->find('css', "input.mark-for-selection[data-fullname=$name]");
|
||||
$okbutton->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes delete function and confirms delete
|
||||
*
|
||||
* @Given /^I confirm deletion$/
|
||||
* @throws ExpectationException Thrown by behat_base::find
|
||||
*/
|
||||
public function i_confirm_deletion() {
|
||||
$name = get_string('deleteselected');
|
||||
|
||||
// Execute the action.
|
||||
$okbutton = $this->find('css', "a[title='$name']");
|
||||
$okbutton->click();
|
||||
|
||||
// Yes, we are sure.
|
||||
// Using xpath + click instead of pressButton as 'Ok' it is a common string.
|
||||
$okbutton = $this->find('css', 'div.fp-dlg button.fp-dlg-butconfirm');
|
||||
$okbutton->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure user can see the exact number of elements (files in folders) in the filemanager.
|
||||
*
|
||||
|
@ -25,21 +25,26 @@ Feature: Delete files and folders from the file manager
|
||||
Given I log in as "admin"
|
||||
And I follow "Manage private files"
|
||||
And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager
|
||||
And I create "Delete me" folder in "Files" filemanager
|
||||
And I create "Delete me later" folder in "Files" filemanager
|
||||
And I press "Save changes"
|
||||
And I follow "Manage private files"
|
||||
And I click on "[title='Display folder with file details']" "css_element"
|
||||
And I mark for deletion "empty.txt" from filemanager
|
||||
And I confirm deletion
|
||||
And I click on "Display folder with file details" "link"
|
||||
And I set the field "Select file 'empty.txt'" to "1"
|
||||
When I click on "Delete selected" "link"
|
||||
Then I should see "Are you sure you want to delete the selected 1 file(s)?"
|
||||
When I click on "OK" "button" in the "Confirm" "dialogue"
|
||||
Then I should not see "empty.txt"
|
||||
And I press "Save changes"
|
||||
But I should see "Delete me later"
|
||||
When I press "Save changes"
|
||||
And I follow "Manage private files"
|
||||
Then I should not see "empty.txt"
|
||||
And I mark for deletion "Delete me" from filemanager
|
||||
And I confirm deletion
|
||||
Then I should not see "Delete me"
|
||||
And I press "Save changes"
|
||||
And I should not see "Delete me"
|
||||
But I should see "Delete me later"
|
||||
And I set the field "Select file 'Delete me later'" to "1"
|
||||
And I click on "Delete selected" "link"
|
||||
And I click on "OK" "button" in the "Confirm" "dialogue"
|
||||
Then I should not see "Delete me later"
|
||||
When I press "Save changes"
|
||||
Then I should not see "Delete me later"
|
||||
|
||||
@javascript
|
||||
Scenario: Delete a file and a folder using bulk functionality (multiple)
|
||||
@ -47,14 +52,45 @@ Feature: Delete files and folders from the file manager
|
||||
And I follow "Manage private files"
|
||||
And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager
|
||||
And I create "Delete me" folder in "Files" filemanager
|
||||
And I create "Do not delete me" folder in "Files" filemanager
|
||||
And I press "Save changes"
|
||||
And I follow "Manage private files"
|
||||
And I click on "[title='Display folder with file details']" "css_element"
|
||||
And I mark for deletion "empty.txt" from filemanager
|
||||
And I mark for deletion "Delete me" from filemanager
|
||||
And I confirm deletion
|
||||
And I click on "Display folder with file details" "link"
|
||||
And I set the field "Select file 'empty.txt'" to "1"
|
||||
And I set the field "Select file 'Delete me'" to "1"
|
||||
When I click on "Delete selected" "link"
|
||||
Then I should see "Are you sure you want to delete the selected 2 file(s)?"
|
||||
When I click on "OK" "button" in the "Confirm" "dialogue"
|
||||
Then I should not see "Delete me"
|
||||
Then I should not see "empty.txt"
|
||||
And I should not see "empty.txt"
|
||||
But I should see "Do not delete me"
|
||||
When I press "Save changes"
|
||||
Then I should not see "Delete me" in the "Private files" "block"
|
||||
And I should not see "empty.txt" in the "Private files" "block"
|
||||
But I should see "Do not delete me" in the "Private files" "block"
|
||||
|
||||
@javascript
|
||||
Scenario: Delete files using the select all checkbox
|
||||
Given I log in as "admin"
|
||||
And I follow "Manage private files"
|
||||
And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager
|
||||
And I create "Delete me" folder in "Files" filemanager
|
||||
And I create "Delete me too" folder in "Files" filemanager
|
||||
And I press "Save changes"
|
||||
And I should not see "Delete me"
|
||||
Then I should not see "empty.txt"
|
||||
And I follow "Manage private files"
|
||||
And I click on "Display folder with file details" "link"
|
||||
When I set the field "Select all/none" to "1"
|
||||
Then the following fields match these values:
|
||||
| Select file 'empty.txt' | 1 |
|
||||
| Select file 'Delete me' | 1 |
|
||||
| Select file 'Delete me too' | 1 |
|
||||
When I click on "Delete selected" "link"
|
||||
Then I should see "Are you sure you want to delete the selected 3 file(s)?"
|
||||
When I click on "OK" "button" in the "Confirm" "dialogue"
|
||||
Then I should not see "Delete me"
|
||||
And I should not see "empty.txt"
|
||||
And I should not see "Delete me too"
|
||||
When I press "Save changes"
|
||||
Then I should not see "Delete me" in the "Private files" "block"
|
||||
And I should not see "empty.txt" in the "Private files" "block"
|
||||
But I should not see "Delete me too" in the "Private files" "block"
|
||||
|
Loading…
x
Reference in New Issue
Block a user