mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Defined SwitchDepsCell in the schema javascript module, because - it
will be loaded before every other javascript module requires this Cell.
This commit is contained in:
parent
05dde57651
commit
d20db0f43e
@ -140,9 +140,10 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
|
||||
cellHeaderClasses:'width_percent_30',
|
||||
editable: 'editable_check_for_table'
|
||||
},{
|
||||
// Need to show this field only when creating new table [in SubNode control]
|
||||
id: 'is_primary_key', label: '{{ _('Is primary key?') }}', cell: SwitchDepCell,
|
||||
type: 'switch', deps:['name'],
|
||||
// Need to show this field only when creating new table
|
||||
// [in SubNode control]
|
||||
id: 'is_primary_key', label: '{{ _('Is primary key?') }}',
|
||||
cell: Backgrid.Extension.SwitchDepCell, type: 'switch', deps:['name'],
|
||||
options: {
|
||||
onText: 'Yes', offText: 'No', onColor: 'success',
|
||||
offColor: 'primary', size: 'small'},
|
||||
|
@ -99,8 +99,9 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
|
||||
return options;
|
||||
}
|
||||
},{
|
||||
id: 'sort_order', label:'{{ _('Sort order') }}', cell: SwitchDepCell,
|
||||
type: 'switch', disabled: 'checkAccessMethod',
|
||||
id: 'sort_order', label:'{{ _('Sort order') }}',
|
||||
cell: Backgrid.ExtensionSwitchDepCell, type: 'switch',
|
||||
disabled: 'checkAccessMethod',
|
||||
editable: function(m) {
|
||||
// Header cell then skip
|
||||
if (m instanceof Backbone.Collection) {
|
||||
@ -115,8 +116,9 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
|
||||
'size': 'small'
|
||||
}
|
||||
},{
|
||||
id: 'nulls', label:'{{ _('NULLs') }}', cell: SwitchDepCell,
|
||||
type: 'switch', disabled: 'checkAccessMethod',
|
||||
id: 'nulls', label:'{{ _('NULLs') }}',
|
||||
cell: Backgrid.Extension.SwitchDepCell, type: 'switch',
|
||||
disabled: 'checkAccessMethod',
|
||||
editable: function(m) {
|
||||
// Header cell then skip
|
||||
if (m instanceof Backbone.Collection) {
|
||||
|
@ -16,33 +16,6 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||
});
|
||||
};
|
||||
|
||||
// Switch Cell with Deps
|
||||
var SwitchDepCell = Backgrid.Extension.SwitchCell.extend({
|
||||
initialize: function() {
|
||||
Backgrid.Extension.SwitchCell.prototype.initialize.apply(this, arguments);
|
||||
Backgrid.Extension.DependentCell.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
dependentChanged: function () {
|
||||
var model = this.model,
|
||||
column = this.column,
|
||||
editable = this.column.get("editable"),
|
||||
input = this.$el.find('input[type=checkbox]').first();
|
||||
|
||||
is_editable = _.isFunction(editable) ? !!editable.apply(column, [model]) : !!editable;
|
||||
if (is_editable) {
|
||||
this.$el.addClass("editable");
|
||||
input.prop('disabled', false);
|
||||
} else {
|
||||
this.$el.removeClass("editable");
|
||||
input.prop('disabled', true);
|
||||
}
|
||||
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
},
|
||||
remove: Backgrid.Extension.DependentCell.prototype.remove
|
||||
});
|
||||
|
||||
if (!pgBrowser.Nodes['table']) {
|
||||
pgAdmin.Browser.Nodes['table'] = pgBrowser.Node.extend({
|
||||
type: 'table',
|
||||
|
@ -128,7 +128,7 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
|
||||
});
|
||||
|
||||
// Extend the browser's collection class for VacuumSettingsModel
|
||||
var VacuumSettingsSchema = Backform.VacuumSettingsSchema =
|
||||
var VacuumSettingsSchema = Backform.VacuumSettingsSchema =
|
||||
[{
|
||||
id: 'autovacuum_custom', label: '{{ _("Custom auto-vacuum?") }}',
|
||||
group: '{{ _("Table") }}', mode: ['edit', 'create'],
|
||||
@ -476,9 +476,36 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
|
||||
// by default we do not want to allow create menu
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// Switch Cell with Deps
|
||||
var SwitchDepCell = Backgrid.Extension.SwitchCell.extend({
|
||||
initialize: function() {
|
||||
Backgrid.Extension.SwitchCell.prototype.initialize.apply(this, arguments);
|
||||
Backgrid.Extension.DependentCell.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
dependentChanged: function () {
|
||||
var model = this.model,
|
||||
column = this.column,
|
||||
editable = this.column.get("editable"),
|
||||
input = this.$el.find('input[type=checkbox]').first();
|
||||
|
||||
is_editable = _.isFunction(editable) ? !!editable.apply(column, [model]) : !!editable;
|
||||
if (is_editable) {
|
||||
this.$el.addClass("editable");
|
||||
input.prop('disabled', false);
|
||||
} else {
|
||||
this.$el.removeClass("editable");
|
||||
input.prop('disabled', true);
|
||||
}
|
||||
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
},
|
||||
remove: Backgrid.Extension.DependentCell.prototype.remove
|
||||
});
|
||||
|
||||
|
||||
return pgBrowser.Nodes['schema'];
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user