The Switch Dependency Cell, implemented in schema module, has a special

case. Its purpose is now to handle certain scinarios specific to table
children modules.

Renamed it to 'TableChildSwitchCell' from 'SwitchDepCell' to avoid any
conflict in future.
pull/3/head
Ashesh Vashi 2016-09-15 13:36:47 +05:30
parent d3d8836f61
commit c48e8d415b
3 changed files with 20 additions and 12 deletions

View File

@ -183,17 +183,25 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
// Need to show this field only when creating new table
// [in SubNode control]
id: 'is_primary_key', label: '{{ _('Primary key?') }}',
cell: Backgrid.Extension.SwitchDepCell, type: 'switch', deps:['name'],
options: { onText: 'Yes', offText: 'No', onColor: 'success', offColor: 'primary' },
cellHeaderClasses:'width_percent_5',
cell: Backgrid.Extension.TableChildSwitchCell, type: 'switch',
deps:['name'], cellHeaderClasses:'width_percent_5',
options: {
onText: '{{ _("Yes") }}', offText: '{{ _("No") }}',
onColor: 'success', offColor: 'primary'
},
visible: function(m) {
return _.isUndefined(m.top.node_info['table'] || m.top.node_info['view'] || m.top.node_info['mview']);
return _.isUndefined(
m.top.node_info['table'] || m.top.node_info['view'] ||
m.top.node_info['mview']
);
},
disabled: function(m){
// If primary key already exist then disable.
if (m.top && !_.isUndefined(m.top.get('oid')) &&
m.top.get('primary_key').length > 0 &&
!_.isUndefined(m.top.get('primary_key').first().get('oid'))) {
if (
m.top && !_.isUndefined(m.top.get('oid')) &&
m.top.get('primary_key').length > 0 &&
!_.isUndefined(m.top.get('primary_key').first().get('oid'))
) {
return true;
}

View File

@ -107,7 +107,7 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
}
},{
id: 'sort_order', label:'{{ _('Sort order') }}',
cell: Backgrid.Extension.SwitchDepCell, type: 'switch',
cell: Backgrid.Extension.TableChildSwitchCell, type: 'switch',
disabled: 'checkAccessMethod',
editable: function(m) {
// Header cell then skip
@ -124,7 +124,7 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
}
},{
id: 'nulls', label:'{{ _('NULLs') }}',
cell: Backgrid.Extension.SwitchDepCell, type: 'switch',
cell: Backgrid.Extension.TableChildSwitchCell, type: 'switch',
disabled: 'checkAccessMethod',
editable: function(m) {
// Header cell then skip

View File

@ -456,9 +456,9 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
});
}
// Switch Cell with Deps
var SwitchDepCell =
Backgrid.Extension.SwitchDepCell = Backgrid.Extension.SwitchCell.extend({
// Switch Cell with Deps (specifically for table children)
var TableChildSwitchCell =
Backgrid.Extension.TableChildSwitchCell = Backgrid.Extension.SwitchCell.extend({
initialize: function() {
Backgrid.Extension.SwitchCell.prototype.initialize.apply(this, arguments);
Backgrid.Extension.DependentCell.prototype.initialize.apply(this, arguments);