MDL-80951 backup: migrate YUI to AMD
This commit is contained in:
committed by
ferranrecio
parent
5b7fc89152
commit
7aefcdf9fb
@@ -0,0 +1,14 @@
|
||||
define("core_backup/schema_backup_form",["exports","core/notification","core/templates"],(function(_exports,_notification,Templates){var obj;
|
||||
/**
|
||||
* Schema selector javascript controls.
|
||||
*
|
||||
* This module controls:
|
||||
* - The select all feature.
|
||||
* - Disabling activities checkboxes when the section is not selected.
|
||||
*
|
||||
* @module core_backup/schema_backup_form
|
||||
* @copyright 2024 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_notification=(obj=_notification)&&obj.__esModule?obj:{default:obj},Templates=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Templates);const Selectors_action="[data-mdl-action]",Selectors_checkboxes='#id_coursesettings input[type="checkbox"]',Selectors_firstSection="fieldset#id_coursesettings .fcontainer .grouped_settings.section_level",Selectors_modCheckboxes=modName=>"setting_activity_".concat(modName,"_"),Suffixes_userData="_userdata",Suffixes_userInfo="_userinfo",Suffixes_included="_included";class BackupFormController{static init(modNames){return new BackupFormController(modNames)}constructor(modNames){this.modNames=modNames,this.scanFormUserData(),this.addSelectorsToPage()}scanFormUserData(){this.withuserdata=!1,this.userDataSuffix=Suffixes_userData;const checkboxes=document.querySelectorAll(Selectors_checkboxes);if(checkboxes)for(const checkbox of checkboxes){const name=checkbox.name;if(name.endsWith(Suffixes_userData)){this.withuserdata=!0;break}if(name.endsWith(Suffixes_userInfo)){this.withuserdata=!0,this.userDataSuffix=Suffixes_userInfo;break}}}initEvents(element){element.addEventListener("click",(event=>{var _action$dataset,_action$dataset$mdlMo,_action$dataset2;const action=event.target.closest(Selectors_action);if(!action)return;event.preventDefault();const suffix="userdata"==(null===(_action$dataset=action.dataset)||void 0===_action$dataset?void 0:_action$dataset.mdlType)?this.userDataSuffix:Suffixes_included;this.changeSelection("selectall"==action.dataset.mdlAction,suffix,null!==(_action$dataset$mdlMo=null===(_action$dataset2=action.dataset)||void 0===_action$dataset2?void 0:_action$dataset2.mdlMod)&&void 0!==_action$dataset$mdlMo?_action$dataset$mdlMo:null)}))}changeSelection(checked,suffix,modName){const prefix=modName?Selectors_modCheckboxes(modName):null;let formId;const checkboxes=document.querySelectorAll(Selectors_checkboxes);for(const checkbox of checkboxes){var _formId;formId=null!==(_formId=formId)&&void 0!==_formId?_formId:checkbox.closest("form").getAttribute("id"),prefix&&!checkbox.name.startsWith(prefix)||checkbox.name.endsWith(suffix)&&(checkbox.checked=checked)}formId&&M.form&&M.form.updateFormState(formId)}generateSelectorsElement(){const links=document.createElement("div");return links.id="backup_selectors",this.initEvents(links),this.renderSelectorsTemplate(links),links}renderSelectorsTemplate(element){const data={modules:this.getModulesTemplateData(),withuserdata:!!this.withuserdata||void 0};Templates.renderForPromise("core_backup/formselectall",data).then((_ref=>{let{html:html,js:js}=_ref;return Templates.replaceNodeContents(element,html,js)})).catch(_notification.default.exception)}getModulesTemplateData(){const modules=[];for(const modName in this.modNames)this.modNames.hasOwnProperty(modName)&&modules.push({modname:modName,heading:this.modNames[modName]});return modules}addSelectorsToPage(){const firstSection=document.querySelector(Selectors_firstSection);if(!firstSection)return;if(!firstSection.querySelector(Selectors_checkboxes))return;const selector=this.generateSelectorsElement();firstSection.parentNode.insertBefore(selector,firstSection)}}return _exports.default=BackupFormController,_exports.default}));
|
||||
|
||||
//# sourceMappingURL=schema_backup_form.min.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,225 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Schema selector javascript controls.
|
||||
*
|
||||
* This module controls:
|
||||
* - The select all feature.
|
||||
* - Disabling activities checkboxes when the section is not selected.
|
||||
*
|
||||
* @module core_backup/schema_backup_form
|
||||
* @copyright 2024 Ferran Recio <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
import Notification from 'core/notification';
|
||||
import * as Templates from 'core/templates';
|
||||
|
||||
const Selectors = {
|
||||
action: '[data-mdl-action]',
|
||||
checkboxes: '#id_coursesettings input[type="checkbox"]',
|
||||
firstSection: 'fieldset#id_coursesettings .fcontainer .grouped_settings.section_level',
|
||||
modCheckboxes: (modName) => `setting_activity_${modName}_`,
|
||||
};
|
||||
|
||||
const Suffixes = {
|
||||
userData: '_userdata',
|
||||
userInfo: '_userinfo',
|
||||
included: '_included',
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds select all/none links to the top of the backup/restore/import schema page.
|
||||
*/
|
||||
export default class BackupFormController {
|
||||
|
||||
/**
|
||||
* Static module init method.
|
||||
* @param {Array<string>} modNames - The names of the modules.
|
||||
* @returns {BackupFormController}
|
||||
*/
|
||||
static init(modNames) {
|
||||
return new BackupFormController(modNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of the SchemaBackupForm class.
|
||||
* @param {Array<string>} modNames - The names of the modules.
|
||||
*/
|
||||
constructor(modNames) {
|
||||
this.modNames = modNames;
|
||||
this.scanFormUserData();
|
||||
this.addSelectorsToPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect the user data attribute from the form.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
scanFormUserData() {
|
||||
this.withuserdata = false;
|
||||
this.userDataSuffix = Suffixes.userData;
|
||||
|
||||
const checkboxes = document.querySelectorAll(Selectors.checkboxes);
|
||||
if (!checkboxes) {
|
||||
return;
|
||||
}
|
||||
// Depending on the form, user data inclusion is called userinfo or userdata.
|
||||
for (const checkbox of checkboxes) {
|
||||
const name = checkbox.name;
|
||||
if (name.endsWith(Suffixes.userData)) {
|
||||
this.withuserdata = true;
|
||||
break;
|
||||
} else if (name.endsWith(Suffixes.userInfo)) {
|
||||
this.withuserdata = true;
|
||||
this.userDataSuffix = Suffixes.userInfo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes all related events.
|
||||
*
|
||||
* @private
|
||||
* @param {HTMLElement} element - The element to attach the events to.
|
||||
*/
|
||||
initEvents(element) {
|
||||
element.addEventListener('click', (event) => {
|
||||
const action = event.target.closest(Selectors.action);
|
||||
if (!action) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
|
||||
const suffix = (action.dataset?.mdlType == 'userdata') ? this.userDataSuffix : Suffixes.included;
|
||||
|
||||
this.changeSelection(
|
||||
action.dataset.mdlAction == 'selectall',
|
||||
suffix,
|
||||
action.dataset?.mdlMod ?? null
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the selection according to the params.
|
||||
*
|
||||
* @private
|
||||
* @param {boolean} checked - The checked state for the checkboxes.
|
||||
* @param {string} suffix - The checkboxes suffix
|
||||
* @param {string} [modName] - The module name.
|
||||
*/
|
||||
changeSelection(checked, suffix, modName) {
|
||||
const prefix = modName ? Selectors.modCheckboxes(modName) : null;
|
||||
|
||||
let formId;
|
||||
|
||||
const checkboxes = document.querySelectorAll(Selectors.checkboxes);
|
||||
for (const checkbox of checkboxes) {
|
||||
formId = formId ?? checkbox.closest('form').getAttribute('id');
|
||||
|
||||
if (prefix && !checkbox.name.startsWith(prefix)) {
|
||||
continue;
|
||||
}
|
||||
if (checkbox.name.endsWith(suffix)) {
|
||||
checkbox.checked = checked;
|
||||
}
|
||||
}
|
||||
|
||||
// At this point, we really need to persuade the form we are part of to
|
||||
// update all of its disabledIf rules. However, as far as I can see,
|
||||
// given the way that lib/form/form.js is written, that is impossible.
|
||||
if (formId && M.form) {
|
||||
M.form.updateFormState(formId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the full selectors element to add to the page.
|
||||
*
|
||||
* @private
|
||||
* @returns {HTMLElement} The selectors element.
|
||||
*/
|
||||
generateSelectorsElement() {
|
||||
const links = document.createElement('div');
|
||||
links.id = 'backup_selectors';
|
||||
this.initEvents(links);
|
||||
this.renderSelectorsTemplate(links);
|
||||
return links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the select all template.
|
||||
*
|
||||
* @private
|
||||
* @param {HTMLElement} element the container
|
||||
*/
|
||||
renderSelectorsTemplate(element) {
|
||||
const data = {
|
||||
modules: this.getModulesTemplateData(),
|
||||
withuserdata: (this.withuserdata) ? true : undefined,
|
||||
};
|
||||
Templates.renderForPromise(
|
||||
'core_backup/formselectall',
|
||||
data
|
||||
).then(({html, js}) => {
|
||||
return Templates.replaceNodeContents(element, html, js);
|
||||
}).catch(Notification.exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the modules template data.
|
||||
*
|
||||
* @private
|
||||
* @returns {Array} of modules data.
|
||||
*/
|
||||
getModulesTemplateData() {
|
||||
const modules = [];
|
||||
for (const modName in this.modNames) {
|
||||
if (!this.modNames.hasOwnProperty(modName)) {
|
||||
continue;
|
||||
}
|
||||
modules.push({
|
||||
modname: modName,
|
||||
heading: this.modNames[modName],
|
||||
});
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds select all/none functionality to the backup form.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
addSelectorsToPage() {
|
||||
const firstSection = document.querySelector(Selectors.firstSection);
|
||||
if (!firstSection) {
|
||||
// This is not a relevant page.
|
||||
return;
|
||||
}
|
||||
if (!firstSection.querySelector(Selectors.checkboxes)) {
|
||||
// No checkboxes.
|
||||
return;
|
||||
}
|
||||
|
||||
// Add global select all/none options.
|
||||
const selector = this.generateSelectorsElement();
|
||||
firstSection.parentNode.insertBefore(selector, firstSection);
|
||||
}
|
||||
}
|
||||
@@ -416,8 +416,7 @@ abstract class base_moodleform extends moodleform {
|
||||
$modinfo = get_fast_modinfo($COURSE);
|
||||
$modnames = array_map('strval', $modinfo->get_used_module_names(true));
|
||||
core_collator::asort($modnames);
|
||||
$PAGE->requires->yui_module('moodle-backup-backupselectall', 'M.core_backup.backupselectall',
|
||||
array($modnames));
|
||||
$PAGE->requires->js_call_amd('core_backup/schema_backup_form', 'init', [$modnames]);
|
||||
$PAGE->requires->strings_for_js(array('select', 'all', 'none'), 'moodle');
|
||||
$PAGE->requires->strings_for_js(array('showtypes', 'hidetypes'), 'backup');
|
||||
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_backup/formselectall
|
||||
|
||||
TODO describe template formselectall
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"withuserdata": true,
|
||||
"modules": [
|
||||
{
|
||||
"modname": "assign",
|
||||
"heading": "Assignments"
|
||||
},
|
||||
{
|
||||
"modname": "book",
|
||||
"heading": "Books"
|
||||
}
|
||||
]
|
||||
}
|
||||
}}
|
||||
<div class="grouped_settings section_level">
|
||||
<div id="backup_selectors_included" class="include_setting section_level">
|
||||
<div class="fitem fitem_fcheckbox backup_selector">
|
||||
<div class="fitemtitle">{{#str}} select {{/str}}</div>
|
||||
<div class="felement">
|
||||
<a
|
||||
data-mdl-action="selectall"
|
||||
data-mdl-type="include"
|
||||
href="#"
|
||||
>{{#str}} all {{/str}}</a> /
|
||||
<a
|
||||
data-mdl-action="selectnone"
|
||||
data-mdl-type="include"
|
||||
href="#"
|
||||
>{{#str}} none {{/str}}</a>
|
||||
(<a
|
||||
class="collapsed showmore-container"
|
||||
id="mod_select_links_toggler"
|
||||
data-toggle="collapse"
|
||||
href="#mod_select_links"
|
||||
aria-expanded="false"
|
||||
aria-controls="mod_select_links"
|
||||
>{{!
|
||||
}}<span class="collapsed-content">{{#str}} showtypes, backup {{/str}}</span>{{!
|
||||
}}<span class="expanded-content">{{#str}} hidetypes, backup {{/str}}</span>{{!
|
||||
}}</a>)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{#withuserdata}}
|
||||
<div id="backup_selectors_userdata" class="normal_setting">
|
||||
<div class="fitem fitem_fcheckbox backup_selector">
|
||||
<div class="fitemtitle">Select</div>
|
||||
<div class="felement">
|
||||
<a
|
||||
data-mdl-action="selectall"
|
||||
data-mdl-type="userdata"
|
||||
href="#"
|
||||
>{{#str}} all {{/str}}</a> /
|
||||
<a
|
||||
data-mdl-action="selectnone"
|
||||
data-mdl-type="userdata"
|
||||
href="#"
|
||||
>{{#str}} none {{/str}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/withuserdata}}
|
||||
<div id="mod_select_links" class="collapse" style="">
|
||||
{{#modules}}
|
||||
<div class="grouped_settings section_level">
|
||||
<div id="backup_selectors_mod_{{modname}}" class="include_setting section_level">
|
||||
<div class="fitem fitem_fcheckbox backup_selector">
|
||||
<div class="fitemtitle">{{heading}}</div>
|
||||
<div class="felement">
|
||||
<a
|
||||
data-mdl-action="selectall"
|
||||
data-mdl-type="include"
|
||||
data-mdl-mod="{{modname}}"
|
||||
href="#"
|
||||
>{{#str}} all {{/str}}</a> /
|
||||
<a
|
||||
data-mdl-action="selectnone"
|
||||
data-mdl-type="include"
|
||||
data-mdl-mod="{{modname}}"
|
||||
href="#"
|
||||
>{{#str}} none {{/str}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{#withuserdata}}
|
||||
<div class="normal_setting">
|
||||
<div id="backup_selectors_userdata-mod_{{modname}}" class="fitem fitem_fcheckbox backup_selector">
|
||||
<div class="fitemtitle">{{heading}}</div>
|
||||
<div class="felement">
|
||||
<a
|
||||
data-mdl-action="selectall"
|
||||
data-mdl-type="userdata"
|
||||
data-mdl-mod="{{modname}}"
|
||||
href="#"
|
||||
>{{#str}} all {{/str}}</a> /
|
||||
<a
|
||||
data-mdl-action="selectnone"
|
||||
data-mdl-type="userdata"
|
||||
data-mdl-mod="{{modname}}"
|
||||
href="#"
|
||||
>{{#str}} none {{/str}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/withuserdata}}
|
||||
</div>
|
||||
{{/modules}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,280 @@
|
||||
@core @core_backup
|
||||
Feature: Schema form selectors
|
||||
In order to quickly select schema elements
|
||||
As an admin
|
||||
I need to use the selectors UI to toggle selection of schema elements
|
||||
|
||||
Background:
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | category | numsections | initsections |
|
||||
| Course 1 | C1 | 0 | 2 | 1 |
|
||||
And the following "activities" exist:
|
||||
| activity | course | idnumber | name | intro | section |
|
||||
| assign | C1 | assign1 | Test assign 1 | Assign description | 1 |
|
||||
| data | C1 | data1 | Test data 1 | Database description | 1 |
|
||||
| assign | C1 | assign2 | Test assign 2 | Assign description | 2 |
|
||||
| data | C1 | data2 | Test data 2 | Database description | 2 |
|
||||
And I am on the "C1" "Course" page logged in as "admin"
|
||||
And I navigate to "Course reuse" in current page administration
|
||||
And I follow "Backup"
|
||||
And I click on "Next" "button" in the "page-content" "region"
|
||||
|
||||
@javascript
|
||||
Scenario: Select all and none should toggle backup schema checkboxes
|
||||
Given the field "Section 1" matches value "1"
|
||||
And the field "Test assign 1" matches value "1"
|
||||
And the field "Test data 1" matches value "1"
|
||||
And the field "Section 2" matches value "1"
|
||||
And the field "Test assign 2" matches value "1"
|
||||
And the field "Test data 2" matches value "1"
|
||||
And the "Section 1: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 1 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 1 user data" "checkbox" should be enabled
|
||||
And the "Section 2: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 2 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 2 user data" "checkbox" should be enabled
|
||||
# Test select none.
|
||||
When I click on "None" "link" in the "backup_selectors_included" "region"
|
||||
Then the field "Section 1" matches value ""
|
||||
And the field "Test assign 1" matches value ""
|
||||
And the field "Test data 1" matches value ""
|
||||
And the field "Section 2" matches value ""
|
||||
And the field "Test assign 2" matches value ""
|
||||
And the field "Test data 2" matches value ""
|
||||
And the "Section 1: User data" "checkbox" should be disabled
|
||||
And the "Include Test assign 1 user data" "checkbox" should be disabled
|
||||
And the "Include Test data 1 user data" "checkbox" should be disabled
|
||||
And the "Section 2: User data" "checkbox" should be disabled
|
||||
And the "Include Test assign 2 user data" "checkbox" should be disabled
|
||||
And the "Include Test data 2 user data" "checkbox" should be disabled
|
||||
# Test select all.
|
||||
And I click on "All" "link" in the "backup_selectors_included" "region"
|
||||
And the field "Section 1" matches value "1"
|
||||
And the field "Test assign 1" matches value "1"
|
||||
And the field "Test data 1" matches value "1"
|
||||
And the field "Section 2" matches value "1"
|
||||
And the field "Test assign 2" matches value "1"
|
||||
And the field "Test data 2" matches value "1"
|
||||
And the "Section 1: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 1 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 1 user data" "checkbox" should be enabled
|
||||
And the "Section 2: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 2 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 2 user data" "checkbox" should be enabled
|
||||
|
||||
@javascript
|
||||
Scenario: The type options panell allow to select all and none of one activity type
|
||||
Given the field "Section 1" matches value "1"
|
||||
And the field "Test assign 1" matches value "1"
|
||||
And the field "Test data 1" matches value "1"
|
||||
And the field "Section 2" matches value "1"
|
||||
And the field "Test assign 2" matches value "1"
|
||||
And the field "Test data 2" matches value "1"
|
||||
And the "Section 1: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 1 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 1 user data" "checkbox" should be enabled
|
||||
And the "Section 2: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 2 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 2 user data" "checkbox" should be enabled
|
||||
# Test select none assignment.
|
||||
When I click on "Show type options" "link" in the "backup_selectors_included" "region"
|
||||
And I click on "None" "link" in the "backup_selectors_mod_assign" "region"
|
||||
Then the field "Section 1" matches value "1"
|
||||
And the field "Test assign 1" matches value ""
|
||||
And the field "Test data 1" matches value "1"
|
||||
And the field "Section 2" matches value "1"
|
||||
And the field "Test assign 2" matches value ""
|
||||
And the field "Test data 2" matches value "1"
|
||||
And the "Section 1: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 1 user data" "checkbox" should be disabled
|
||||
And the "Include Test data 1 user data" "checkbox" should be enabled
|
||||
And the "Section 2: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 2 user data" "checkbox" should be disabled
|
||||
And the "Include Test data 2 user data" "checkbox" should be enabled
|
||||
# Test select all assignments.
|
||||
And I click on "All" "link" in the "backup_selectors_mod_assign" "region"
|
||||
And the field "Section 1" matches value "1"
|
||||
And the field "Test assign 1" matches value "1"
|
||||
And the field "Test data 1" matches value "1"
|
||||
And the field "Section 2" matches value "1"
|
||||
And the field "Test assign 2" matches value "1"
|
||||
And the field "Test data 2" matches value "1"
|
||||
And the "Section 1: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 1 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 1 user data" "checkbox" should be enabled
|
||||
And the "Section 2: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 2 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 2 user data" "checkbox" should be enabled
|
||||
|
||||
@javascript
|
||||
Scenario: Select all or none in user data should toggle backup schema checkboxes
|
||||
Given the field "Section 1" matches value "1"
|
||||
And the field "Test assign 1" matches value "1"
|
||||
And the field "Test data 1" matches value "1"
|
||||
And the field "Section 2" matches value "1"
|
||||
And the field "Test assign 2" matches value "1"
|
||||
And the field "Test data 2" matches value "1"
|
||||
And the field "Section 1: User data" matches value "1"
|
||||
And the field "Include Test assign 1 user data" matches value "1"
|
||||
And the field "Include Test data 1 user data" matches value "1"
|
||||
And the field "Section 2: User data" matches value "1"
|
||||
And the field "Include Test assign 2 user data" matches value "1"
|
||||
And the field "Include Test data 2 user data" matches value "1"
|
||||
# Test select none.
|
||||
When I click on "None" "link" in the "backup_selectors_userdata" "region"
|
||||
Then the field "Section 1" matches value "1"
|
||||
And the field "Test assign 1" matches value "1"
|
||||
And the field "Test data 1" matches value "1"
|
||||
And the field "Section 2" matches value "1"
|
||||
And the field "Test assign 2" matches value "1"
|
||||
And the field "Test data 2" matches value "1"
|
||||
And the field "Section 1: User data" matches value ""
|
||||
And the field "Include Test assign 1 user data" matches value ""
|
||||
And the field "Include Test data 1 user data" matches value ""
|
||||
And the field "Section 2: User data" matches value ""
|
||||
And the field "Include Test assign 2 user data" matches value ""
|
||||
And the field "Include Test data 2 user data" matches value ""
|
||||
# Test select all.
|
||||
And I click on "All" "link" in the "backup_selectors_userdata" "region"
|
||||
And the field "Section 1" matches value "1"
|
||||
And the field "Test assign 1" matches value "1"
|
||||
And the field "Test data 1" matches value "1"
|
||||
And the field "Section 2" matches value "1"
|
||||
And the field "Test assign 2" matches value "1"
|
||||
And the field "Test data 2" matches value "1"
|
||||
And the field "Section 1: User data" matches value "1"
|
||||
And the field "Include Test assign 1 user data" matches value "1"
|
||||
And the field "Include Test data 1 user data" matches value "1"
|
||||
And the field "Section 2: User data" matches value "1"
|
||||
And the field "Include Test assign 2 user data" matches value "1"
|
||||
And the field "Include Test data 2 user data" matches value "1"
|
||||
|
||||
@javascript
|
||||
Scenario: The type options panell allow to select all and none user data for an activity type
|
||||
Given the field "Section 1" matches value "1"
|
||||
And the field "Test assign 1" matches value "1"
|
||||
And the field "Test data 1" matches value "1"
|
||||
And the field "Section 2" matches value "1"
|
||||
And the field "Test assign 2" matches value "1"
|
||||
And the field "Test data 2" matches value "1"
|
||||
And the field "Section 1: User data" matches value "1"
|
||||
And the field "Include Test assign 1 user data" matches value "1"
|
||||
And the field "Include Test data 1 user data" matches value "1"
|
||||
And the field "Section 2: User data" matches value "1"
|
||||
And the field "Include Test assign 2 user data" matches value "1"
|
||||
And the field "Include Test data 2 user data" matches value "1"
|
||||
# Test select none assignment.
|
||||
When I click on "Show type options" "link" in the "backup_selectors_included" "region"
|
||||
And I click on "None" "link" in the "backup_selectors_userdata-mod_assign" "region"
|
||||
Then the field "Section 1" matches value "1"
|
||||
And the field "Test assign 1" matches value "1"
|
||||
And the field "Test data 1" matches value "1"
|
||||
And the field "Section 2" matches value "1"
|
||||
And the field "Test assign 2" matches value "1"
|
||||
And the field "Test data 2" matches value "1"
|
||||
And the field "Section 1: User data" matches value "1"
|
||||
And the field "Include Test assign 1 user data" matches value ""
|
||||
And the field "Include Test data 1 user data" matches value "1"
|
||||
And the field "Section 2: User data" matches value "1"
|
||||
And the field "Include Test assign 2 user data" matches value ""
|
||||
And the field "Include Test data 2 user data" matches value "1"
|
||||
# Test select all assignments.
|
||||
And I click on "All" "link" in the "backup_selectors_userdata-mod_assign" "region"
|
||||
And the field "Section 1" matches value "1"
|
||||
And the field "Test assign 1" matches value "1"
|
||||
And the field "Test data 1" matches value "1"
|
||||
And the field "Section 2" matches value "1"
|
||||
And the field "Test assign 2" matches value "1"
|
||||
And the field "Test data 2" matches value "1"
|
||||
And the field "Section 1: User data" matches value "1"
|
||||
And the field "Include Test assign 1 user data" matches value "1"
|
||||
And the field "Include Test data 1 user data" matches value "1"
|
||||
And the field "Section 2: User data" matches value "1"
|
||||
And the field "Include Test assign 2 user data" matches value "1"
|
||||
And the field "Include Test data 2 user data" matches value "1"
|
||||
|
||||
@javascript
|
||||
Scenario: Select or unselect a section schema disable the activities checkboxes
|
||||
Given the field "Section 1" matches value "1"
|
||||
And the field "Test assign 1" matches value "1"
|
||||
And the field "Test data 1" matches value "1"
|
||||
And the field "Section 2" matches value "1"
|
||||
And the field "Test assign 2" matches value "1"
|
||||
And the field "Test data 2" matches value "1"
|
||||
And the "Section 1: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 1 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 1 user data" "checkbox" should be enabled
|
||||
And the "Section 2: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 2 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 2 user data" "checkbox" should be enabled
|
||||
# Test unselect section 1.
|
||||
When I set the field "Section 1" to ""
|
||||
Then the field "Section 1" matches value ""
|
||||
And the "Test assign 1" "checkbox" should be disabled
|
||||
And the "Test data 1" "checkbox" should be disabled
|
||||
And the "Section 2" "checkbox" should be enabled
|
||||
And the "Test assign 2" "checkbox" should be enabled
|
||||
And the "Test data 2" "checkbox" should be enabled
|
||||
And the "Section 1: User data" "checkbox" should be disabled
|
||||
And the "Include Test assign 1 user data" "checkbox" should be disabled
|
||||
And the "Include Test data 1 user data" "checkbox" should be disabled
|
||||
And the "Section 2: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 2 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 2 user data" "checkbox" should be enabled
|
||||
# Test select section 1.
|
||||
And I set the field "Section 1" to "1"
|
||||
And the field "Section 1" matches value "1"
|
||||
And the "Test assign 1" "checkbox" should be enabled
|
||||
And the "Test data 1" "checkbox" should be enabled
|
||||
And the "Section 2" "checkbox" should be enabled
|
||||
And the "Test assign 2" "checkbox" should be enabled
|
||||
And the "Test data 2" "checkbox" should be enabled
|
||||
And the "Section 1: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 1 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 1 user data" "checkbox" should be enabled
|
||||
And the "Section 2: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 2 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 2 user data" "checkbox" should be enabled
|
||||
|
||||
@javascript
|
||||
Scenario: Select or unselect a section user data disable the activities checkboxes
|
||||
Given the "Section 1" "checkbox" should be enabled
|
||||
And the "Test assign 1" "checkbox" should be enabled
|
||||
And the "Test data 1" "checkbox" should be enabled
|
||||
And the "Section 2" "checkbox" should be enabled
|
||||
And the "Test assign 2" "checkbox" should be enabled
|
||||
And the "Test data 2" "checkbox" should be enabled
|
||||
And the "Section 1: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 1 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 1 user data" "checkbox" should be enabled
|
||||
And the "Section 2: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 2 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 2 user data" "checkbox" should be enabled
|
||||
# Test unselect section 1.
|
||||
When I set the field "Section 1: User data" to ""
|
||||
Then the "Section 1" "checkbox" should be enabled
|
||||
And the "Test assign 1" "checkbox" should be enabled
|
||||
And the "Test data 1" "checkbox" should be enabled
|
||||
And the "Section 2" "checkbox" should be enabled
|
||||
And the "Test assign 2" "checkbox" should be enabled
|
||||
And the "Test data 2" "checkbox" should be enabled
|
||||
And the "Section 1: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 1 user data" "checkbox" should be disabled
|
||||
And the "Include Test data 1 user data" "checkbox" should be disabled
|
||||
And the "Section 2: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 2 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 2 user data" "checkbox" should be enabled
|
||||
# Test select section 1.
|
||||
And I set the field "Section 1: User data" to "1"
|
||||
And the "Section 1" "checkbox" should be enabled
|
||||
And the "Test assign 1" "checkbox" should be enabled
|
||||
And the "Test data 1" "checkbox" should be enabled
|
||||
And the "Section 2" "checkbox" should be enabled
|
||||
And the "Test assign 2" "checkbox" should be enabled
|
||||
And the "Test data 2" "checkbox" should be enabled
|
||||
And the "Section 1: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 1 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 1 user data" "checkbox" should be enabled
|
||||
And the "Section 2: User data" "checkbox" should be enabled
|
||||
And the "Include Test assign 2 user data" "checkbox" should be enabled
|
||||
And the "Include Test data 2 user data" "checkbox" should be enabled
|
||||
Vendored
-193
@@ -1,193 +0,0 @@
|
||||
YUI.add('moodle-backup-backupselectall', function (Y, NAME) {
|
||||
|
||||
/**
|
||||
* Adds select all/none links to the top of the backup/restore/import schema page.
|
||||
*
|
||||
* @module moodle-backup-backupselectall
|
||||
*/
|
||||
|
||||
// Namespace for the backup
|
||||
M.core_backup = M.core_backup || {};
|
||||
|
||||
/**
|
||||
* Adds select all/none links to the top of the backup/restore/import schema page.
|
||||
*
|
||||
* @class M.core_backup.backupselectall
|
||||
*/
|
||||
M.core_backup.backupselectall = function(modnames) {
|
||||
var formid = null;
|
||||
|
||||
var helper = function(e, check, type, mod) {
|
||||
e.preventDefault();
|
||||
var prefix = '';
|
||||
if (typeof mod !== 'undefined') {
|
||||
prefix = 'setting_activity_' + mod + '_';
|
||||
}
|
||||
|
||||
var len = type.length;
|
||||
Y.all('input[type="checkbox"]').each(function(checkbox) {
|
||||
var name = checkbox.get('name');
|
||||
// If a prefix has been set, ignore checkboxes which don't have that prefix.
|
||||
if (prefix && name.substring(0, prefix.length) !== prefix) {
|
||||
return;
|
||||
}
|
||||
if (name.substring(name.length - len) === type) {
|
||||
checkbox.set('checked', check);
|
||||
}
|
||||
});
|
||||
|
||||
// At this point, we really need to persuade the form we are part of to
|
||||
// update all of its disabledIf rules. However, as far as I can see,
|
||||
// given the way that lib/form/form.js is written, that is impossible.
|
||||
if (formid && M.form) {
|
||||
M.form.updateFormState(formid);
|
||||
}
|
||||
};
|
||||
|
||||
var html_generator = function(classname, idtype, heading, extra) {
|
||||
if (typeof extra === 'undefined') {
|
||||
extra = '';
|
||||
}
|
||||
return '<div class="' + classname + '">' +
|
||||
'<div class="fitem fitem_fcheckbox backup_selector">' +
|
||||
'<div class="fitemtitle">' + heading + '</div>' +
|
||||
'<div class="felement">' +
|
||||
'<a id="backup-all-' + idtype + '" href="#">' + M.util.get_string('all', 'moodle') + '</a> / ' +
|
||||
'<a id="backup-none-' + idtype + '" href="#">' + M.util.get_string('none', 'moodle') + '</a>' +
|
||||
extra +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
};
|
||||
|
||||
var firstsection = Y.one('fieldset#id_coursesettings .fcontainer .grouped_settings.section_level');
|
||||
if (!firstsection) {
|
||||
// This is not a relevant page.
|
||||
return;
|
||||
}
|
||||
if (!firstsection.one('input[type="checkbox"]')) {
|
||||
// No checkboxes.
|
||||
return;
|
||||
}
|
||||
|
||||
formid = firstsection.ancestor('form').getAttribute('id');
|
||||
|
||||
var withuserdata = false;
|
||||
Y.all('input[type="checkbox"]').each(function(checkbox) {
|
||||
var name = checkbox.get('name');
|
||||
if (name.substring(name.length - 9) === '_userdata') {
|
||||
withuserdata = '_userdata';
|
||||
} else if (name.substring(name.length - 9) === '_userinfo') {
|
||||
withuserdata = '_userinfo';
|
||||
}
|
||||
});
|
||||
|
||||
// Add global select all/none options.
|
||||
var html = html_generator('include_setting section_level', 'included', M.util.get_string('select', 'moodle'),
|
||||
' (<a id="backup-bytype" href="#">' + M.util.get_string('showtypes', 'backup') + '</a>)');
|
||||
if (withuserdata) {
|
||||
html += html_generator('normal_setting', 'userdata', M.util.get_string('select', 'moodle'));
|
||||
}
|
||||
var links = Y.Node.create('<div class="grouped_settings section_level">' + html + '</div>');
|
||||
firstsection.insert(links, 'before');
|
||||
|
||||
// Add select all/none for each module type.
|
||||
var initlinks = function(links, mod) {
|
||||
Y.one('#backup-all-mod_' + mod).on('click', function(e) {
|
||||
helper(e, true, '_included', mod);
|
||||
});
|
||||
Y.one('#backup-none-mod_' + mod).on('click', function(e) {
|
||||
helper(e, false, '_included', mod);
|
||||
});
|
||||
if (withuserdata) {
|
||||
Y.one('#backup-all-userdata-mod_' + mod).on('click', function(e) {
|
||||
helper(e, true, withuserdata, mod);
|
||||
});
|
||||
Y.one('#backup-none-userdata-mod_' + mod).on('click', function(e) {
|
||||
helper(e, false, withuserdata, mod);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// For each module type on the course, add hidden select all/none options.
|
||||
var modlist = Y.Node.create('<div id="mod_select_links">');
|
||||
modlist.hide();
|
||||
modlist.currentlyshown = false;
|
||||
links.appendChild(modlist);
|
||||
for (var mod in modnames) {
|
||||
// Only include actual values from the list.
|
||||
if (!modnames.hasOwnProperty(mod)) {
|
||||
continue;
|
||||
}
|
||||
html = html_generator('include_setting section_level', 'mod_' + mod, modnames[mod]);
|
||||
if (withuserdata) {
|
||||
html += html_generator('normal_setting', 'userdata-mod_' + mod, modnames[mod]);
|
||||
}
|
||||
var modlinks = Y.Node.create(
|
||||
'<div class="grouped_settings section_level">' + html + '</div>');
|
||||
modlist.appendChild(modlinks);
|
||||
initlinks(modlinks, mod);
|
||||
}
|
||||
|
||||
// Toggles the display of the hidden module select all/none links.
|
||||
var toggletypes = function() {
|
||||
// Change text of type toggle link.
|
||||
var link = Y.one('#backup-bytype');
|
||||
if (modlist.currentlyshown) {
|
||||
link.setHTML(M.util.get_string('showtypes', 'backup'));
|
||||
} else {
|
||||
link.setHTML(M.util.get_string('hidetypes', 'backup'));
|
||||
}
|
||||
|
||||
// The link has now been toggled (from show to hide, or vice-versa).
|
||||
modlist.currentlyshown = !modlist.currentlyshown;
|
||||
|
||||
// Either hide or show the links.
|
||||
var animcfg = {node: modlist, duration: 0.2},
|
||||
anim;
|
||||
if (modlist.currentlyshown) {
|
||||
// Animate reveal of the module links.
|
||||
modlist.show();
|
||||
animcfg.to = {maxHeight: modlist.get('clientHeight') + 'px'};
|
||||
modlist.setStyle('maxHeight', '0px');
|
||||
anim = new Y.Anim(animcfg);
|
||||
anim.on('end', function() {
|
||||
modlist.setStyle('maxHeight', 'none');
|
||||
});
|
||||
anim.run();
|
||||
} else {
|
||||
// Animate hide of the module links.
|
||||
animcfg.to = {maxHeight: '0px'};
|
||||
modlist.setStyle('maxHeight', modlist.get('clientHeight') + 'px');
|
||||
anim = new Y.Anim(animcfg);
|
||||
anim.on('end', function() {
|
||||
modlist.hide();
|
||||
modlist.setStyle('maxHeight', 'none');
|
||||
});
|
||||
anim.run();
|
||||
}
|
||||
|
||||
};
|
||||
Y.one('#backup-bytype').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
toggletypes();
|
||||
});
|
||||
|
||||
Y.one('#backup-all-included').on('click', function(e) {
|
||||
helper(e, true, '_included');
|
||||
});
|
||||
Y.one('#backup-none-included').on('click', function(e) {
|
||||
helper(e, false, '_included');
|
||||
});
|
||||
if (withuserdata) {
|
||||
Y.one('#backup-all-userdata').on('click', function(e) {
|
||||
helper(e, true, withuserdata);
|
||||
});
|
||||
Y.one('#backup-none-userdata').on('click', function(e) {
|
||||
helper(e, false, withuserdata);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}, '@VERSION@', {"requires": ["node", "event", "node-event-simulate", "anim"]});
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
YUI.add("moodle-backup-backupselectall",function(g,e){M.core_backup=M.core_backup||{},M.core_backup.backupselectall=function(e){var t,n,i,d,o,c,r,p,l=null,a=function(e,t,i,n){var o,c;e.preventDefault(),o=void 0!==n?"setting_activity_"+n+"_":"",c=i.length,g.all('input[type="checkbox"]').each(function(e){var n=e.get("name");o&&n.substring(0,o.length)!==o||n.substring(n.length-c)===i&&e.set("checked",t)}),l&&M.form&&M.form.updateFormState(l)},u=function(e,n,t,i){return void 0===i&&(i=""),'<div class="'+e+'"><div class="fitem fitem_fcheckbox backup_selector"><div class="fitemtitle">'+t+'</div><div class="felement"><a id="backup-all-'+n+'" href="#">'+M.util.get_string("all","moodle")+'</a> / <a id="backup-none-'+n+'" href="#">'+M.util.get_string("none","moodle")+"</a>"+i+"</div></div></div>"},s=g.one("fieldset#id_coursesettings .fcontainer .grouped_settings.section_level");if(s&&s.one('input[type="checkbox"]')){for(c in l=s.ancestor("form").getAttribute("id"),t=!1,g.all('input[type="checkbox"]').each(function(e){e=e.get("name");"_userdata"===e.substring(e.length-9)?t="_userdata":"_userinfo"===e.substring(e.length-9)&&(t="_userinfo")}),n=u("include_setting section_level","included",M.util.get_string("select","moodle"),' (<a id="backup-bytype" href="#">'+M.util.get_string("showtypes","backup")+"</a>)"),t&&(n+=u("normal_setting","userdata",M.util.get_string("select","moodle"))),i=g.Node.create('<div class="grouped_settings section_level">'+n+"</div>"),s.insert(i,"before"),d=function(e,n){g.one("#backup-all-mod_"+n).on("click",function(e){a(e,!0,"_included",n)}),g.one("#backup-none-mod_"+n).on("click",function(e){a(e,!1,"_included",n)}),t&&(g.one("#backup-all-userdata-mod_"+n).on("click",function(e){a(e,!0,t,n)}),g.one("#backup-none-userdata-mod_"+n).on("click",function(e){a(e,!1,t,n)}))},(o=g.Node.create('<div id="mod_select_links">')).hide(),o.currentlyshown=!1,i.appendChild(o),e)e.hasOwnProperty(c)&&(n=u("include_setting section_level","mod_"+c,e[c]),t&&(n+=u("normal_setting","userdata-mod_"+c,e[c])),r=g.Node.create('<div class="grouped_settings section_level">'+n+"</div>"),o.appendChild(r),d(0,c));p=function(){var e,n=g.one("#backup-bytype");o.currentlyshown?n.setHTML(M.util.get_string("showtypes","backup")):n.setHTML(M.util.get_string("hidetypes","backup")),o.currentlyshown=!o.currentlyshown,n={node:o,duration:.2},o.currentlyshown?(o.show(),n.to={maxHeight:o.get("clientHeight")+"px"},o.setStyle("maxHeight","0px"),(e=new g.Anim(n)).on("end",function(){o.setStyle("maxHeight","none")})):(n.to={maxHeight:"0px"},o.setStyle("maxHeight",o.get("clientHeight")+"px"),(e=new g.Anim(n)).on("end",function(){o.hide(),o.setStyle("maxHeight","none")})),e.run()},g.one("#backup-bytype").on("click",function(e){e.preventDefault(),p()}),g.one("#backup-all-included").on("click",function(e){a(e,!0,"_included")}),g.one("#backup-none-included").on("click",function(e){a(e,!1,"_included")}),t&&(g.one("#backup-all-userdata").on("click",function(e){a(e,!0,t)}),g.one("#backup-none-userdata").on("click",function(e){a(e,!1,t)}))}}},"@VERSION@",{requires:["node","event","node-event-simulate","anim"]});
|
||||
-193
@@ -1,193 +0,0 @@
|
||||
YUI.add('moodle-backup-backupselectall', function (Y, NAME) {
|
||||
|
||||
/**
|
||||
* Adds select all/none links to the top of the backup/restore/import schema page.
|
||||
*
|
||||
* @module moodle-backup-backupselectall
|
||||
*/
|
||||
|
||||
// Namespace for the backup
|
||||
M.core_backup = M.core_backup || {};
|
||||
|
||||
/**
|
||||
* Adds select all/none links to the top of the backup/restore/import schema page.
|
||||
*
|
||||
* @class M.core_backup.backupselectall
|
||||
*/
|
||||
M.core_backup.backupselectall = function(modnames) {
|
||||
var formid = null;
|
||||
|
||||
var helper = function(e, check, type, mod) {
|
||||
e.preventDefault();
|
||||
var prefix = '';
|
||||
if (typeof mod !== 'undefined') {
|
||||
prefix = 'setting_activity_' + mod + '_';
|
||||
}
|
||||
|
||||
var len = type.length;
|
||||
Y.all('input[type="checkbox"]').each(function(checkbox) {
|
||||
var name = checkbox.get('name');
|
||||
// If a prefix has been set, ignore checkboxes which don't have that prefix.
|
||||
if (prefix && name.substring(0, prefix.length) !== prefix) {
|
||||
return;
|
||||
}
|
||||
if (name.substring(name.length - len) === type) {
|
||||
checkbox.set('checked', check);
|
||||
}
|
||||
});
|
||||
|
||||
// At this point, we really need to persuade the form we are part of to
|
||||
// update all of its disabledIf rules. However, as far as I can see,
|
||||
// given the way that lib/form/form.js is written, that is impossible.
|
||||
if (formid && M.form) {
|
||||
M.form.updateFormState(formid);
|
||||
}
|
||||
};
|
||||
|
||||
var html_generator = function(classname, idtype, heading, extra) {
|
||||
if (typeof extra === 'undefined') {
|
||||
extra = '';
|
||||
}
|
||||
return '<div class="' + classname + '">' +
|
||||
'<div class="fitem fitem_fcheckbox backup_selector">' +
|
||||
'<div class="fitemtitle">' + heading + '</div>' +
|
||||
'<div class="felement">' +
|
||||
'<a id="backup-all-' + idtype + '" href="#">' + M.util.get_string('all', 'moodle') + '</a> / ' +
|
||||
'<a id="backup-none-' + idtype + '" href="#">' + M.util.get_string('none', 'moodle') + '</a>' +
|
||||
extra +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
};
|
||||
|
||||
var firstsection = Y.one('fieldset#id_coursesettings .fcontainer .grouped_settings.section_level');
|
||||
if (!firstsection) {
|
||||
// This is not a relevant page.
|
||||
return;
|
||||
}
|
||||
if (!firstsection.one('input[type="checkbox"]')) {
|
||||
// No checkboxes.
|
||||
return;
|
||||
}
|
||||
|
||||
formid = firstsection.ancestor('form').getAttribute('id');
|
||||
|
||||
var withuserdata = false;
|
||||
Y.all('input[type="checkbox"]').each(function(checkbox) {
|
||||
var name = checkbox.get('name');
|
||||
if (name.substring(name.length - 9) === '_userdata') {
|
||||
withuserdata = '_userdata';
|
||||
} else if (name.substring(name.length - 9) === '_userinfo') {
|
||||
withuserdata = '_userinfo';
|
||||
}
|
||||
});
|
||||
|
||||
// Add global select all/none options.
|
||||
var html = html_generator('include_setting section_level', 'included', M.util.get_string('select', 'moodle'),
|
||||
' (<a id="backup-bytype" href="#">' + M.util.get_string('showtypes', 'backup') + '</a>)');
|
||||
if (withuserdata) {
|
||||
html += html_generator('normal_setting', 'userdata', M.util.get_string('select', 'moodle'));
|
||||
}
|
||||
var links = Y.Node.create('<div class="grouped_settings section_level">' + html + '</div>');
|
||||
firstsection.insert(links, 'before');
|
||||
|
||||
// Add select all/none for each module type.
|
||||
var initlinks = function(links, mod) {
|
||||
Y.one('#backup-all-mod_' + mod).on('click', function(e) {
|
||||
helper(e, true, '_included', mod);
|
||||
});
|
||||
Y.one('#backup-none-mod_' + mod).on('click', function(e) {
|
||||
helper(e, false, '_included', mod);
|
||||
});
|
||||
if (withuserdata) {
|
||||
Y.one('#backup-all-userdata-mod_' + mod).on('click', function(e) {
|
||||
helper(e, true, withuserdata, mod);
|
||||
});
|
||||
Y.one('#backup-none-userdata-mod_' + mod).on('click', function(e) {
|
||||
helper(e, false, withuserdata, mod);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// For each module type on the course, add hidden select all/none options.
|
||||
var modlist = Y.Node.create('<div id="mod_select_links">');
|
||||
modlist.hide();
|
||||
modlist.currentlyshown = false;
|
||||
links.appendChild(modlist);
|
||||
for (var mod in modnames) {
|
||||
// Only include actual values from the list.
|
||||
if (!modnames.hasOwnProperty(mod)) {
|
||||
continue;
|
||||
}
|
||||
html = html_generator('include_setting section_level', 'mod_' + mod, modnames[mod]);
|
||||
if (withuserdata) {
|
||||
html += html_generator('normal_setting', 'userdata-mod_' + mod, modnames[mod]);
|
||||
}
|
||||
var modlinks = Y.Node.create(
|
||||
'<div class="grouped_settings section_level">' + html + '</div>');
|
||||
modlist.appendChild(modlinks);
|
||||
initlinks(modlinks, mod);
|
||||
}
|
||||
|
||||
// Toggles the display of the hidden module select all/none links.
|
||||
var toggletypes = function() {
|
||||
// Change text of type toggle link.
|
||||
var link = Y.one('#backup-bytype');
|
||||
if (modlist.currentlyshown) {
|
||||
link.setHTML(M.util.get_string('showtypes', 'backup'));
|
||||
} else {
|
||||
link.setHTML(M.util.get_string('hidetypes', 'backup'));
|
||||
}
|
||||
|
||||
// The link has now been toggled (from show to hide, or vice-versa).
|
||||
modlist.currentlyshown = !modlist.currentlyshown;
|
||||
|
||||
// Either hide or show the links.
|
||||
var animcfg = {node: modlist, duration: 0.2},
|
||||
anim;
|
||||
if (modlist.currentlyshown) {
|
||||
// Animate reveal of the module links.
|
||||
modlist.show();
|
||||
animcfg.to = {maxHeight: modlist.get('clientHeight') + 'px'};
|
||||
modlist.setStyle('maxHeight', '0px');
|
||||
anim = new Y.Anim(animcfg);
|
||||
anim.on('end', function() {
|
||||
modlist.setStyle('maxHeight', 'none');
|
||||
});
|
||||
anim.run();
|
||||
} else {
|
||||
// Animate hide of the module links.
|
||||
animcfg.to = {maxHeight: '0px'};
|
||||
modlist.setStyle('maxHeight', modlist.get('clientHeight') + 'px');
|
||||
anim = new Y.Anim(animcfg);
|
||||
anim.on('end', function() {
|
||||
modlist.hide();
|
||||
modlist.setStyle('maxHeight', 'none');
|
||||
});
|
||||
anim.run();
|
||||
}
|
||||
|
||||
};
|
||||
Y.one('#backup-bytype').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
toggletypes();
|
||||
});
|
||||
|
||||
Y.one('#backup-all-included').on('click', function(e) {
|
||||
helper(e, true, '_included');
|
||||
});
|
||||
Y.one('#backup-none-included').on('click', function(e) {
|
||||
helper(e, false, '_included');
|
||||
});
|
||||
if (withuserdata) {
|
||||
Y.one('#backup-all-userdata').on('click', function(e) {
|
||||
helper(e, true, withuserdata);
|
||||
});
|
||||
Y.one('#backup-none-userdata').on('click', function(e) {
|
||||
helper(e, false, withuserdata);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}, '@VERSION@', {"requires": ["node", "event", "node-event-simulate", "anim"]});
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"name": "moodle-backup-backupselectall",
|
||||
"builds": {
|
||||
"moodle-backup-backupselectall": {
|
||||
"jsfiles": [
|
||||
"backupselectall.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
/**
|
||||
* Adds select all/none links to the top of the backup/restore/import schema page.
|
||||
*
|
||||
* @module moodle-backup-backupselectall
|
||||
*/
|
||||
|
||||
// Namespace for the backup
|
||||
M.core_backup = M.core_backup || {};
|
||||
|
||||
/**
|
||||
* Adds select all/none links to the top of the backup/restore/import schema page.
|
||||
*
|
||||
* @class M.core_backup.backupselectall
|
||||
*/
|
||||
M.core_backup.backupselectall = function(modnames) {
|
||||
var formid = null;
|
||||
|
||||
var helper = function(e, check, type, mod) {
|
||||
e.preventDefault();
|
||||
var prefix = '';
|
||||
if (typeof mod !== 'undefined') {
|
||||
prefix = 'setting_activity_' + mod + '_';
|
||||
}
|
||||
|
||||
var len = type.length;
|
||||
Y.all('input[type="checkbox"]').each(function(checkbox) {
|
||||
var name = checkbox.get('name');
|
||||
// If a prefix has been set, ignore checkboxes which don't have that prefix.
|
||||
if (prefix && name.substring(0, prefix.length) !== prefix) {
|
||||
return;
|
||||
}
|
||||
if (name.substring(name.length - len) === type) {
|
||||
checkbox.set('checked', check);
|
||||
}
|
||||
});
|
||||
|
||||
// At this point, we really need to persuade the form we are part of to
|
||||
// update all of its disabledIf rules. However, as far as I can see,
|
||||
// given the way that lib/form/form.js is written, that is impossible.
|
||||
if (formid && M.form) {
|
||||
M.form.updateFormState(formid);
|
||||
}
|
||||
};
|
||||
|
||||
var html_generator = function(classname, idtype, heading, extra) {
|
||||
if (typeof extra === 'undefined') {
|
||||
extra = '';
|
||||
}
|
||||
return '<div class="' + classname + '">' +
|
||||
'<div class="fitem fitem_fcheckbox backup_selector">' +
|
||||
'<div class="fitemtitle">' + heading + '</div>' +
|
||||
'<div class="felement">' +
|
||||
'<a id="backup-all-' + idtype + '" href="#">' + M.util.get_string('all', 'moodle') + '</a> / ' +
|
||||
'<a id="backup-none-' + idtype + '" href="#">' + M.util.get_string('none', 'moodle') + '</a>' +
|
||||
extra +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
};
|
||||
|
||||
var firstsection = Y.one('fieldset#id_coursesettings .fcontainer .grouped_settings.section_level');
|
||||
if (!firstsection) {
|
||||
// This is not a relevant page.
|
||||
return;
|
||||
}
|
||||
if (!firstsection.one('input[type="checkbox"]')) {
|
||||
// No checkboxes.
|
||||
return;
|
||||
}
|
||||
|
||||
formid = firstsection.ancestor('form').getAttribute('id');
|
||||
|
||||
var withuserdata = false;
|
||||
Y.all('input[type="checkbox"]').each(function(checkbox) {
|
||||
var name = checkbox.get('name');
|
||||
if (name.substring(name.length - 9) === '_userdata') {
|
||||
withuserdata = '_userdata';
|
||||
} else if (name.substring(name.length - 9) === '_userinfo') {
|
||||
withuserdata = '_userinfo';
|
||||
}
|
||||
});
|
||||
|
||||
// Add global select all/none options.
|
||||
var html = html_generator('include_setting section_level', 'included', M.util.get_string('select', 'moodle'),
|
||||
' (<a id="backup-bytype" href="#">' + M.util.get_string('showtypes', 'backup') + '</a>)');
|
||||
if (withuserdata) {
|
||||
html += html_generator('normal_setting', 'userdata', M.util.get_string('select', 'moodle'));
|
||||
}
|
||||
var links = Y.Node.create('<div class="grouped_settings section_level">' + html + '</div>');
|
||||
firstsection.insert(links, 'before');
|
||||
|
||||
// Add select all/none for each module type.
|
||||
var initlinks = function(links, mod) {
|
||||
Y.one('#backup-all-mod_' + mod).on('click', function(e) {
|
||||
helper(e, true, '_included', mod);
|
||||
});
|
||||
Y.one('#backup-none-mod_' + mod).on('click', function(e) {
|
||||
helper(e, false, '_included', mod);
|
||||
});
|
||||
if (withuserdata) {
|
||||
Y.one('#backup-all-userdata-mod_' + mod).on('click', function(e) {
|
||||
helper(e, true, withuserdata, mod);
|
||||
});
|
||||
Y.one('#backup-none-userdata-mod_' + mod).on('click', function(e) {
|
||||
helper(e, false, withuserdata, mod);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// For each module type on the course, add hidden select all/none options.
|
||||
var modlist = Y.Node.create('<div id="mod_select_links">');
|
||||
modlist.hide();
|
||||
modlist.currentlyshown = false;
|
||||
links.appendChild(modlist);
|
||||
for (var mod in modnames) {
|
||||
// Only include actual values from the list.
|
||||
if (!modnames.hasOwnProperty(mod)) {
|
||||
continue;
|
||||
}
|
||||
html = html_generator('include_setting section_level', 'mod_' + mod, modnames[mod]);
|
||||
if (withuserdata) {
|
||||
html += html_generator('normal_setting', 'userdata-mod_' + mod, modnames[mod]);
|
||||
}
|
||||
var modlinks = Y.Node.create(
|
||||
'<div class="grouped_settings section_level">' + html + '</div>');
|
||||
modlist.appendChild(modlinks);
|
||||
initlinks(modlinks, mod);
|
||||
}
|
||||
|
||||
// Toggles the display of the hidden module select all/none links.
|
||||
var toggletypes = function() {
|
||||
// Change text of type toggle link.
|
||||
var link = Y.one('#backup-bytype');
|
||||
if (modlist.currentlyshown) {
|
||||
link.setHTML(M.util.get_string('showtypes', 'backup'));
|
||||
} else {
|
||||
link.setHTML(M.util.get_string('hidetypes', 'backup'));
|
||||
}
|
||||
|
||||
// The link has now been toggled (from show to hide, or vice-versa).
|
||||
modlist.currentlyshown = !modlist.currentlyshown;
|
||||
|
||||
// Either hide or show the links.
|
||||
var animcfg = {node: modlist, duration: 0.2},
|
||||
anim;
|
||||
if (modlist.currentlyshown) {
|
||||
// Animate reveal of the module links.
|
||||
modlist.show();
|
||||
animcfg.to = {maxHeight: modlist.get('clientHeight') + 'px'};
|
||||
modlist.setStyle('maxHeight', '0px');
|
||||
anim = new Y.Anim(animcfg);
|
||||
anim.on('end', function() {
|
||||
modlist.setStyle('maxHeight', 'none');
|
||||
});
|
||||
anim.run();
|
||||
} else {
|
||||
// Animate hide of the module links.
|
||||
animcfg.to = {maxHeight: '0px'};
|
||||
modlist.setStyle('maxHeight', modlist.get('clientHeight') + 'px');
|
||||
anim = new Y.Anim(animcfg);
|
||||
anim.on('end', function() {
|
||||
modlist.hide();
|
||||
modlist.setStyle('maxHeight', 'none');
|
||||
});
|
||||
anim.run();
|
||||
}
|
||||
|
||||
};
|
||||
Y.one('#backup-bytype').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
toggletypes();
|
||||
});
|
||||
|
||||
Y.one('#backup-all-included').on('click', function(e) {
|
||||
helper(e, true, '_included');
|
||||
});
|
||||
Y.one('#backup-none-included').on('click', function(e) {
|
||||
helper(e, false, '_included');
|
||||
});
|
||||
if (withuserdata) {
|
||||
Y.one('#backup-all-userdata').on('click', function(e) {
|
||||
helper(e, true, withuserdata);
|
||||
});
|
||||
Y.one('#backup-none-userdata').on('click', function(e) {
|
||||
helper(e, false, withuserdata);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"moodle-backup-backupselectall": {
|
||||
"requires": [
|
||||
"node",
|
||||
"event",
|
||||
"node-event-simulate",
|
||||
"anim"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -3090,9 +3090,6 @@ blockquote {
|
||||
/* Showmore component */
|
||||
.showmore-container {
|
||||
&.collapsed {
|
||||
.collapsed-content {
|
||||
display: block;
|
||||
}
|
||||
.expanded-content {
|
||||
display: none;
|
||||
}
|
||||
@@ -3101,9 +3098,6 @@ blockquote {
|
||||
.collapsed-content {
|
||||
display: none;
|
||||
}
|
||||
.expanded-content {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
button {
|
||||
float: right;
|
||||
|
||||
@@ -26002,18 +26002,12 @@ blockquote {
|
||||
}
|
||||
|
||||
/* Showmore component */
|
||||
.showmore-container.collapsed .collapsed-content {
|
||||
display: block;
|
||||
}
|
||||
.showmore-container.collapsed .expanded-content {
|
||||
display: none;
|
||||
}
|
||||
.showmore-container:not(.collapsed) .collapsed-content {
|
||||
display: none;
|
||||
}
|
||||
.showmore-container:not(.collapsed) .expanded-content {
|
||||
display: block;
|
||||
}
|
||||
.showmore-container button {
|
||||
float: right;
|
||||
}
|
||||
|
||||
@@ -26002,18 +26002,12 @@ blockquote {
|
||||
}
|
||||
|
||||
/* Showmore component */
|
||||
.showmore-container.collapsed .collapsed-content {
|
||||
display: block;
|
||||
}
|
||||
.showmore-container.collapsed .expanded-content {
|
||||
display: none;
|
||||
}
|
||||
.showmore-container:not(.collapsed) .collapsed-content {
|
||||
display: none;
|
||||
}
|
||||
.showmore-container:not(.collapsed) .expanded-content {
|
||||
display: block;
|
||||
}
|
||||
.showmore-container button {
|
||||
float: right;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user