mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Evaluate the disabled option in SwitchControl.
Also - for consistency reason use the same evaluation logic in each of the control.
This commit is contained in:
parent
12a0cb1ba1
commit
219f208317
@ -447,8 +447,13 @@
|
|||||||
name = attrArr.shift(),
|
name = attrArr.shift(),
|
||||||
path = attrArr.join('.'),
|
path = attrArr.join('.'),
|
||||||
rawValue = this.keyPathAccessor(attributes[name], path),
|
rawValue = this.keyPathAccessor(attributes[name], path),
|
||||||
options = _.defaults({}, this.field.get('options'), this.defaults.options,
|
evalF = function(f, d, m) {
|
||||||
$.fn.bootstrapSwitch.defaults);
|
return (_.isFunction(f) ? !!f.apply(d, [m]) : !!f);
|
||||||
|
},
|
||||||
|
options = _.defaults({
|
||||||
|
disabled: evalF(field.disabled, field, this.model)
|
||||||
|
}, this.field.get('options'), this.defaults.options,
|
||||||
|
$.fn.bootstrapSwitch.defaults);
|
||||||
|
|
||||||
Backform.InputControl.prototype.render.apply(this, arguments);
|
Backform.InputControl.prototype.render.apply(this, arguments);
|
||||||
this.$input = this.$el.find("input[type=checkbox]").first();
|
this.$input = this.$el.find("input[type=checkbox]").first();
|
||||||
@ -1109,18 +1114,18 @@
|
|||||||
attributes: attributes,
|
attributes: attributes,
|
||||||
formatter: this.formatter
|
formatter: this.formatter
|
||||||
}),
|
}),
|
||||||
evalF = function(f, m) {
|
evalF = function(f, d, m) {
|
||||||
return (_.isFunction(f) ? !!f(m) : !!f);
|
return (_.isFunction(f) ? !!f.apply(d, [m]) : !!f);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Evaluate the disabled, visible, required, canAdd, cannEdit & canDelete option
|
// Evaluate the disabled, visible, required, canAdd, cannEdit & canDelete option
|
||||||
_.extend(data, {
|
_.extend(data, {
|
||||||
disabled: evalF(data.disabled, this.model),
|
disabled: evalF(data.disabled, data, this.model),
|
||||||
visible: evalF(data.visible, this.model),
|
visible: evalF(data.visible, data, this.model),
|
||||||
required: evalF(data.required, this.model),
|
required: evalF(data.required, data, this.model),
|
||||||
canAdd: evalF(data.canAdd, this.model),
|
canAdd: evalF(data.canAdd, data, this.model),
|
||||||
canEdit: evalF(data.canEdit, this.model),
|
canEdit: evalF(data.canEdit, data, this.model),
|
||||||
canDelete: evalF(data.canDelete, this.model)
|
canDelete: evalF(data.canDelete, data, this.model)
|
||||||
});
|
});
|
||||||
// Show Backgrid Control
|
// Show Backgrid Control
|
||||||
grid = (data.subnode == undefined) ? "" : this.showGridControl(data);
|
grid = (data.subnode == undefined) ? "" : this.showGridControl(data);
|
||||||
|
Loading…
Reference in New Issue
Block a user