mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed few issues with the backform custom controls.
- Fixed the server backend version check for any schema object. - Fixed the switch control, it was not enable to toggle the values properly. - Fixed the editableCell to work properly in the collection properties.
This commit is contained in:
@@ -35,16 +35,15 @@
|
|||||||
|
|
||||||
var pgAdmin = (window.pgAdmin = window.pgAdmin || {});
|
var pgAdmin = (window.pgAdmin = window.pgAdmin || {});
|
||||||
|
|
||||||
pgAdmin.editableCell = function(m) {
|
pgAdmin.editableCell = function() {
|
||||||
if (this.attributes && this.attributes.disabled) {
|
if (this.attributes && this.attributes.disabled) {
|
||||||
if(_.isFunction(this.attributes.disabled)) {
|
if(_.isFunction(this.attributes.disabled)) {
|
||||||
return !(this.attributes.disabled.apply(this, [m]));
|
return !(this.attributes.disabled.apply(this, [arguments]));
|
||||||
}
|
}
|
||||||
if (_.isBoolean(this.attributes.disabled)) {
|
if (_.isBoolean(this.attributes.disabled)) {
|
||||||
return !this.attributes.disabled;
|
return !this.attributes.disabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// HTML markup global class names. More can be added by individual controls
|
// HTML markup global class names. More can be added by individual controls
|
||||||
@@ -176,7 +175,6 @@
|
|||||||
// Requires the Bootstrap Switch to work.
|
// Requires the Bootstrap Switch to work.
|
||||||
var SwitchControl = Backform.SwitchControl = Backform.InputControl.extend({
|
var SwitchControl = Backform.SwitchControl = Backform.InputControl.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
type: "checkbox",
|
|
||||||
label: "",
|
label: "",
|
||||||
options: {},
|
options: {},
|
||||||
extraClasses: [],
|
extraClasses: [],
|
||||||
@@ -191,17 +189,18 @@
|
|||||||
'<div class="<%=Backform.controlsClassName%>">',
|
'<div class="<%=Backform.controlsClassName%>">',
|
||||||
' <div class="checkbox">',
|
' <div class="checkbox">',
|
||||||
' <label>',
|
' <label>',
|
||||||
' <input type="<%=type%>" class="<%=extraClasses.join(\' \')%>" name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%> <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
|
' <input type="checkbox" class="<%=extraClasses.join(\' \')%>" name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%> <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
|
||||||
' </label>',
|
' </label>',
|
||||||
' </div>',
|
' </div>',
|
||||||
'</div>'
|
'</div>'
|
||||||
].join("\n")),
|
].join("\n")),
|
||||||
getValueFromDOM: function() {
|
getValueFromDOM: function() {
|
||||||
return this.formatter.toRaw(
|
return this.formatter.toRaw(
|
||||||
this.$el.find(".input").data('switch-get'),
|
this.$input.prop('checked'),
|
||||||
this.model
|
this.model
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
events: {'switchChange.bootstrapSwitch': 'onChange'},
|
||||||
render: function() {
|
render: function() {
|
||||||
var field = _.defaults(this.field.toJSON(), this.defaults),
|
var field = _.defaults(this.field.toJSON(), this.defaults),
|
||||||
attributes = this.model.toJSON(),
|
attributes = this.model.toJSON(),
|
||||||
@@ -211,9 +210,10 @@
|
|||||||
rawValue = this.keyPathAccessor(attributes[name], path);
|
rawValue = this.keyPathAccessor(attributes[name], path);
|
||||||
|
|
||||||
Backform.InputControl.prototype.render.apply(this, arguments);
|
Backform.InputControl.prototype.render.apply(this, arguments);
|
||||||
|
this.$input = this.$el.find("input[type=checkbox]").first();
|
||||||
|
|
||||||
//Check & set additional properties
|
//Check & set additional properties
|
||||||
this.$el.find("input").bootstrapSwitch({
|
this.$input.bootstrapSwitch({
|
||||||
'onText': field.onText,
|
'onText': field.onText,
|
||||||
'offText': field.offText,
|
'offText': field.offText,
|
||||||
'onColor': field.onColor,
|
'onColor': field.onColor,
|
||||||
@@ -561,7 +561,7 @@
|
|||||||
// Each field is kept in specified group, or in
|
// Each field is kept in specified group, or in
|
||||||
// 'General' category.
|
// 'General' category.
|
||||||
var group = s.group || pgBrowser.messages.general_cateogty,
|
var group = s.group || pgBrowser.messages.general_cateogty,
|
||||||
control = Backform.getMappedControl(s.type, mode),
|
control = s.control || Backform.getMappedControl(s.type, mode),
|
||||||
cell = s.cell || Backform.getMappedControl(s.type, 'cell');
|
cell = s.cell || Backform.getMappedControl(s.type, 'cell');
|
||||||
|
|
||||||
if (control == null) {
|
if (control == null) {
|
||||||
@@ -573,8 +573,8 @@
|
|||||||
var disabled = ((mode == 'properties') ||
|
var disabled = ((mode == 'properties') ||
|
||||||
(server_info &&
|
(server_info &&
|
||||||
(s.server_type && !(server_info.type in s.server_type)) ||
|
(s.server_type && !(server_info.type in s.server_type)) ||
|
||||||
(s.min_version && s.min_version < server_info.version) ||
|
(s.min_version && server_info.version < s.min_version) ||
|
||||||
(s.max_version && s.max_version > server_info.version)
|
(s.max_version && server_info.version > s.max_version)
|
||||||
));
|
));
|
||||||
|
|
||||||
var o = _.extend(_.clone(s), {
|
var o = _.extend(_.clone(s), {
|
||||||
@@ -584,7 +584,7 @@
|
|||||||
// This can be disabled in some cases (if not hidden)
|
// This can be disabled in some cases (if not hidden)
|
||||||
|
|
||||||
disabled: (disabled ? true : evalASFunc(s.disabled)),
|
disabled: (disabled ? true : evalASFunc(s.disabled)),
|
||||||
editable: (disabled ? false : pgAdmin.editableCell),
|
editable: (disabled ? false : (_.isUndefined(s.editable) ? pgAdmin.editableCell : !!(s.editable))),
|
||||||
subnode: ((_.isString(s.model) && s.model in pgBrowser.Nodes) ?
|
subnode: ((_.isString(s.model) && s.model in pgBrowser.Nodes) ?
|
||||||
pgBrowser.Nodes[s.model].model : s.model),
|
pgBrowser.Nodes[s.model].model : s.model),
|
||||||
canAdd: (disabled ? false : evalASFunc(s.canAdd)),
|
canAdd: (disabled ? false : evalASFunc(s.canAdd)),
|
||||||
|
|||||||
Reference in New Issue
Block a user