mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
Merge branch 'MDL-71402' of git://github.com/paulholden/moodle
This commit is contained in:
commit
e41ff4f15e
@ -198,8 +198,11 @@ M.core_availability.form = {
|
||||
// If the groupmode and grouping id aren't set, disable it.
|
||||
var groupmode = Y.one('#id_groupmode');
|
||||
var groupingid = Y.one('#id_groupingid');
|
||||
if ((!groupmode || Number(groupmode.get('value')) === 0) &&
|
||||
(!groupingid || Number(groupingid.get('value')) === 0)) {
|
||||
var groupavailability = Number(this.restrictByGroup.getData('groupavailability')) === 1;
|
||||
var groupingavailability = Number(this.restrictByGroup.getData('groupingavailability')) === 1;
|
||||
|
||||
if ((!groupmode || Number(groupmode.get('value')) === 0 || !groupavailability) &&
|
||||
(!groupingid || Number(groupingid.get('value')) === 0 || !groupingavailability)) {
|
||||
this.restrictByGroup.set('disabled', true);
|
||||
return;
|
||||
}
|
||||
@ -220,22 +223,28 @@ M.core_availability.form = {
|
||||
e.preventDefault();
|
||||
|
||||
// Add the condition.
|
||||
var groupmode = Y.one('#id_groupmode');
|
||||
var groupingid = Y.one('#id_groupingid');
|
||||
var groupavailability = Number(this.restrictByGroup.getData('groupavailability')) === 1;
|
||||
var groupingavailability = Number(this.restrictByGroup.getData('groupingavailability')) === 1;
|
||||
|
||||
var newChild;
|
||||
if (groupingid && Number(groupingid.get('value')) !== 0) {
|
||||
if (groupingid && Number(groupingid.get('value')) !== 0 && groupingavailability) {
|
||||
// Add a grouping restriction if one is specified.
|
||||
newChild = new M.core_availability.Item(
|
||||
{type: 'grouping', id: Number(groupingid.get('value'))}, true);
|
||||
} else {
|
||||
} else if (groupmode && groupavailability) {
|
||||
// Otherwise just add a group restriction.
|
||||
newChild = new M.core_availability.Item({type: 'group'}, true);
|
||||
}
|
||||
|
||||
// Refresh HTML.
|
||||
this.rootList.addChild(newChild);
|
||||
this.update();
|
||||
this.rootList.renumber();
|
||||
this.rootList.updateHtml();
|
||||
if (newChild !== null) {
|
||||
this.rootList.addChild(newChild);
|
||||
this.update();
|
||||
this.rootList.renumber();
|
||||
this.rootList.updateHtml();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -198,8 +198,11 @@ M.core_availability.form = {
|
||||
// If the groupmode and grouping id aren't set, disable it.
|
||||
var groupmode = Y.one('#id_groupmode');
|
||||
var groupingid = Y.one('#id_groupingid');
|
||||
if ((!groupmode || Number(groupmode.get('value')) === 0) &&
|
||||
(!groupingid || Number(groupingid.get('value')) === 0)) {
|
||||
var groupavailability = Number(this.restrictByGroup.getData('groupavailability')) === 1;
|
||||
var groupingavailability = Number(this.restrictByGroup.getData('groupingavailability')) === 1;
|
||||
|
||||
if ((!groupmode || Number(groupmode.get('value')) === 0 || !groupavailability) &&
|
||||
(!groupingid || Number(groupingid.get('value')) === 0 || !groupingavailability)) {
|
||||
this.restrictByGroup.set('disabled', true);
|
||||
return;
|
||||
}
|
||||
@ -220,22 +223,28 @@ M.core_availability.form = {
|
||||
e.preventDefault();
|
||||
|
||||
// Add the condition.
|
||||
var groupmode = Y.one('#id_groupmode');
|
||||
var groupingid = Y.one('#id_groupingid');
|
||||
var groupavailability = Number(this.restrictByGroup.getData('groupavailability')) === 1;
|
||||
var groupingavailability = Number(this.restrictByGroup.getData('groupingavailability')) === 1;
|
||||
|
||||
var newChild;
|
||||
if (groupingid && Number(groupingid.get('value')) !== 0) {
|
||||
if (groupingid && Number(groupingid.get('value')) !== 0 && groupingavailability) {
|
||||
// Add a grouping restriction if one is specified.
|
||||
newChild = new M.core_availability.Item(
|
||||
{type: 'grouping', id: Number(groupingid.get('value'))}, true);
|
||||
} else {
|
||||
} else if (groupmode && groupavailability) {
|
||||
// Otherwise just add a group restriction.
|
||||
newChild = new M.core_availability.Item({type: 'group'}, true);
|
||||
}
|
||||
|
||||
// Refresh HTML.
|
||||
this.rootList.addChild(newChild);
|
||||
this.update();
|
||||
this.rootList.renumber();
|
||||
this.rootList.updateHtml();
|
||||
if (newChild !== null) {
|
||||
this.rootList.addChild(newChild);
|
||||
this.update();
|
||||
this.rootList.renumber();
|
||||
this.rootList.updateHtml();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
25
availability/yui/src/form/js/form.js
vendored
25
availability/yui/src/form/js/form.js
vendored
@ -196,8 +196,11 @@ M.core_availability.form = {
|
||||
// If the groupmode and grouping id aren't set, disable it.
|
||||
var groupmode = Y.one('#id_groupmode');
|
||||
var groupingid = Y.one('#id_groupingid');
|
||||
if ((!groupmode || Number(groupmode.get('value')) === 0) &&
|
||||
(!groupingid || Number(groupingid.get('value')) === 0)) {
|
||||
var groupavailability = Number(this.restrictByGroup.getData('groupavailability')) === 1;
|
||||
var groupingavailability = Number(this.restrictByGroup.getData('groupingavailability')) === 1;
|
||||
|
||||
if ((!groupmode || Number(groupmode.get('value')) === 0 || !groupavailability) &&
|
||||
(!groupingid || Number(groupingid.get('value')) === 0 || !groupingavailability)) {
|
||||
this.restrictByGroup.set('disabled', true);
|
||||
return;
|
||||
}
|
||||
@ -218,22 +221,28 @@ M.core_availability.form = {
|
||||
e.preventDefault();
|
||||
|
||||
// Add the condition.
|
||||
var groupmode = Y.one('#id_groupmode');
|
||||
var groupingid = Y.one('#id_groupingid');
|
||||
var groupavailability = Number(this.restrictByGroup.getData('groupavailability')) === 1;
|
||||
var groupingavailability = Number(this.restrictByGroup.getData('groupingavailability')) === 1;
|
||||
|
||||
var newChild;
|
||||
if (groupingid && Number(groupingid.get('value')) !== 0) {
|
||||
if (groupingid && Number(groupingid.get('value')) !== 0 && groupingavailability) {
|
||||
// Add a grouping restriction if one is specified.
|
||||
newChild = new M.core_availability.Item(
|
||||
{type: 'grouping', id: Number(groupingid.get('value'))}, true);
|
||||
} else {
|
||||
} else if (groupmode && groupavailability) {
|
||||
// Otherwise just add a group restriction.
|
||||
newChild = new M.core_availability.Item({type: 'group'}, true);
|
||||
}
|
||||
|
||||
// Refresh HTML.
|
||||
this.rootList.addChild(newChild);
|
||||
this.update();
|
||||
this.rootList.renumber();
|
||||
this.rootList.updateHtml();
|
||||
if (newChild !== null) {
|
||||
this.rootList.addChild(newChild);
|
||||
this.update();
|
||||
this.rootList.renumber();
|
||||
this.rootList.updateHtml();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -623,10 +623,23 @@ abstract class moodleform_mod extends moodleform {
|
||||
if (!empty($CFG->enableavailability)) {
|
||||
// Add special button to end of previous section if groups/groupings
|
||||
// are enabled.
|
||||
if ($this->_features->groups || $this->_features->groupings) {
|
||||
|
||||
$availabilityplugins = \core\plugininfo\availability::get_enabled_plugins();
|
||||
$groupavailability = $this->_features->groups && array_key_exists('group', $availabilityplugins);
|
||||
$groupingavailability = $this->_features->groupings && array_key_exists('grouping', $availabilityplugins);
|
||||
|
||||
if ($groupavailability || $groupingavailability) {
|
||||
// When creating the button, we need to set type=button to prevent it behaving as a submit.
|
||||
$mform->addElement('static', 'restrictgroupbutton', '',
|
||||
html_writer::tag('button', get_string('restrictbygroup', 'availability'),
|
||||
array('id' => 'restrictbygroup', 'disabled' => 'disabled', 'class' => 'btn btn-secondary')));
|
||||
html_writer::tag('button', get_string('restrictbygroup', 'availability'), [
|
||||
'id' => 'restrictbygroup',
|
||||
'type' => 'button',
|
||||
'disabled' => 'disabled',
|
||||
'class' => 'btn btn-secondary',
|
||||
'data-groupavailability' => $groupavailability,
|
||||
'data-groupingavailability' => $groupingavailability
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
// Availability field. This is just a textarea; the user interface
|
||||
|
Loading…
x
Reference in New Issue
Block a user