'].join("\n"))
- }),
- transform: function(rows) {
- // This will only get called in case of NodeListByNameControl.
-
- var that = this,
+ } else {
+ Backform.NodeListByNameControl.prototype.remove.apply(this, arguments);
+ }
+ },
+ template: _.template([
+ '
',].join("\n")
-
- _.extend(data, {
- column_label: gettext('Local column'),
- references_label: gettext('References'),
- referenced_label: gettext('Referencing')
- });
-
- var self = this,
+ var self = this,
headerTmpl = _.template(header),
$header = $(headerTmpl(data)),
controls = this.controls;
- this.headerFields.each(function(field) {
- var control = new (field.get("control"))({
- field: field,
- model: self.headerData
- });
+ this.headerFields.each(function(field) {
+ var control = new (field.get('control'))({
+ field: field,
+ model: self.headerData,
+ });
- $header.find('div[header="' + field.get('name') + '"]').append(
- control.render().$el
- );
+ $header.find('div[header="' + field.get('name') + '"]').append(
+ control.render().$el
+ );
- controls.push(control);
- });
+ controls.push(control);
+ });
- // We should not show add but in properties mode
- if (data.mode == 'properties') {
- $header.html('');
- }
+ // We should not show add but in properties mode
+ if (data.mode == 'properties') {
+ $header.html('');
+ }
- self.$header = $header;
+ self.$header = $header;
- return $header;
- },
+ return $header;
+ },
- events: _.extend(
- {}, Backform.UniqueColCollectionControl.prototype.events,
- {'click button.add': 'addColumns'}
- ),
+ events: _.extend(
+ {}, Backform.UniqueColCollectionControl.prototype.events,
+ {'click button.add': 'addColumns'}
+ ),
- showGridControl: function(data) {
+ showGridControl: function(data) {
- var self = this,
+ var self = this,
titleTmpl = _.template([
- "
",
- "",
- "
"].join("\n")),
+ '
',
+ '',
+ '
'].join('\n')),
$gridBody =
- $("").append(
- // Append titleTmpl only if create/edit mode
- data.mode !== 'properties' ? titleTmpl({label: data.label}) : ''
- );
-
- // Clean up existing grid if any (in case of re-render)
- if (self.grid) {
- self.grid.remove();
- }
+ $('').append(
+ // Append titleTmpl only if create/edit mode
+ data.mode !== 'properties' ? titleTmpl({label: data.label}) : ''
+ );
- $gridBody.append(self.generateHeader(data));
+ // Clean up existing grid if any (in case of re-render)
+ if (self.grid) {
+ self.grid.remove();
+ }
- var gridSchema = _.clone(this.gridSchema);
+ $gridBody.append(self.generateHeader(data));
- // Insert Delete Cell into Grid
- if (data.disabled == false && data.canDelete) {
+ var gridSchema = _.clone(this.gridSchema);
+
+ // Insert Delete Cell into Grid
+ if (data.disabled == false && data.canDelete) {
gridSchema.columns.unshift({
- name: "pg-backform-delete", label: "",
+ name: 'pg-backform-delete', label: '',
cell: Backgrid.Extension.DeleteCell,
- editable: false, cell_priority: -1
+ editable: false, cell_priority: -1,
});
- }
+ }
+
+ // Initialize a new Grid instance
+ var grid = self.grid = new Backgrid.Grid({
+ columns: gridSchema.columns,
+ collection: self.collection,
+ className: 'backgrid table-bordered',
+ });
+ self.$grid = grid.render().$el;
+
+ $gridBody.append(self.$grid);
- // Initialize a new Grid instance
- var grid = self.grid = new Backgrid.Grid({
- columns: gridSchema.columns,
- collection: self.collection,
- className: "backgrid table-bordered"
- });
- self.$grid = grid.render().$el;
-
- $gridBody.append(self.$grid);
-
- setTimeout(function() {
- self.headerData.set({
- 'local_column':
- self.$header.find(
- 'div[header="local_column"] select option:first'
- ).val(),
+ setTimeout(function() {
+ self.headerData.set({
+ 'local_column':
+ self.$header.find(
+ 'div[header="local_column"] select option:first'
+ ).val(),
'referenced':
- self.$header.find(
- 'div[header="referenced"] select option:first'
- ).val(),
+ self.$header.find(
+ 'div[header="referenced"] select option:first'
+ ).val(),
'references':
- self.$header.find(
- 'div[header="references"] select option:first'
- ).val()
- }, {silent:true}
+ self.$header.find(
+ 'div[header="references"] select option:first'
+ ).val(),
+ }, {silent:true}
);
- }, 10);
+ }, 10);
- // Remove unwanted class from grid to display it properly
- if(data.mode === 'properties')
- $gridBody.find('.subnode-header-form').removeClass('subnode-header-form');
+ // Remove unwanted class from grid to display it properly
+ if(data.mode === 'properties')
+ $gridBody.find('.subnode-header-form').removeClass('subnode-header-form');
- // Render node grid
- return $gridBody;
- },
+ // Render node grid
+ return $gridBody;
+ },
- headerDataChanged: function() {
- var self = this, val,
+ headerDataChanged: function() {
+ var self = this, val,
data = this.headerData.toJSON(),
inSelected = false,
checkVars = ['local_column', 'referenced'];
- if (!self.$header) {
- return;
- }
+ if (!self.$header) {
+ return;
+ }
- if (self.control_data.canAdd) {
- self.collection.each(function(m) {
- if (!inSelected) {
- _.each(checkVars, function(v) {
- if (!inSelected) {
- val = m.get(v);
- inSelected = ((
- (_.isUndefined(val) || _.isNull(val)) &&
- (_.isUndefined(data[v]) || _.isNull(data[v]))
+ if (self.control_data.canAdd) {
+ self.collection.each(function(m) {
+ if (!inSelected) {
+ _.each(checkVars, function(v) {
+ if (!inSelected) {
+ val = m.get(v);
+ inSelected = ((
+ (_.isUndefined(val) || _.isNull(val)) &&
+ (_.isUndefined(data[v]) || _.isNull(data[v]))
) ||
- (val == data[v]));
- }
- });
- }
- });
- }
- else {
- inSelected = true;
- }
+ (val == data[v]));
+ }
+ });
+ }
+ });
+ }
+ else {
+ inSelected = true;
+ }
- self.$header.find('button.add').prop('disabled', inSelected);
- },
+ self.$header.find('button.add').prop('disabled', inSelected);
+ },
- addColumns: function(ev) {
- ev.preventDefault();
- var self = this,
+ addColumns: function(ev) {
+ ev.preventDefault();
+ var self = this,
local_column = self.headerData.get('local_column'),
referenced = self.headerData.get('referenced');
- if (!local_column || local_column == '' ||
+ if (!local_column || local_column == '' ||
!referenced || referenced =='') {
- return false;
- }
+ return false;
+ }
- var m = new (self.field.get('model'))(
- self.headerData.toJSON()),
+ var m = new (self.field.get('model'))(
+ self.headerData.toJSON()),
coll = self.model.get(self.field.get('name'));
- coll.add(m);
+ coll.add(m);
- var idx = coll.indexOf(m);
+ var idx = coll.indexOf(m);
- // idx may not be always > -1 because our UniqueColCollection may
- // remove 'm' if duplicate value found.
- if (idx > -1) {
- self.$grid.find('.new').removeClass('new');
+ // idx may not be always > -1 because our UniqueColCollection may
+ // remove 'm' if duplicate value found.
+ if (idx > -1) {
+ self.$grid.find('.new').removeClass('new');
- var newRow = self.grid.body.rows[idx].$el;
+ var newRow = self.grid.body.rows[idx].$el;
- newRow.addClass("new");
- $(newRow).pgMakeVisible('backform-tab');
- } else {
- //delete m;
- }
+ newRow.addClass('new');
+ $(newRow).pgMakeVisible('backform-tab');
+ } else {
+ //delete m;
+ }
- return false;
- },
+ return false;
+ },
- onAddorRemoveColumns: function() {
- var self = this;
+ onAddorRemoveColumns: function() {
+ var self = this;
- // Wait for collection to be updated before checking for the button to be
- // enabled, or not.
- setTimeout(function() {
- if (self.collection.length > 0) {
- self.$header.find(
- 'div[header="references"] select'
+ // Wait for collection to be updated before checking for the button to be
+ // enabled, or not.
+ setTimeout(function() {
+ if (self.collection.length > 0) {
+ self.$header.find(
+ 'div[header="references"] select'
).prop('disabled', true);
- } else {
- self.$header.find(
- 'div[header="references"] select'
+ } else {
+ self.$header.find(
+ 'div[header="references"] select'
).prop('disabled', false);
- }
+ }
- self.collection.trigger('pgadmin:columns:updated', self.collection);
+ self.collection.trigger('pgadmin:columns:updated', self.collection);
- self.headerDataChanged();
+ self.headerDataChanged();
- if ((!_.has(self.model, 'handler') || (_.has(self.model, 'handler') &&
- _.isUndefined(self.model.handler))) ||
- (_.has(self.model, 'handler') && !_.isUndefined(self.model.handler) &&
- !_.isUndefined(self.model.handler.get('oid')))) {
- self.getCoveringIndex();
- }
+ if ((!_.has(self.model, 'handler') || (_.has(self.model, 'handler') &&
+ _.isUndefined(self.model.handler))) ||
+ (_.has(self.model, 'handler') && !_.isUndefined(self.model.handler) &&
+ !_.isUndefined(self.model.handler.get('oid')))) {
+ self.getCoveringIndex();
+ }
- }, 10);
- },
+ }, 10);
+ },
- getCoveringIndex: function() {
+ getCoveringIndex: function() {
- var self = this,
+ var self = this,
url = 'get_coveringindex',
m = self.model,
cols = [],
coveringindex = null;
- self.collection.each(function(m){
- cols.push(m.get('local_column'));
- })
-
- if (cols.length > 0) {
- var node = this.field.get('schema_node'),
- node_info = this.field.get('node_info'),
- full_url = node.generate_url.apply(
- node, [
- null, url, this.field.get('node_data'),
- this.field.get('url_with_id') || false, node_info
- ]);
-
- if (this.field.get('version_compatible')) {
- m.trigger('pgadmin:view:fetching', m, self.field);
- $.ajax({
- async: false,
- data : {cols:JSON.stringify(cols)},
- url: full_url,
- success: function(res) {
- coveringindex = res.data;
- },
- error: function() {
- m.trigger('pgadmin:view:fetch:error', m, self.field);
- }
- });
- m.trigger('pgadmin:view:fetched', m, self.field);
- }
- }
+ self.collection.each(function(m){
+ cols.push(m.get('local_column'));
+ });
- if (coveringindex) {
- m.set('hasindex', true);
- m.set('autoindex', false);
- m.set('coveringindex', coveringindex);
- } else {
- m.set('coveringindex', null);
- m.set('autoindex', true);
- m.set('hasindex', false);
+ if (cols.length > 0) {
+ var node = this.field.get('schema_node'),
+ node_info = this.field.get('node_info'),
+ full_url = node.generate_url.apply(
+ node, [
+ null, url, this.field.get('node_data'),
+ this.field.get('url_with_id') || false, node_info,
+ ]);
+
+ if (this.field.get('version_compatible')) {
+ m.trigger('pgadmin:view:fetching', m, self.field);
+ $.ajax({
+ async: false,
+ data : {cols:JSON.stringify(cols)},
+ url: full_url,
+ success: function(res) {
+ coveringindex = res.data;
+ },
+ error: function() {
+ m.trigger('pgadmin:view:fetch:error', m, self.field);
+ },
+ });
+ m.trigger('pgadmin:view:fetched', m, self.field);
}
- },
+ }
- remove: function() {
- /*
- * Stop listening the events registered by this control.
- */
- this.stopListening(this.headerData, "change", this.headerDataChanged);
- this.listenTo(this.headerData, "select2", this.headerDataChanged);
- this.listenTo(this.collection, "remove", this.onRemoveVariable);
- // Remove header controls.
- _.each(this.controls, function(controls) {
- controls.remove();
- });
+ if (coveringindex) {
+ m.set('hasindex', true);
+ m.set('autoindex', false);
+ m.set('coveringindex', coveringindex);
+ } else {
+ m.set('coveringindex', null);
+ m.set('autoindex', true);
+ m.set('hasindex', false);
+ }
+ },
- ForeignKeyColumnControl.__super__.remove.apply(this, arguments);
+ remove: function() {
+ /*
+ * Stop listening the events registered by this control.
+ */
+ this.stopListening(this.headerData, 'change', this.headerDataChanged);
+ this.listenTo(this.headerData, 'select2', this.headerDataChanged);
+ this.listenTo(this.collection, 'remove', this.onRemoveVariable);
+ // Remove header controls.
+ _.each(this.controls, function(controls) {
+ controls.remove();
+ });
- // Remove the header model
- delete (this.headerData);
+ ForeignKeyColumnControl.__super__.remove.apply(this, arguments);
- }
- });
+ // Remove the header model
+ delete (this.headerData);
+
+ },
+ });
// Extend the browser's node class for foreign key node
if (!pgBrowser.Nodes['foreign_key']) {
@@ -615,7 +618,7 @@ define('pgadmin.node.foreign_key', [
Init: function() {
/* Avoid multiple registration of menus */
if (this.initialized)
- return;
+ return;
this.initialized = true;
@@ -624,13 +627,13 @@ define('pgadmin.node.foreign_key', [
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Foreign key...'),
icon: 'wcTabIcon icon-foreign_key', data: {action: 'create', check: true},
- enable: 'canCreate'
+ enable: 'canCreate',
},{
name: 'validate_foreign_key', node: 'foreign_key', module: this,
applies: ['object', 'context'], callback: 'validate_foreign_key',
category: 'validate', priority: 4, label: gettext('Validate foreign key'),
- icon: 'fa fa-link', enable : 'is_not_valid'
- }
+ icon: 'fa fa-link', enable : 'is_not_valid',
+ },
]);
},
is_not_valid: function(node) {
@@ -639,10 +642,10 @@ define('pgadmin.node.foreign_key', [
callbacks: {
validate_foreign_key: function(args) {
var input = args || {},
- obj = this,
- t = pgBrowser.tree,
- i = input.item || t.selected(),
- d = i && i.length == 1 ? t.itemData(i) : undefined;
+ obj = this,
+ t = pgBrowser.tree,
+ i = input.item || t.selected(),
+ d = i && i.length == 1 ? t.itemData(i) : undefined;
if (!d) {
return false;
@@ -653,7 +656,7 @@ define('pgadmin.node.foreign_key', [
type:'GET',
success: function(res) {
if (res.success == 1) {
- alertify.success(res.info);
+ Alertify.success(res.info);
t.removeIcon(i);
data.valid = true;
data.icon = 'icon-foreign_key';
@@ -662,19 +665,21 @@ define('pgadmin.node.foreign_key', [
setTimeout(function() {t.select(i);}, 100);
}
},
- error: function(xhr, status, error) {
+ error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
if (err.success == 0) {
- alertify.error(err.errormsg);
+ Alertify.error(err.errormsg);
}
- } catch (e) {}
+ } catch (e) {
+ console.warn(e.stack || e);
+ }
t.unload(i);
- }
- });
+ },
+ });
return false;
- }
+ },
},
// Define the model for foreign key node
model: pgAdmin.Browser.Node.Model.extend({
@@ -689,11 +694,11 @@ define('pgadmin.node.foreign_key', [
confmatchtype: undefined,
convalidated: undefined,
columns: undefined,
- confupdtype: "a",
- confdeltype: "a",
+ confupdtype: 'a',
+ confdeltype: 'a',
autoindex: true,
coveringindex: undefined,
- hasindex:undefined
+ hasindex:undefined,
},
toJSON: function () {
var d = pgAdmin.Browser.Node.Model.prototype.toJSON.apply(this, arguments);
@@ -704,10 +709,10 @@ define('pgadmin.node.foreign_key', [
schema: [{
id: 'name', label: gettext('Name'), type: 'text',
mode: ['properties', 'create', 'edit'], editable:true,
- headerCell: Backgrid.Extension.CustomHeaderCell, cellHeaderClasses: 'width_percent_50'
+ headerCell: Backgrid.Extension.CustomHeaderCell, cellHeaderClasses: 'width_percent_50',
},{
id: 'oid', label: gettext('OID'), cell: 'string',
- type: 'text' , mode: ['properties']
+ type: 'text' , mode: ['properties'],
},{
id: 'comment', label: gettext('Comment'), cell: 'string',
type: 'multiline', mode: ['properties', 'create', 'edit'],
@@ -715,27 +720,27 @@ define('pgadmin.node.foreign_key', [
var name = m.get('name');
if (!(name && name != '')) {
setTimeout(function(){
- if(m.get('comment') && m.get('comment') !== '')
- m.set('comment', null);
+ if(m.get('comment') && m.get('comment') !== '')
+ m.set('comment', null);
},10);
return true;
} else {
return false;
}
- }
+ },
},{
id: 'condeferrable', label: gettext('Deferrable?'),
type: 'switch', group: gettext('Definition'),
disabled: function(m) {
// If we are in table edit mode then
if (_.has(m, 'handler') && !_.isUndefined(m.handler)) {
- // If OID is undefined then user is trying to add
- // new constraint which should allowed for Unique
- return !_.isUndefined(m.get('oid'));
+ // If OID is undefined then user is trying to add
+ // new constraint which should allowed for Unique
+ return !_.isUndefined(m.get('oid'));
}
// We can't update condeferrable of existing foreign key.
return !m.isNew();
- }
+ },
},{
id: 'condeferred', label: gettext('Deferred?'),
type: 'switch', group: gettext('Definition'),
@@ -743,9 +748,9 @@ define('pgadmin.node.foreign_key', [
disabled: function(m) {
// If we are in table edit mode then
if (_.has(m, 'handler') && !_.isUndefined(m.handler)) {
- // If OID is undefined then user is trying to add
- // new constraint which should allowed for Unique
- return !_.isUndefined(m.get('oid'));
+ // If OID is undefined then user is trying to add
+ // new constraint which should allowed for Unique
+ return !_.isUndefined(m.get('oid'));
} else if(!m.isNew()) {
return true;
}
@@ -759,7 +764,7 @@ define('pgadmin.node.foreign_key', [
},10);
return true;
}
- }
+ },
},{
id: 'confmatchtype', label: gettext('Match type'),
type: 'switch', group: gettext('Definition'),
@@ -769,77 +774,77 @@ define('pgadmin.node.foreign_key', [
},disabled: function(m) {
// If we are in table edit mode then
if (_.has(m, 'handler') && !_.isUndefined(m.handler)) {
- // If OID is undefined then user is trying to add
- // new constraint which should allowed for Unique
- return !_.isUndefined(m.get('oid'));
+ // If OID is undefined then user is trying to add
+ // new constraint which should allowed for Unique
+ return !_.isUndefined(m.get('oid'));
}
// We can't update condeferred of existing foreign key.
return !m.isNew();
- }
+ },
},{
- id: 'convalidated', label: gettext("Validated?"),
+ id: 'convalidated', label: gettext('Validated?'),
type: 'switch', group: gettext('Definition'),
options: {
onText: gettext('Yes'),
- offText: gettext('No')
+ offText: gettext('No'),
},disabled: function(m) {
// If we are in table edit mode then
if (_.has(m, 'handler') && !_.isUndefined(m.handler)) {
- // If OID is undefined then user is trying to add
- // new constraint which should allowed
- return !(_.isUndefined(m.get('oid')) || m.get("convalidated"));
+ // If OID is undefined then user is trying to add
+ // new constraint which should allowed
+ return !(_.isUndefined(m.get('oid')) || m.get('convalidated'));
}
// We can't update condeferred of existing foreign key.
- return !(m.isNew() || m.get("convalidated"));
- }
+ return !(m.isNew() || m.get('convalidated'));
+ },
},{
id: 'autoindex', label: gettext('Auto FK index?'),
type: 'switch', group: gettext('Definition'),
deps: ['name', 'hasindex'],
options: {
onText: gettext('Yes'),
- offText: gettext('No')
+ offText: gettext('No'),
},disabled: function(m) {
var index = m.get('coveringindex'),
- autoindex = m.get('autoindex'),
- setIndexName = function() {
- var name = m.get('name'),
+ autoindex = m.get('autoindex'),
+ setIndexName = function() {
+ var name = m.get('name'),
oldindex = 'fki_'+m.previous ('name');
- if (m.get('hasindex')) {
- return true;
- } else if (m.get('autoindex') && !_.isUndefined(name) && !_.isNull(name) &&
- name != '' && (_.isUndefined(index) || _.isNull(index) ||
- index == '' || index == oldindex)) {
- var newIndex = 'fki_' + name;
- m.set('coveringindex', newIndex);
- return false;
- } else {
- return false;
- }
- };
- // If we are in table edit mode then
- if (_.has(m, 'handler') && !_.isUndefined(m.handler)) {
- // If OID is undefined then user is trying to add
- // new constraint which should allowed for Unique
- if(_.isUndefined(m.get('oid')) && _.isUndefined(m.handler.get('oid'))) {
- setTimeout(function () {
- if(m.get('autoindex'))
- m.set('autoindex', false);
- }, 10);
+ if (m.get('hasindex')) {
return true;
+ } else if (m.get('autoindex') && !_.isUndefined(name) && !_.isNull(name) &&
+ name != '' && (_.isUndefined(index) || _.isNull(index) ||
+ index == '' || index == oldindex)) {
+ var newIndex = 'fki_' + name;
+ m.set('coveringindex', newIndex);
+ return false;
} else {
- return setIndexName();
+ return false;
}
+ };
+ // If we are in table edit mode then
+ if (_.has(m, 'handler') && !_.isUndefined(m.handler)) {
+ // If OID is undefined then user is trying to add
+ // new constraint which should allowed for Unique
+ if(_.isUndefined(m.get('oid')) && _.isUndefined(m.handler.get('oid'))) {
+ setTimeout(function () {
+ if(m.get('autoindex'))
+ m.set('autoindex', false);
+ }, 10);
+ return true;
+ } else {
+ return setIndexName();
+ }
} else {
if(!m.isNew() && autoindex && !_.isUndefined(index) &&
- !_.isNull(index) && index != '' && m.get('hasindex')) {
+ !_.isNull(index) && index != '' && m.get('hasindex')) {
return true;
} else {
return setIndexName();
}
}
- }
+ },
},{
id: 'coveringindex', label: gettext('Covering index'), type: 'text',
mode: ['properties', 'create', 'edit'], group: gettext('Definition'),
@@ -859,10 +864,10 @@ define('pgadmin.node.foreign_key', [
var name = m.get('name'),
newIndex = 'fki_' + name;
- if (m.get('autoindex') && !_.isUndefined(name) && !_.isNull(name) &&
- name != '') {
- m.set('coveringindex', newIndex);
- }
+ if (m.get('autoindex') && !_.isUndefined(name) && !_.isNull(name) &&
+ name != '') {
+ m.set('coveringindex', newIndex);
+ }
});
return false;
@@ -871,24 +876,24 @@ define('pgadmin.node.foreign_key', [
// If we are in table edit mode then
if (_.has(m, 'handler') && !_.isUndefined(m.handler)) {
- // If OID is undefined then user is trying to add
- // new constraint which should allowed for Unique
- if (_.isUndefined(m.get('oid')) && _.isUndefined(m.handler.get('oid'))) {
- return true;
- } else {
- return setIndexName();
- }
+ // If OID is undefined then user is trying to add
+ // new constraint which should allowed for Unique
+ if (_.isUndefined(m.get('oid')) && _.isUndefined(m.handler.get('oid'))) {
+ return true;
+ } else {
+ return setIndexName();
+ }
} else if (!m.isNew() && m.get('autoindex') && !_.isUndefined(index)
- && _.isNull(index) && index == '') {
+ && _.isNull(index) && index == '') {
return true;
}
return setIndexName();
- }
+ },
},{
id: 'columns', label: gettext('Columns'),
- type: 'collection', group: gettext('Columns'), disabled: false,
+ type: 'collection', group: gettext('Columns'),
node: 'foreign_key', editable: false, headerCell: Backgrid.Extension.CustomHeaderCell,
cellHeaderClasses: 'width_percent_50',
cell: Backgrid.StringCell.extend({
@@ -906,14 +911,14 @@ define('pgadmin.node.foreign_key', [
self.model.get('columns').on('pgadmin:columns:updated', function() {
self.render.apply(self);
});
- self.listenTo(collection, "add", self.render);
- self.listenTo(collection, "remove", self.render);
+ self.listenTo(collection, 'add', self.render);
+ self.listenTo(collection, 'remove', self.render);
},
removeColumn: function(m){
var self = this,
- removedCols = self.model.get('columns').where(
- {local_column: m.get('name')}
- );
+ removedCols = self.model.get('columns').where(
+ {local_column: m.get('name')}
+ );
self.model.get('columns').remove(removedCols);
setTimeout(function () {
@@ -921,50 +926,46 @@ define('pgadmin.node.foreign_key', [
}, 10);
setTimeout(function () {
- var constraints = self.model.top.get("foreign_key");
+ var constraints = self.model.top.get('foreign_key');
var removed = [];
constraints.each(function(constraint) {
- if (constraint.get("columns").length == 0) {
- removed.push(constraint);
+ if (constraint.get('columns').length == 0) {
+ removed.push(constraint);
}
});
constraints.remove(removed);
},100);
},
resetColOptions : function(m) {
- var self = this,
- updatedCols = self.model.get('columns').where(
- {"local_column": m.previous('name')}
- );
- if (updatedCols.length > 0) {
- /*
- * Table column name has changed so update
- * column name in foreign key as well.
- */
- updatedCols[0].set(
- {"local_column": m.get('name')});
- }
+ var self = this,
+ updatedCols = self.model.get('columns').where(
+ {'local_column': m.previous('name')}
+ );
+ if (updatedCols.length > 0) {
+ /*
+ * Table column name has changed so update
+ * column name in foreign key as well.
+ */
+ updatedCols[0].set(
+ {'local_column': m.get('name')});
+ }
- setTimeout(function () {
- self.render();
- }, 10);
+ setTimeout(function () { self.render(); }, 10);
},
formatter: {
- fromRaw: function (rawValue, model) {
+ fromRaw: function (rawValue) {
var cols = [],
- remote_cols = [];
+ remote_cols = [];
if (rawValue.length > 0) {
rawValue.each(function(col){
cols.push(col.get('local_column'));
- remote_cols.push(col.get('referenced'))
+ remote_cols.push(col.get('referenced'));
});
return '('+cols.join(', ')+') -> ('+ remote_cols.join(', ')+')';
}
- return "";
+ return '';
},
- toRaw: function (val, model) {
- return val;
- }
+ toRaw: function (val) { return val; },
},
render: function() {
return Backgrid.StringCell.prototype.render.apply(this, arguments);
@@ -976,121 +977,123 @@ define('pgadmin.node.foreign_key', [
this.stopListening(tableCols, 'change:name' , self.resetColOptions);
Backgrid.StringCell.prototype.remove.apply(this, arguments);
- }
+ },
}),
canAdd: function(m) {
- // We can't update columns of existing foreign key.
+ // We can't update columns of existing foreign key.
return m.isNew();
}, canDelete: true,
control: ForeignKeyColumnControl,
model: ForeignKeyColumnModel,
disabled: function(m) {
- // If we are in table edit mode then
+ // If we are in table edit mode then
if (_.has(m, 'handler') && !_.isUndefined(m.handler)) {
// If OID is undefined then user is trying to add
// new constraint which should allowed for Unique
- return !_.isUndefined(m.get('oid'));
+ return !_.isUndefined(m.get('oid'));
}
- // We can't update columns of existing foreign key.
+ // We can't update columns of existing foreign key.
return !m.isNew();
- }
+ },
},{
id: 'confupdtype', label: gettext('On update'),
- type:"select2", group: gettext('Action'), mode: ['edit','create'],
- select2:{width:"50%", allowClear: false},
+ type:'select2', group: gettext('Action'), mode: ['edit','create'],
+ select2:{width:'50%', allowClear: false},
options: [
- {label: "NO ACTION", value: "a"},
- {label: "RESTRICT", value: "r"},
- {label: "CASCADE", value: "c"},
- {label: "SET NULL", value: "n"},
- {label: "SET DEFAULT", value: "d"}
+ {label: 'NO ACTION', value: 'a'},
+ {label: 'RESTRICT', value: 'r'},
+ {label: 'CASCADE', value: 'c'},
+ {label: 'SET NULL', value: 'n'},
+ {label: 'SET DEFAULT', value: 'd'},
],disabled: function(m) {
- // If we are in table edit mode then
+ // If we are in table edit mode then
if (_.has(m, 'handler') && !_.isUndefined(m.handler)) {
// If OID is undefined then user is trying to add
// new constraint which should allowed for Unique
- return !_.isUndefined(m.get('oid'));
+ return !_.isUndefined(m.get('oid'));
}
- // We can't update confupdtype of existing foreign key.
+ // We can't update confupdtype of existing foreign key.
return !m.isNew();
- }
+ },
},{
id: 'confdeltype', label: gettext('On delete'),
- type:"select2", group: gettext('Action'), mode: ['edit','create'],
- select2:{width:"50%", allowClear: false},
+ type:'select2', group: gettext('Action'), mode: ['edit','create'],
+ select2:{width:'50%', allowClear: false},
options: [
- {label: "NO ACTION", value: "a"},
- {label: "RESTRICT", value: "r"},
- {label: "CASCADE", value: "c"},
- {label: "SET NULL", value: "n"},
- {label: "SET DEFAULT", value: "d"}
+ {label: 'NO ACTION', value: 'a'},
+ {label: 'RESTRICT', value: 'r'},
+ {label: 'CASCADE', value: 'c'},
+ {label: 'SET NULL', value: 'n'},
+ {label: 'SET DEFAULT', value: 'd'},
],disabled: function(m) {
- // If we are in table edit mode then
+ // If we are in table edit mode then
if (_.has(m, 'handler') && !_.isUndefined(m.handler)) {
// If OID is undefined then user is trying to add
// new constraint which should allowed for Unique
- return !_.isUndefined(m.get('oid'));
+ return !_.isUndefined(m.get('oid'));
}
- // We can't update confdeltype of existing foreign key.
+ // We can't update confdeltype of existing foreign key.
return !m.isNew();
- }
- }
+ },
+ },
],
validate: function() {
+ var columns = this.get('columns'),
+ msg;
+
this.errorModel.clear();
- var columns = this.get('columns');
if ((_.isUndefined(columns) || _.isNull(columns) || columns.length < 1)) {
- var msg = gettext('Please specify columns for Foreign key.');
+ msg = gettext('Please specify columns for Foreign key.');
this.errorModel.set('columns', msg);
return msg;
}
var coveringindex = this.get('coveringindex'),
- autoindex = this.get('autoindex');
+ autoindex = this.get('autoindex');
if (autoindex && (_.isUndefined(coveringindex) || _.isNull(coveringindex) ||
- String(coveringindex).replace(/^\s+|\s+$/g, '') == '')) {
- var msg = gettext('Please specify covering index name.');
+ String(coveringindex).replace(/^\s+|\s+$/g, '') == '')) {
+ msg = gettext('Please specify covering index name.');
this.errorModel.set('coveringindex', msg);
return msg;
}
return null;
- }
+ },
}),
canCreate: function(itemData, item, data) {
// If check is false then , we will allow create menu
- if (data && data.check == false)
- return true;
+ if (data && data.check == false)
+ return true;
- var t = pgBrowser.tree, i = item, d = itemData, parents = [],
- immediate_parent_table_found = false,
- is_immediate_parent_table_partitioned = false;
+ var t = pgBrowser.tree, i = item, d = itemData, parents = [],
+ immediate_parent_table_found = false,
+ is_immediate_parent_table_partitioned = false;
// To iterate over tree to check parent node
- while (i) {
+ while (i) {
// If table is partitioned table then return false
- if (!immediate_parent_table_found && (d._type == 'table' || d._type == 'partition')) {
- immediate_parent_table_found = true;
- if ('is_partitioned' in d && d.is_partitioned) {
- is_immediate_parent_table_partitioned = true;
- }
+ if (!immediate_parent_table_found && (d._type == 'table' || d._type == 'partition')) {
+ immediate_parent_table_found = true;
+ if ('is_partitioned' in d && d.is_partitioned) {
+ is_immediate_parent_table_partitioned = true;
}
+ }
// If it is schema then allow user to c reate table
- if (_.indexOf(['schema'], d._type) > -1)
- return !is_immediate_parent_table_partitioned;
- parents.push(d._type);
- i = t.hasParent(i) ? t.parent(i) : null;
- d = i ? t.itemData(i) : null;
- }
- // If node is under catalog then do not allow 'create' menu
- if (_.indexOf(parents, 'catalog') > -1) {
- return false;
- } else {
+ if (_.indexOf(['schema'], d._type) > -1)
return !is_immediate_parent_table_partitioned;
- }
- }
+ parents.push(d._type);
+ i = t.hasParent(i) ? t.parent(i) : null;
+ d = i ? t.itemData(i) : null;
+ }
+ // If node is under catalog then do not allow 'create' menu
+ if (_.indexOf(parents, 'catalog') > -1) {
+ return false;
+ } else {
+ return !is_immediate_parent_table_partitioned;
+ }
+ },
});
}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js
index a212d8ec..d3a6cff4 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js
@@ -1,8 +1,8 @@
define('pgadmin.node.primary_key', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
- 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'alertify',
- 'pgadmin.browser.collection'
-], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
+ 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.backgrid',
+ 'pgadmin.browser.collection',
+], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, Backgrid) {
// Extend the browser's node class for index constraint node
if (!pgBrowser.Nodes['primary_key']) {
@@ -24,7 +24,7 @@ define('pgadmin.node.primary_key', [
Init: function() {
/* Avoid multiple registration of menus */
if (this.initialized)
- return;
+ return;
this.initialized = true;
@@ -33,9 +33,9 @@ define('pgadmin.node.primary_key', [
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Primary key'),
icon: 'wcTabIcon icon-primary_key', data: {action: 'create', check: true},
- enable: 'canCreate'
+ enable: 'canCreate',
- }
+ },
]);
},
canCreate: function(itemData, item, data) {
@@ -44,8 +44,8 @@ define('pgadmin.node.primary_key', [
return true;
var t = pgBrowser.tree, i = item, d = itemData, parents = [],
- immediate_parent_table_found = false,
- is_immediate_parent_table_partitioned = false;
+ immediate_parent_table_found = false,
+ is_immediate_parent_table_partitioned = false;
// To iterate over tree to check parent node
while (i) {
@@ -69,7 +69,7 @@ define('pgadmin.node.primary_key', [
_.each(children, function(child){
data = pgBrowser.tree.itemData($(child));
- if (!primary_key_found && data._type == "primary_key") {
+ if (!primary_key_found && data._type == 'primary_key') {
primary_key_found = true;
}
});
@@ -100,7 +100,7 @@ define('pgadmin.node.primary_key', [
fillfactor: undefined,
condeferrable: undefined,
condeferred: undefined,
- columns: []
+ columns: [],
},
// Define the schema for the index constraint node
@@ -119,15 +119,15 @@ define('pgadmin.node.primary_key', [
var name = m.get('name');
if (!(name && name != '')) {
setTimeout(function(){
- if(m.get('comment') && m.get('comment') !== '') {
- m.set('comment', null);
- }
+ if(m.get('comment') && m.get('comment') !== '') {
+ m.set('comment', null);
+ }
},10);
return true;
} else {
return false;
}
- }
+ },
},{
id: 'columns', label: gettext('Columns'),
type: 'collection', group: gettext('Definition'),
@@ -139,37 +139,37 @@ define('pgadmin.node.primary_key', [
var self = this,
collection = this.model.get('columns');
- // Do not listen for any event(s) for existing constraint.
+ // Do not listen for any event(s) for existing constraint.
if (_.isUndefined(self.model.get('oid'))) {
var tableCols = self.model.top.get('columns');
- self.listenTo(tableCols, 'remove' , self.removeColumn);
- self.listenTo(tableCols, 'change:name', self.resetColOptions);
+ self.listenTo(tableCols, 'remove' , self.removeColumn);
+ self.listenTo(tableCols, 'change:name', self.resetColOptions);
}
collection.on('pgadmin:multicolumn:updated', function() {
self.render.apply(self);
});
- self.listenTo(collection, "add", self.render);
- self.listenTo(collection, "remove", self.render);
+ self.listenTo(collection, 'add', self.render);
+ self.listenTo(collection, 'remove', self.render);
},
removeColumn: function(m) {
var self = this,
- removedCols = self.model.get('columns').where(
- {column: m.get('name')}
- );
+ removedCols = self.model.get('columns').where(
+ {column: m.get('name')}
+ );
self.model.get('columns').remove(removedCols);
setTimeout(function () {
self.render();
}, 10);
- var key = 'primary_key'
+ var key = 'primary_key';
setTimeout(function () {
- constraints = self.model.top.get(key);
- var removed = [];
+ var constraints = self.model.top.get(key),
+ removed = [];
constraints.each(function(constraint) {
- if (constraint.get("columns").length == 0) {
- removed.push(constraint);
+ if (constraint.get('columns').length == 0) {
+ removed.push(constraint);
}
});
constraints.remove(removed);
@@ -179,7 +179,7 @@ define('pgadmin.node.primary_key', [
resetColOptions : function(m) {
var self = this,
updatedCols = self.model.get('columns').where(
- {column: m.previous('name')}
+ {column: m.previous('name')}
);
if (updatedCols.length > 0) {
/*
@@ -187,8 +187,8 @@ define('pgadmin.node.primary_key', [
* column name in primary key as well.
*/
updatedCols[0].set(
- {"column": m.get('name')},
- {silent: true});
+ {'column': m.get('name')},
+ {silent: true});
}
setTimeout(function () {
@@ -196,19 +196,17 @@ define('pgadmin.node.primary_key', [
}, 10);
},
formatter: {
- fromRaw: function (rawValue, model) {
- return rawValue.pluck("column").toString();
+ fromRaw: function (rawValue) {
+ return rawValue.pluck('column').toString();
},
- toRaw: function (val, model) {
- return val;
- }
+ toRaw: function (val) { return val; },
},
render: function() {
return Backgrid.StringCell.prototype.render.apply(this, arguments);
},
remove: function() {
var tableCols = this.model.top.get('columns'),
- primary_key_col = this.model.get('columns');
+ primary_key_col = this.model.get('columns');
if (primary_key_col) {
primary_key_col.off('pgadmin:multicolumn:updated');
@@ -218,7 +216,7 @@ define('pgadmin.node.primary_key', [
this.stopListening(tableCols, 'change:name' , self.resetColOptions);
Backgrid.StringCell.prototype.remove.apply(this, arguments);
- }
+ },
}),
canDelete: true, canAdd: true,
control: Backform.MultiSelectAjaxControl.extend({
@@ -231,13 +229,13 @@ define('pgadmin.node.primary_key', [
allowClear: true,
width: 'style',
placeholder: gettext('Select the column(s)'),
- }
+ },
}
),
keyPathAccessor: function(obj, path) {
var res = obj;
if(_.isArray(res)) {
- return _.map(res, function(o) { return o['column']
+ return _.map(res, function(o) { return o['column'];
});
}
path = path.split('.');
@@ -249,8 +247,8 @@ define('pgadmin.node.primary_key', [
return _.isObject(res) && !_.isArray(res) ? null : res;
},
initialize: function() {
- // Here we will decide if we need to call URL
- // Or fetch the data from parent columns collection
+ // Here we will decide if we need to call URL
+ // Or fetch the data from parent columns collection
var self = this;
if(this.model.handler) {
Backform.Select2Control.prototype.initialize.apply(this, arguments);
@@ -266,17 +264,16 @@ define('pgadmin.node.primary_key', [
Backform.MultiSelectAjaxControl.prototype.initialize.apply(this, arguments);
}
self.model.get('columns').on('pgadmin:multicolumn:updated', function() {
- self.render.apply(self);
- });
+ self.render.apply(self);
+ });
},
- resetColOptions: function(m) {
+ resetColOptions: function() {
var self = this;
setTimeout(function () {
self.custom_options();
self.render.apply(self);
}, 50);
-
},
custom_options: function() {
// We will add all the columns entered by user in table model
@@ -285,73 +282,71 @@ define('pgadmin.node.primary_key', [
if (columns.length > 0) {
_.each(columns.models, function(m) {
- var col = m.get('name');
- if(!_.isUndefined(col) && !_.isNull(col)) {
- added_columns_from_tables.push(
- {label: col, value: col, image:'icon-column'}
- );
- }
+ var col = m.get('name');
+ if(!_.isUndefined(col) && !_.isNull(col)) {
+ added_columns_from_tables.push(
+ {label: col, value: col, image:'icon-column'}
+ );
+ }
});
}
// Set the values in to options so that user can select
this.field.set('options', added_columns_from_tables);
},
- onChange: function(e) {
+ onChange: function() {
var self = this,
- model = this.model,
- $el = $(e.target),
- attrArr = this.field.get("name").split('.'),
- name = attrArr.shift(),
- path = attrArr.join('.'),
- vals = this.getValueFromDOM(),
- collection = model.get(name),
- removed = [];
+ model = this.model,
+ attrArr = this.field.get('name').split('.'),
+ name = attrArr.shift(),
+ vals = this.getValueFromDOM(),
+ collection = model.get(name),
+ removed = [];
- this.stopListening(this.model, "change:" + name, this.render);
+ this.stopListening(this.model, 'change:' + name, this.render);
- /*
- * Iterate through all the values, and find out how many are already
- * present in the collection.
- */
+ /*
+ * Iterate through all the values, and find out how many are already
+ * present in the collection.
+ */
collection.each(function(m) {
- var column = m.get('column'),
- idx = _.indexOf(vals, column);
+ var column = m.get('column'),
+ idx = _.indexOf(vals, column);
- if (idx > -1) {
- vals.splice(idx, 1);
- } else {
- removed.push(column);
- }
- });
+ if (idx > -1) {
+ vals.splice(idx, 1);
+ } else {
+ removed.push(column);
+ }
+ });
- /*
- * Adding new values
- */
+ /*
+ * Adding new values
+ */
_.each(vals, function(v) {
var m = new (self.field.get('model'))(
- {column: v}, { silent: true,
- top: self.model.top,
- collection: collection,
- handler: collection
- });
+ {column: v}, { silent: true,
+ top: self.model.top,
+ collection: collection,
+ handler: collection,
+ });
collection.add(m);
});
- /*
- * Removing unwanted!
- */
+ /*
+ * Removing unwanted!
+ */
_.each(removed, function(v) {
collection.remove(collection.where({column: v}));
});
- this.listenTo(this.model, "change:" + name, this.render);
+ this.listenTo(this.model, 'change:' + name, this.render);
},
remove: function() {
if(this.model.handler) {
var self = this,
- tableCols = self.model.top.get('columns');
+ tableCols = self.model.top.get('columns');
self.stopListening(tableCols, 'remove' , self.resetColOptions);
self.stopListening(tableCols, 'change:name' , self.resetColOptions);
self.model.get('columns').off('pgadmin:multicolumn:updated');
@@ -361,23 +356,23 @@ define('pgadmin.node.primary_key', [
} else {
Backform.MultiSelectAjaxControl.prototype.remove.apply(this, arguments);
}
- }
+ },
}),
deps: ['index'], node: 'column',
model: pgBrowser.Node.Model.extend({
defaults: {
- column: undefined
+ column: undefined,
},
validate: function() {
return null;
- }
+ },
}),
transform : function(data){
var res = [];
if (data && _.isArray(data)) {
_.each(data, function(d) {
res.push({label: d.label, value: d.label, image:'icon-column'});
- })
+ });
}
return res;
},
@@ -385,27 +380,27 @@ define('pgadmin.node.primary_key', [
disabled: function(m) {
// If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top)
- && !m.top.isNew()) {
+ && !m.top.isNew()) {
// If OID is undefined then user is trying to add
// new constraint which should be allowed for Unique
- return !_.isUndefined(m.get('oid'));
+ return !_.isUndefined(m.get('oid'));
}
// We can't update columns of existing index constraint.
if (!m.isNew()) {
- return true;
+ return true;
}
// Disable if index is selected.
var index = m.get('index');
- if(_.isUndefined(index) || index == '') {
- return false;
- } else {
- var col = m.get('columns');
- col.reset();
- return true;
- }
+ if(_.isUndefined(index) || index == '') {
+ return false;
+ } else {
+ var col = m.get('columns');
+ col.reset();
+ return true;
}
- },{
+ },
+ },{
id: 'spcname', label: gettext('Tablespace'),
type: 'text', group: gettext('Definition'),
control: 'node-list-by-name', node: 'tablespace',
@@ -413,40 +408,40 @@ define('pgadmin.node.primary_key', [
select2:{allowClear:false},
filter: function(m) {
// Don't show pg_global tablespace in selection.
- if (m.label == "pg_global") return false;
+ if (m.label == 'pg_global') return false;
else return true;
},
disabled: function(m) {
// Disable if index is selected.
m = m.top || m;
var index = m.get('index');
- if(_.isUndefined(index) || index == '') {
- return false;
- } else {
- setTimeout(function(){
- m.set('spcname', '');
- },10);
- return true;
- }
- }
+ if(_.isUndefined(index) || index == '') {
+ return false;
+ } else {
+ setTimeout(function(){
+ m.set('spcname', '');
+ },10);
+ return true;
+ }
+ },
},{
id: 'index', label: gettext('Index'),
type: 'text', group: gettext('Definition'),
control: Backform.NodeListByNameControl.extend({
- initialize:function() {
- if (_.isUndefined(this.model.top)) {
- Backform.NodeListByNameControl.prototype.initialize.apply(this,arguments);
- } else {
- Backform.Control.prototype.initialize.apply(this,arguments);
- }
- }
+ initialize:function() {
+ if (_.isUndefined(this.model.top)) {
+ Backform.NodeListByNameControl.prototype.initialize.apply(this,arguments);
+ } else {
+ Backform.Control.prototype.initialize.apply(this,arguments);
+ }
+ },
}),
select2:{allowClear:true}, node: 'index',
disabled: function(m) {
// If we are in table edit mode then disable it
if (_.has(m, 'top') && !_.isUndefined(m.top)
- && !m.top.isNew()) {
- return true;
+ && !m.top.isNew()) {
+ return true;
}
// We can't update index of existing index constraint.
@@ -455,37 +450,37 @@ define('pgadmin.node.primary_key', [
// We will not show this field in Create Table mode
visible: function(m) {
return !_.isUndefined(m.top.node_info['table']);
- }
+ },
},{
id: 'fillfactor', label: gettext('Fill factor'), deps: ['index'],
type: 'int', group: gettext('Definition'), allowNull: true,
disabled: function(m) {
// Disable if index is selected.
var index = m.get('index');
- if(_.isUndefined(index) || index == '') {
- return false;
- } else {
- setTimeout(function(){
- m.set('fillfactor', null);
- },10);
- return true;
- }
+ if(_.isUndefined(index) || index == '') {
+ return false;
+ } else {
+ setTimeout(function(){
+ m.set('fillfactor', null);
+ },10);
+ return true;
}
+ },
},{
id: 'condeferrable', label: gettext('Deferrable?'),
type: 'switch', group: gettext('Definition'), deps: ['index'],
disabled: function(m) {
// If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top)
- && !m.top.isNew()) {
+ && !m.top.isNew()) {
// If OID is undefined then user is trying to add
// new constraint which should allowed for Unique
- return !_.isUndefined(m.get('oid'));
+ return !_.isUndefined(m.get('oid'));
}
// We can't update condeferrable of existing index constraint.
if (!m.isNew()) {
- return true;
+ return true;
}
// Disable if index is selected.
var index = m.get('index');
@@ -498,7 +493,7 @@ define('pgadmin.node.primary_key', [
},10);
return true;
}
- }
+ },
},{
id: 'condeferred', label: gettext('Deferred?'),
type: 'switch', group: gettext('Definition'),
@@ -506,10 +501,10 @@ define('pgadmin.node.primary_key', [
disabled: function(m) {
// If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top)
- && !m.top.isNew()) {
+ && !m.top.isNew()) {
// If OID is undefined then user is trying to add
// new constraint which should allowed for Unique
- return !_.isUndefined(m.get('oid'));
+ return !_.isUndefined(m.get('oid'));
}
// We can't update condeferred of existing index constraint.
@@ -521,13 +516,13 @@ define('pgadmin.node.primary_key', [
return false;
} else {
setTimeout(function(){
- if(m.get('condeferred'))
+ if(m.get('condeferred'))
m.set('condeferred', false);
},10);
return true;
}
- }
- }
+ },
+ },
],
validate: function() {
this.errorModel.clear();
@@ -539,17 +534,17 @@ define('pgadmin.node.primary_key', [
var columns = this.get('columns'),
index = this.get('index');
- if ((_.isUndefined(index) || String(index).replace(/^\s+|\s+$/g, '') == '') &&
- (_.isUndefined(columns) || _.isNull(columns) || columns.length < 1)) {
- var msg = gettext('Please specify columns for %(node)s', {node: gettext('Primary key')});
- this.errorModel.set('columns', msg);
- return msg;
- }
+ if ((_.isUndefined(index) || String(index).replace(/^\s+|\s+$/g, '') == '') &&
+ (_.isUndefined(columns) || _.isNull(columns) || columns.length < 1)) {
+ var msg = gettext('Please specify columns for %(node)s', {node: gettext('Primary key')});
+ this.errorModel.set('columns', msg);
+ return msg;
+ }
return null;
- }
- })
- });
+ },
+ }),
+ });
}
return pgBrowser.Nodes['primary_key'];
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.js
index 0413f2df..769185d6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.js
@@ -1,8 +1,8 @@
define('pgadmin.node.unique_constraint', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
- 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'alertify',
- 'pgadmin.browser.collection'
-], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
+ 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.backgrid',
+ 'pgadmin.browser.collection',
+], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, Backgrid) {
// Extend the browser's node class for index constraint node
if (!pgBrowser.Nodes['unique_constraint']) {
@@ -24,7 +24,7 @@ define('pgadmin.node.unique_constraint', [
Init: function() {
/* Avoid multiple registration of menus */
if (this.initialized)
- return;
+ return;
this.initialized = true;
@@ -33,9 +33,9 @@ define('pgadmin.node.unique_constraint', [
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Unique constraint'),
icon: 'wcTabIcon icon-unique_constraint', data: {action: 'create', check: true},
- enable: 'canCreate'
+ enable: 'canCreate',
- }
+ },
]);
},
canCreate: function(itemData, item, data) {
@@ -44,8 +44,8 @@ define('pgadmin.node.unique_constraint', [
return true;
var t = pgBrowser.tree, i = item, d = itemData, parents = [],
- immediate_parent_table_found = false,
- is_immediate_parent_table_partitioned = false;
+ immediate_parent_table_found = false,
+ is_immediate_parent_table_partitioned = false;
// To iterate over tree to check parent node
while (i) {
@@ -86,7 +86,7 @@ define('pgadmin.node.unique_constraint', [
fillfactor: undefined,
condeferrable: undefined,
condeferred: undefined,
- columns: []
+ columns: [],
},
// Define the schema for the index constraint node
@@ -105,15 +105,15 @@ define('pgadmin.node.unique_constraint', [
var name = m.get('name');
if (!(name && name != '')) {
setTimeout(function(){
- if(m.get('comment') && m.get('comment') !== '') {
- m.set('comment', null);
- }
+ if(m.get('comment') && m.get('comment') !== '') {
+ m.set('comment', null);
+ }
},10);
return true;
} else {
return false;
}
- }
+ },
},{
id: 'columns', label: gettext('Columns'),
type: 'collection', group: gettext('Definition'),
@@ -125,47 +125,47 @@ define('pgadmin.node.unique_constraint', [
var self = this,
collection = this.model.get('columns');
- // Do not listen for any event(s) for existing constraint.
+ // Do not listen for any event(s) for existing constraint.
if (_.isUndefined(self.model.get('oid'))) {
var tableCols = self.model.top.get('columns');
- self.listenTo(tableCols, 'remove' , self.removeColumn);
- self.listenTo(tableCols, 'change:name', self.resetColOptions);
+ self.listenTo(tableCols, 'remove' , self.removeColumn);
+ self.listenTo(tableCols, 'change:name', self.resetColOptions);
}
collection.on('pgadmin:multicolumn:updated', function() {
self.render.apply(self);
});
- self.listenTo(collection, "add", self.render);
- self.listenTo(collection, "remove", self.render);
+ self.listenTo(collection, 'add', self.render);
+ self.listenTo(collection, 'remove', self.render);
},
removeColumn: function(m) {
var self = this,
- removedCols = self.model.get('columns').where(
- {column: m.get('name')}
- );
+ removedCols = self.model.get('columns').where(
+ {column: m.get('name')}
+ );
self.model.get('columns').remove(removedCols);
setTimeout(function () {
self.render();
}, 10);
- var key = 'unique_constraint'
+ var key = 'unique_constraint';
setTimeout(function () {
- constraints = self.model.top.get(key);
- var removed = [];
+ var constraints = self.model.top.get(key),
+ removed = [];
+
constraints.each(function(constraint) {
- if (constraint.get("columns").length == 0) {
- removed.push(constraint);
+ if (constraint.get('columns').length == 0) {
+ removed.push(constraint);
}
});
constraints.remove(removed);
},100);
-
},
resetColOptions : function(m) {
var self = this,
updatedCols = self.model.get('columns').where(
- {column: m.previous('name')}
+ {column: m.previous('name')}
);
if (updatedCols.length > 0) {
/*
@@ -173,8 +173,8 @@ define('pgadmin.node.unique_constraint', [
* column name in primary key as well.
*/
updatedCols[0].set(
- {"column": m.get('name')},
- {silent: true});
+ {'column': m.get('name')},
+ {silent: true});
}
setTimeout(function () {
@@ -182,19 +182,17 @@ define('pgadmin.node.unique_constraint', [
}, 10);
},
formatter: {
- fromRaw: function (rawValue, model) {
- return rawValue.pluck("column").toString();
+ fromRaw: function (rawValue) {
+ return rawValue.pluck('column').toString();
},
- toRaw: function (val, model) {
- return val;
- }
+ toRaw: function (val) { return val; },
},
render: function() {
return Backgrid.StringCell.prototype.render.apply(this, arguments);
},
remove: function() {
var tableCols = this.model.top.get('columns'),
- primary_key_col = this.model.get('columns');
+ primary_key_col = this.model.get('columns');
if (primary_key_col) {
primary_key_col.off('pgadmin:multicolumn:updated');
@@ -204,7 +202,7 @@ define('pgadmin.node.unique_constraint', [
this.stopListening(tableCols, 'change:name' , self.resetColOptions);
Backgrid.StringCell.prototype.remove.apply(this, arguments);
- }
+ },
}),
canDelete: true, canAdd: true,
control: Backform.MultiSelectAjaxControl.extend({
@@ -217,13 +215,13 @@ define('pgadmin.node.unique_constraint', [
allowClear: true,
width: 'style',
placeholder: gettext('Select the column(s)'),
- }
+ },
}
),
keyPathAccessor: function(obj, path) {
var res = obj;
if(_.isArray(res)) {
- return _.map(res, function(o) { return o['column']
+ return _.map(res, function(o) { return o['column'];
});
}
path = path.split('.');
@@ -235,8 +233,8 @@ define('pgadmin.node.unique_constraint', [
return _.isObject(res) && !_.isArray(res) ? null : res;
},
initialize: function() {
- // Here we will decide if we need to call URL
- // Or fetch the data from parent columns collection
+ // Here we will decide if we need to call URL
+ // Or fetch the data from parent columns collection
var self = this;
if(this.model.handler) {
Backform.Select2Control.prototype.initialize.apply(this, arguments);
@@ -252,17 +250,16 @@ define('pgadmin.node.unique_constraint', [
Backform.MultiSelectAjaxControl.prototype.initialize.apply(this, arguments);
}
self.model.get('columns').on('pgadmin:multicolumn:updated', function() {
- self.render.apply(self);
- });
+ self.render.apply(self);
+ });
},
- resetColOptions: function(m) {
+ resetColOptions: function() {
var self = this;
setTimeout(function () {
self.custom_options();
self.render.apply(self);
}, 50);
-
},
custom_options: function() {
// We will add all the columns entered by user in table model
@@ -271,73 +268,71 @@ define('pgadmin.node.unique_constraint', [
if (columns.length > 0) {
_.each(columns.models, function(m) {
- var col = m.get('name');
- if(!_.isUndefined(col) && !_.isNull(col)) {
- added_columns_from_tables.push(
- {label: col, value: col, image:'icon-column'}
- );
- }
+ var col = m.get('name');
+ if(!_.isUndefined(col) && !_.isNull(col)) {
+ added_columns_from_tables.push(
+ {label: col, value: col, image:'icon-column'}
+ );
+ }
});
}
// Set the values in to options so that user can select
this.field.set('options', added_columns_from_tables);
},
- onChange: function(e) {
+ onChange: function() {
var self = this,
- model = this.model,
- $el = $(e.target),
- attrArr = this.field.get("name").split('.'),
- name = attrArr.shift(),
- path = attrArr.join('.'),
- vals = this.getValueFromDOM(),
- collection = model.get(name),
- removed = [];
+ model = this.model,
+ attrArr = this.field.get('name').split('.'),
+ name = attrArr.shift(),
+ vals = this.getValueFromDOM(),
+ collection = model.get(name),
+ removed = [];
- this.stopListening(this.model, "change:" + name, this.render);
+ this.stopListening(this.model, 'change:' + name, this.render);
- /*
- * Iterate through all the values, and find out how many are already
- * present in the collection.
- */
+ /*
+ * Iterate through all the values, and find out how many are already
+ * present in the collection.
+ */
collection.each(function(m) {
- var column = m.get('column'),
- idx = _.indexOf(vals, column);
+ var column = m.get('column'),
+ idx = _.indexOf(vals, column);
- if (idx > -1) {
- vals.splice(idx, 1);
- } else {
- removed.push(column);
- }
- });
+ if (idx > -1) {
+ vals.splice(idx, 1);
+ } else {
+ removed.push(column);
+ }
+ });
- /*
- * Adding new values
- */
+ /*
+ * Adding new values
+ */
_.each(vals, function(v) {
var m = new (self.field.get('model'))(
- {column: v}, { silent: true,
- top: self.model.top,
- collection: collection,
- handler: collection
- });
+ {column: v}, { silent: true,
+ top: self.model.top,
+ collection: collection,
+ handler: collection,
+ });
collection.add(m);
});
- /*
- * Removing unwanted!
- */
+ /*
+ * Removing unwanted!
+ */
_.each(removed, function(v) {
collection.remove(collection.where({column: v}));
});
- this.listenTo(this.model, "change:" + name, this.render);
+ this.listenTo(this.model, 'change:' + name, this.render);
},
remove: function() {
if(this.model.handler) {
var self = this,
- tableCols = self.model.top.get('columns');
+ tableCols = self.model.top.get('columns');
self.stopListening(tableCols, 'remove' , self.resetColOptions);
self.stopListening(tableCols, 'change:name' , self.resetColOptions);
self.model.get('columns').off('pgadmin:multicolumn:updated');
@@ -347,23 +342,23 @@ define('pgadmin.node.unique_constraint', [
} else {
Backform.MultiSelectAjaxControl.prototype.remove.apply(this, arguments);
}
- }
+ },
}),
deps: ['index'], node: 'column',
model: pgBrowser.Node.Model.extend({
defaults: {
- column: undefined
+ column: undefined,
},
validate: function() {
return null;
- }
+ },
}),
transform : function(data){
var res = [];
if (data && _.isArray(data)) {
_.each(data, function(d) {
res.push({label: d.label, value: d.label, image:'icon-column'});
- })
+ });
}
return res;
},
@@ -371,27 +366,27 @@ define('pgadmin.node.unique_constraint', [
disabled: function(m) {
// If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top)
- && !m.top.isNew()) {
+ && !m.top.isNew()) {
// If OID is undefined then user is trying to add
// new constraint which should be allowed for Unique
- return !_.isUndefined(m.get('oid'));
+ return !_.isUndefined(m.get('oid'));
}
// We can't update columns of existing index constraint.
if (!m.isNew()) {
- return true;
+ return true;
}
// Disable if index is selected.
var index = m.get('index');
- if(_.isUndefined(index) || index == '') {
- return false;
- } else {
- var col = m.get('columns');
- col.reset();
- return true;
- }
+ if(_.isUndefined(index) || index == '') {
+ return false;
+ } else {
+ var col = m.get('columns');
+ col.reset();
+ return true;
}
- },{
+ },
+ },{
id: 'spcname', label: gettext('Tablespace'),
type: 'text', group: gettext('Definition'),
control: 'node-list-by-name', node: 'tablespace',
@@ -399,40 +394,40 @@ define('pgadmin.node.unique_constraint', [
select2:{allowClear:false},
filter: function(m) {
// Don't show pg_global tablespace in selection.
- if (m.label == "pg_global") return false;
+ if (m.label == 'pg_global') return false;
else return true;
},
disabled: function(m) {
// Disable if index is selected.
m = m.top || m;
var index = m.get('index');
- if(_.isUndefined(index) || index == '') {
- return false;
- } else {
- setTimeout(function(){
- m.set('spcname', '');
- },10);
- return true;
- }
- }
+ if(_.isUndefined(index) || index == '') {
+ return false;
+ } else {
+ setTimeout(function(){
+ m.set('spcname', '');
+ },10);
+ return true;
+ }
+ },
},{
id: 'index', label: gettext('Index'),
type: 'text', group: gettext('Definition'),
control: Backform.NodeListByNameControl.extend({
- initialize:function() {
- if (_.isUndefined(this.model.top)) {
- Backform.NodeListByNameControl.prototype.initialize.apply(this,arguments);
- } else {
- Backform.Control.prototype.initialize.apply(this,arguments);
- }
- }
+ initialize:function() {
+ if (_.isUndefined(this.model.top)) {
+ Backform.NodeListByNameControl.prototype.initialize.apply(this,arguments);
+ } else {
+ Backform.Control.prototype.initialize.apply(this,arguments);
+ }
+ },
}),
select2:{allowClear:true}, node: 'index',
disabled: function(m) {
// If we are in table edit mode then disable it
if (_.has(m, 'top') && !_.isUndefined(m.top)
- && !m.top.isNew()) {
- return true;
+ && !m.top.isNew()) {
+ return true;
}
// We can't update index of existing index constraint.
@@ -441,37 +436,37 @@ define('pgadmin.node.unique_constraint', [
// We will not show this field in Create Table mode
visible: function(m) {
return !_.isUndefined(m.top.node_info['table']);
- }
+ },
},{
id: 'fillfactor', label: gettext('Fill factor'), deps: ['index'],
type: 'int', group: gettext('Definition'), allowNull: true,
disabled: function(m) {
// Disable if index is selected.
var index = m.get('index');
- if(_.isUndefined(index) || index == '') {
- return false;
- } else {
- setTimeout(function(){
- m.set('fillfactor', null);
- },10);
- return true;
- }
+ if(_.isUndefined(index) || index == '') {
+ return false;
+ } else {
+ setTimeout(function(){
+ m.set('fillfactor', null);
+ },10);
+ return true;
}
+ },
},{
id: 'condeferrable', label: gettext('Deferrable?'),
type: 'switch', group: gettext('Definition'), deps: ['index'],
disabled: function(m) {
// If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top)
- && !m.top.isNew()) {
+ && !m.top.isNew()) {
// If OID is undefined then user is trying to add
// new constraint which should allowed for Unique
- return !_.isUndefined(m.get('oid'));
+ return !_.isUndefined(m.get('oid'));
}
// We can't update condeferrable of existing index constraint.
if (!m.isNew()) {
- return true;
+ return true;
}
// Disable if index is selected.
var index = m.get('index');
@@ -484,7 +479,7 @@ define('pgadmin.node.unique_constraint', [
},10);
return true;
}
- }
+ },
},{
id: 'condeferred', label: gettext('Deferred?'),
type: 'switch', group: gettext('Definition'),
@@ -492,10 +487,10 @@ define('pgadmin.node.unique_constraint', [
disabled: function(m) {
// If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top)
- && !m.top.isNew()) {
+ && !m.top.isNew()) {
// If OID is undefined then user is trying to add
// new constraint which should allowed for Unique
- return !_.isUndefined(m.get('oid'));
+ return !_.isUndefined(m.get('oid'));
}
// We can't update condeferred of existing index constraint.
@@ -507,13 +502,13 @@ define('pgadmin.node.unique_constraint', [
return false;
} else {
setTimeout(function(){
- if(m.get('condeferred'))
+ if(m.get('condeferred'))
m.set('condeferred', false);
},10);
return true;
}
- }
- }
+ },
+ },
],
validate: function() {
this.errorModel.clear();
@@ -525,17 +520,17 @@ define('pgadmin.node.unique_constraint', [
var columns = this.get('columns'),
index = this.get('index');
- if ((_.isUndefined(index) || String(index).replace(/^\s+|\s+$/g, '') == '') &&
- (_.isUndefined(columns) || _.isNull(columns) || columns.length < 1)) {
- var msg = gettext('Please specify columns for %(node)s', {node: gettext('Unique constraint')});
- this.errorModel.set('columns', msg);
- return msg;
- }
+ if ((_.isUndefined(index) || String(index).replace(/^\s+|\s+$/g, '') == '') &&
+ (_.isUndefined(columns) || _.isNull(columns) || columns.length < 1)) {
+ var msg = gettext('Please specify columns for %(node)s', {node: gettext('Unique constraint')});
+ this.errorModel.set('columns', msg);
+ return msg;
+ }
return null;
- }
- })
- });
+ },
+ }),
+ });
}
return pgBrowser.Nodes['unique_constraint'];
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/static/js/constraints.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/static/js/constraints.js
index eaf7e9a6..cb242cd2 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/static/js/constraints.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/static/js/constraints.js
@@ -1,20 +1,21 @@
define('pgadmin.node.constraints', [
- 'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'sources/pgadmin',
- 'pgadmin.browser', 'pgadmin.browser.collection', 'pgadmin.node.unique_constraint',
- 'pgadmin.node.check_constraint', 'pgadmin.node.foreign_key',
- 'pgadmin.node.exclusion_constraint', 'pgadmin.node.primary_key'
-], function(gettext, $, _, S, pgAdmin, pgBrowser) {
+ 'sources/gettext', 'jquery', 'underscore', 'sources/pgadmin',
+ 'pgadmin.browser', 'pgadmin.browser.collection',
+ 'pgadmin.node.unique_constraint', 'pgadmin.node.check_constraint',
+ 'pgadmin.node.foreign_key', 'pgadmin.node.exclusion_constraint',
+ 'pgadmin.node.primary_key',
+], function(gettext, $, _, pgAdmin, pgBrowser) {
if (!pgBrowser.Nodes['coll-constraints']) {
- var databases = pgAdmin.Browser.Nodes['coll-constraints'] =
+ pgAdmin.Browser.Nodes['coll-constraints'] =
pgAdmin.Browser.Collection.extend({
node: 'constraints',
label: gettext('Constraints'),
type: 'coll-constraints',
getTreeNodeHierarchy: pgBrowser.tableChildTreeNodeHierarchy,
- columns: ['name', 'comment']
+ columns: ['name', 'comment'],
});
- };
+ }
if (!pgBrowser.Nodes['constraints']) {
pgAdmin.Browser.Nodes['constraints'] = pgBrowser.Node.extend({
@@ -26,7 +27,7 @@ define('pgadmin.node.constraints', [
Init: function() {
/* Avoid mulitple registration of menus */
if (this.initialized)
- return;
+ return;
this.initialized = true;
@@ -36,20 +37,20 @@ define('pgadmin.node.constraints', [
defaults: {
name: undefined,
oid: undefined,
- comment: undefined
- },
+ comment: undefined,
+ },
schema: [{
id: 'name', label: gettext('Name'), type: 'text',
- mode: ['properties', 'create', 'edit']
+ mode: ['properties', 'create', 'edit'],
},{
id: 'oid', label: gettext('Oid'), cell: 'string',
- type: 'text' , mode: ['properties']
+ type: 'text' , mode: ['properties'],
},{
id: 'comment', label: gettext('Comment'), cell: 'string',
- type: 'multiline', mode: ['properties', 'create', 'edit']
- }]
- })
- });
+ type: 'multiline', mode: ['properties', 'create', 'edit'],
+ }],
+ }),
+ });
}
return pgBrowser.Nodes['constraints'];
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js
index f0ce19be..ec2b4da1 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js
@@ -1,11 +1,14 @@
define('pgadmin.node.index', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
- 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'backform', 'alertify',
- 'pgadmin.browser.collection'
-], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
+ 'backbone', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs',
+ 'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.browser.collection',
+], function(
+ gettext, url_for, $, _, Backbone, pgAdmin, pgBrowser, Alertify, Backform,
+ Backgrid
+) {
if (!pgBrowser.Nodes['coll-index']) {
- var databases = pgAdmin.Browser.Nodes['coll-index'] =
+ pgAdmin.Browser.Nodes['coll-index'] =
pgAdmin.Browser.Collection.extend({
node: 'index',
label: gettext('Indexes'),
@@ -16,199 +19,199 @@ define('pgadmin.node.index', [
dialogHelp: url_for('help.static', {'filename': 'index_dialog.html'}),
columns: ['name', 'description'],
hasStatistics: true,
- statsPrettifyFields: ['Size', 'Index size']
+ statsPrettifyFields: ['Size', 'Index size'],
});
- };
+ }
// Node-Ajax-Cell with Deps
var NodeAjaxOptionsDepsCell = Backgrid.Extension.NodeAjaxOptionsCell.extend({
- initialize: function() {
- Backgrid.Extension.NodeAjaxOptionsCell.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('select').first();
+ initialize: function() {
+ Backgrid.Extension.NodeAjaxOptionsCell.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('select').first();
- var 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);
- }
+ var 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
- });
+ this.delegateEvents();
+ return this;
+ },
+ remove: Backgrid.Extension.DependentCell.prototype.remove,
+ });
- // Model to create column collection control
- var ColumnModel = pgAdmin.Browser.Node.Model.extend({
- defaults: {
- colname: undefined,
- collspcname: undefined,
- op_class: undefined,
- sort_order: false,
- nulls: false,
- is_sort_nulls_applicable: true
+ // Model to create column collection control
+ var ColumnModel = pgAdmin.Browser.Node.Model.extend({
+ defaults: {
+ colname: undefined,
+ collspcname: undefined,
+ op_class: undefined,
+ sort_order: false,
+ nulls: false,
+ is_sort_nulls_applicable: true,
+ },
+ schema: [
+ {
+ id: 'colname', label: gettext('Column'), cell: 'node-list-by-name',
+ type: 'text', disabled: 'inSchemaWithModelCheck', editable: function(m) {
+ // Header cell then skip
+ if (m instanceof Backbone.Collection) {
+ return false;
+ }
+ return !(m.inSchemaWithModelCheck.apply(this, arguments));
},
- schema: [
- {
- id: 'colname', label: gettext('Column'), cell: 'node-list-by-name',
- type: 'text', disabled: 'inSchemaWithModelCheck', editable: function(m) {
- // Header cell then skip
- if (m instanceof Backbone.Collection) {
- return false;
- }
- return !(m.inSchemaWithModelCheck.apply(this, arguments));
- },
- control: 'node-list-by-name', node: 'column'
- },{
- id: 'collspcname', label: gettext('Collation'),
- cell: NodeAjaxOptionsDepsCell,
- type: 'text', disabled: 'inSchemaWithModelCheck', editable: function(m) {
- // Header cell then skip
- if (m instanceof Backbone.Collection) {
- return false;
- }
- return !(m.inSchemaWithModelCheck.apply(this, arguments));
- },
- control: 'node-ajax-options', url: 'get_collations', node: 'index'
- },{
- id: 'op_class', label: gettext('Operator class'),
- cell: NodeAjaxOptionsDepsCell, tags: true,
- type: 'text', disabled: 'checkAccessMethod',
- editable: function(m) {
- // Header cell then skip
- if (m instanceof Backbone.Collection) {
- return false;
- } else if (m.inSchemaWithModelCheck.apply(this, arguments)) {
- return false;
- }
- return !(m.checkAccessMethod.apply(this, arguments));
- },
- control: 'node-ajax-options', url: 'get_op_class', node: 'index',
- deps: ['amname'], transform: function(data, control) {
- /* We need to extract data from collection according
- * to access method selected by user if not selected
- * send btree related op_class options
- */
- var amname = control.model.top.get('amname'),
- options = data['btree'];
+ control: 'node-list-by-name', node: 'column',
+ },{
+ id: 'collspcname', label: gettext('Collation'),
+ cell: NodeAjaxOptionsDepsCell,
+ type: 'text', disabled: 'inSchemaWithModelCheck', editable: function(m) {
+ // Header cell then skip
+ if (m instanceof Backbone.Collection) {
+ return false;
+ }
+ return !(m.inSchemaWithModelCheck.apply(this, arguments));
+ },
+ control: 'node-ajax-options', url: 'get_collations', node: 'index',
+ },{
+ id: 'op_class', label: gettext('Operator class'),
+ cell: NodeAjaxOptionsDepsCell, tags: true,
+ type: 'text', disabled: 'checkAccessMethod',
+ editable: function(m) {
+ // Header cell then skip
+ if (m instanceof Backbone.Collection) {
+ return false;
+ } else if (m.inSchemaWithModelCheck.apply(this, arguments)) {
+ return false;
+ }
+ return !(m.checkAccessMethod.apply(this, arguments));
+ },
+ control: 'node-ajax-options', url: 'get_op_class', node: 'index',
+ deps: ['amname'], transform: function(data, control) {
+ /* We need to extract data from collection according
+ * to access method selected by user if not selected
+ * send btree related op_class options
+ */
+ var amname = control.model.top.get('amname'),
+ options = data['btree'];
- if(_.isUndefined(amname))
- return options;
+ if(_.isUndefined(amname))
+ return options;
- _.each(data, function(v, k) {
- if(amname === k) {
- options = v;
- }
- });
- return options;
+ _.each(data, function(v, k) {
+ if(amname === k) {
+ options = v;
}
- },{
- id: 'sort_order', label: gettext('Sort order'),
- cell: Backgrid.Extension.TableChildSwitchCell, type: 'switch',
- editable: function(m) {
- // Header cell then skip
- if (m instanceof Backbone.Collection) {
- return false;
- } else if (m.inSchemaWithModelCheck.apply(this, arguments)) {
- return false;
- } else if (m.top.get('amname') === 'btree') {
- m.set('is_sort_nulls_applicable', true);
- return true;
- } else {
- m.set('is_sort_nulls_applicable', false);
- return false;
- }
- },
- deps: ['amname'],
- options: {
- 'onText': 'DESC', 'offText': 'ASC',
- 'onColor': 'success', 'offColor': 'primary',
- 'size': 'small'
- }
- },{
- id: 'nulls', label: gettext('NULLs'),
- cell: Backgrid.Extension.TableChildSwitchCell, type: 'switch',
- editable: function(m) {
- // Header cell then skip
- if (m instanceof Backbone.Collection) {
- return false;
- } else if (m.inSchemaWithModelCheck.apply(this, arguments)) {
- return false;
- } else if (m.top.get('amname') === 'btree') {
- m.set('is_sort_nulls_applicable', true);
- return true;
- } else {
- m.set('is_sort_nulls_applicable', false);
- return false;
- }
- },
- deps: ['amname', 'sort_order'],
- options: {
- 'onText': 'FIRST', 'offText': 'LAST',
- 'onColor': 'success', 'offColor': 'primary',
- 'size': 'small'
- }
- }
- ],
- validate: function() {
- this.errorModel.clear();
-
- if (_.isUndefined(this.get('colname'))
- || String(this.get('colname')).replace(/^\s+|\s+$/g, '') == '') {
- var msg = gettext('Column Name cannot be empty.');
- this.errorModel.set('colname', msg);
- return msg;
- }
+ });
+ return options;
},
- // We will check if we are under schema node
- inSchema: function() {
- if(this.node_info && 'catalog' in this.node_info) {
+ },{
+ id: 'sort_order', label: gettext('Sort order'),
+ cell: Backgrid.Extension.TableChildSwitchCell, type: 'switch',
+ editable: function(m) {
+ // Header cell then skip
+ if (m instanceof Backbone.Collection) {
+ return false;
+ } else if (m.inSchemaWithModelCheck.apply(this, arguments)) {
+ return false;
+ } else if (m.top.get('amname') === 'btree') {
+ m.set('is_sort_nulls_applicable', true);
return true;
+ } else {
+ m.set('is_sort_nulls_applicable', false);
+ return false;
}
- return false;
},
- // We will check if we are under schema node & in 'create' mode
- inSchemaWithModelCheck: function(m) {
- if(m.top.node_info && 'schema' in m.top.node_info) {
- // We will disable control if it's in 'edit' mode
- if (m.top.isNew()) {
- return false;
- } else {
- return true;
- }
- }
- return true;
+ deps: ['amname'],
+ options: {
+ 'onText': 'DESC', 'offText': 'ASC',
+ 'onColor': 'success', 'offColor': 'primary',
+ 'size': 'small',
},
- // We will check if we are under schema node and added condition
- checkAccessMethod: function(m) {
- //Access method is empty or btree then do not disable field
- var parent_model = m.top;
- if(_.isUndefined(parent_model.get('amname')) ||
- _.isNull(parent_model.get('amname')) ||
- String(parent_model.get('amname')).replace(/^\s+|\s+$/g, '') == '' ||
- parent_model.get('amname') === 'btree') {
- // We need to set nulls to true if sort_order is set to desc
- // nulls first is default for desc
- if(m.get('sort_order') == true && m.previous('sort_order') == false) {
- setTimeout(function() { m.set('nulls', true) }, 10);
- }
- }
- else {
+ },{
+ id: 'nulls', label: gettext('NULLs'),
+ cell: Backgrid.Extension.TableChildSwitchCell, type: 'switch',
+ editable: function(m) {
+ // Header cell then skip
+ if (m instanceof Backbone.Collection) {
+ return false;
+ } else if (m.inSchemaWithModelCheck.apply(this, arguments)) {
+ return false;
+ } else if (m.top.get('amname') === 'btree') {
+ m.set('is_sort_nulls_applicable', true);
+ return true;
+ } else {
m.set('is_sort_nulls_applicable', false);
+ return false;
}
+ },
+ deps: ['amname', 'sort_order'],
+ options: {
+ 'onText': 'FIRST', 'offText': 'LAST',
+ 'onColor': 'success', 'offColor': 'primary',
+ 'size': 'small',
+ },
+ },
+ ],
+ validate: function() {
+ this.errorModel.clear();
+
+ if (_.isUndefined(this.get('colname'))
+ || String(this.get('colname')).replace(/^\s+|\s+$/g, '') == '') {
+ var msg = gettext('Column Name cannot be empty.');
+ this.errorModel.set('colname', msg);
+ return msg;
+ }
+ },
+ // We will check if we are under schema node
+ inSchema: function() {
+ if(this.node_info && 'catalog' in this.node_info) {
+ return true;
+ }
+ return false;
+ },
+ // We will check if we are under schema node & in 'create' mode
+ inSchemaWithModelCheck: function(m) {
+ if(m.top.node_info && 'schema' in m.top.node_info) {
+ // We will disable control if it's in 'edit' mode
+ if (m.top.isNew()) {
return false;
+ } else {
+ return true;
}
- });
+ }
+ return true;
+ },
+ // We will check if we are under schema node and added condition
+ checkAccessMethod: function(m) {
+ //Access method is empty or btree then do not disable field
+ var parent_model = m.top;
+ if(_.isUndefined(parent_model.get('amname')) ||
+ _.isNull(parent_model.get('amname')) ||
+ String(parent_model.get('amname')).replace(/^\s+|\s+$/g, '') == '' ||
+ parent_model.get('amname') === 'btree') {
+ // We need to set nulls to true if sort_order is set to desc
+ // nulls first is default for desc
+ if(m.get('sort_order') == true && m.previous('sort_order') == false) {
+ setTimeout(function() { m.set('nulls', true); }, 10);
+ }
+ }
+ else {
+ m.set('is_sort_nulls_applicable', false);
+ }
+ return false;
+ },
+ });
if (!pgBrowser.Nodes['index']) {
pgAdmin.Browser.Nodes['index'] = pgBrowser.Node.extend({
@@ -226,7 +229,7 @@ define('pgadmin.node.index', [
Init: function() {
/* Avoid mulitple registration of menus */
if (this.initialized)
- return;
+ return;
this.initialized = true;
@@ -235,32 +238,32 @@ define('pgadmin.node.index', [
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Index...'),
icon: 'wcTabIcon icon-index', data: {action: 'create', check: true},
- enable: 'canCreate'
+ enable: 'canCreate',
},{
name: 'create_index', node: 'index', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Index...'),
icon: 'wcTabIcon icon-index', data: {action: 'create', check: true},
- enable: 'canCreate'
+ enable: 'canCreate',
},{
name: 'create_index_onTable', node: 'table', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Index...'),
icon: 'wcTabIcon icon-index', data: {action: 'create', check: true},
- enable: 'canCreate'
+ enable: 'canCreate',
},{
name: 'create_index_onPartition', node: 'partition', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Index...'),
icon: 'wcTabIcon icon-index', data: {action: 'create', check: true},
- enable: 'canCreate'
+ enable: 'canCreate',
},{
name: 'create_index_onMatView', node: 'mview', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 5, label: gettext('Index...'),
icon: 'wcTabIcon icon-index', data: {action: 'create', check: true},
- enable: 'canCreate'
- }
+ enable: 'canCreate',
+ },
]);
},
canDrop: pgBrowser.Nodes['schema'].canChildDrop,
@@ -274,14 +277,14 @@ define('pgadmin.node.index', [
nspname: undefined,
tabname: undefined,
spcname: undefined,
- amname: 'btree'
+ amname: 'btree',
},
schema: [{
id: 'name', label: gettext('Name'), cell: 'string',
- type: 'text', disabled: 'inSchema'
+ type: 'text', disabled: 'inSchema',
},{
id: 'oid', label: gettext('OID'), cell: 'string',
- type: 'int', disabled: true, mode: ['edit', 'properties']
+ type: 'int', disabled: true, mode: ['edit', 'properties'],
},{
id: 'spcname', label: gettext('Tablespace'), cell: 'string',
control: 'node-list-by-name', node: 'tablespace',
@@ -294,7 +297,7 @@ define('pgadmin.node.index', [
return false;
}
return true;
- }
+ },
},{
id: 'amname', label: gettext('Access Method'), cell: 'string',
type: 'text', mode: ['properties', 'create', 'edit'],
@@ -305,63 +308,63 @@ define('pgadmin.node.index', [
onChange: function() {
Backform.NodeAjaxOptionsControl.prototype.onChange.apply(this, arguments);
var self = this,
- // current access method
- current_am = self.model.get('amname'),
- // previous access method
- previous_am = self.model.previous('amname');
+ // current access method
+ current_am = self.model.get('amname'),
+ // previous access method
+ previous_am = self.model.previous('amname');
if (current_am != previous_am && self.model.get('columns').length !== 0) {
var msg = gettext('Changing access method will clear columns collection');
- alertify.confirm(msg, function (e) {
- // User clicks Ok, lets clear collection
- var column_collection = self.model.get('columns'),
- col_length = column_collection.length;
- for (var i=(col_length-1);i>=0;i--) {
- column_collection.remove(column_collection.models[i]);
- }
- }, function() {
- // User clicks Cancel set previous value again in combo box
- setTimeout(function(){
- self.model.set('amname', previous_am);
- }, 10);
+ Alertify.confirm(msg, function () {
+ // User clicks Ok, lets clear collection
+ var column_collection = self.model.get('columns'),
+ col_length = column_collection.length;
+ for (var i=(col_length-1);i>=0;i--) {
+ column_collection.remove(column_collection.models[i]);
+ }
+ }, function() {
+ // User clicks Cancel set previous value again in combo box
+ setTimeout(function(){
+ self.model.set('amname', previous_am);
+ }, 10);
});
}
- }
- })
+ },
+ }),
},{
id: 'cols', label: gettext('Columns'), cell: 'string',
type: 'text', disabled: 'inSchema', mode: ['properties'],
- group: gettext('Definition')
+ group: gettext('Definition'),
},{
id: 'fillfactor', label: gettext('Fill factor'), cell: 'string',
type: 'int', disabled: 'inSchema', mode: ['create', 'edit', 'properties'],
- min: 10, max:100, group: gettext('Definition')
+ min: 10, max:100, group: gettext('Definition'),
},{
id: 'indisunique', label: gettext('Unique?'), cell: 'string',
type: 'switch', disabled: 'inSchemaWithModelCheck',
- group: gettext('Definition')
+ group: gettext('Definition'),
},{
id: 'indisclustered', label: gettext('Clustered?'), cell: 'string',
type: 'switch', disabled: 'inSchema',
- group: gettext('Definition')
+ group: gettext('Definition'),
},{
id: 'indisvalid', label: gettext('Valid?'), cell: 'string',
type: 'switch', disabled: true, mode: ['properties'],
- group: gettext('Definition')
+ group: gettext('Definition'),
},{
id: 'indisprimary', label: gettext('Primary?'), cell: 'string',
type: 'switch', disabled: true, mode: ['properties'],
- group: gettext('Definition')
+ group: gettext('Definition'),
},{
id: 'is_sys_idx', label: gettext('System index?'), cell: 'string',
- type: 'switch', disabled: true, mode: ['properties']
+ type: 'switch', disabled: true, mode: ['properties'],
},{
id: 'isconcurrent', label: gettext('Concurrent build?'), cell: 'string',
type: 'switch', disabled: 'inSchemaWithModelCheck',
- mode: ['create', 'edit'], group: gettext('Definition')
+ mode: ['create', 'edit'], group: gettext('Definition'),
},{
id: 'indconstraint', label: gettext('Constraint'), cell: 'string',
type: 'text', disabled: 'inSchemaWithModelCheck', mode: ['create', 'edit'],
- control: 'sql-field', visible: true, group: gettext('Definition')
+ control: 'sql-field', visible: true, group: gettext('Definition'),
},{
id: 'columns', label: gettext('Columns'), type: 'collection', deps: ['amname'],
group: gettext('Definition'), model: ColumnModel, mode: ['edit', 'create'],
@@ -383,17 +386,15 @@ define('pgadmin.node.index', [
}
},
control: 'unique-col-collection', uniqueCol : ['colname'],
- columns: ['colname', 'op_class', 'sort_order', 'nulls', 'collspcname']
+ columns: ['colname', 'op_class', 'sort_order', 'nulls', 'collspcname'],
},{
id: 'description', label: gettext('Comment'), cell: 'string',
type: 'multiline', mode: ['properties', 'create', 'edit'],
- disabled: 'inSchema'
- }
+ disabled: 'inSchema',
+ },
],
validate: function(keys) {
- var err = {},
- changedAttrs = this.changed,
- msg = undefined;
+ var msg;
// Nothing to validate
if (keys && keys.length == 0) {
@@ -404,19 +405,19 @@ define('pgadmin.node.index', [
}
if (_.isUndefined(this.get('name'))
- || String(this.get('name')).replace(/^\s+|\s+$/g, '') == '') {
+ || String(this.get('name')).replace(/^\s+|\s+$/g, '') == '') {
msg = gettext('Name cannot be empty.');
this.errorModel.set('name', msg);
return msg;
}
if (_.isUndefined(this.get('spcname'))
- || String(this.get('spcname')).replace(/^\s+|\s+$/g, '') == '') {
+ || String(this.get('spcname')).replace(/^\s+|\s+$/g, '') == '') {
msg = gettext('Tablespace cannot be empty.');
this.errorModel.set('spcname', msg);
return msg;
}
if (_.isUndefined(this.get('amname'))
- || String(this.get('amname')).replace(/^\s+|\s+$/g, '') == '') {
+ || String(this.get('amname')).replace(/^\s+|\s+$/g, '') == '') {
msg = gettext('Access method cannot be empty.');
this.errorModel.set('amname', msg);
return msg;
@@ -424,15 +425,15 @@ define('pgadmin.node.index', [
// Checks if all columns has names
var cols = this.get('columns');
if(cols && cols.length > 0) {
- if(!_.every(cols.pluck('colname'))) {
- msg = gettext('You must specify column name.');
- this.errorModel.set('columns', msg);
- return msg;
- }
+ if(!_.every(cols.pluck('colname'))) {
+ msg = gettext('You must specify column name.');
+ this.errorModel.set('columns', msg);
+ return msg;
+ }
} else if(cols){
- msg = gettext('You must specify at least one column.');
- this.errorModel.set('columns', msg);
- return msg;
+ msg = gettext('You must specify at least one column.');
+ this.errorModel.set('columns', msg);
+ return msg;
}
return null;
},
@@ -469,47 +470,47 @@ define('pgadmin.node.index', [
} else {
return true;
}
- }
+ }
}
return true;
- }
+ },
}),
// Below function will enable right click menu for creating column
canCreate: function(itemData, item, data) {
- // If check is false then , we will allow create menu
- if (data && data.check == false)
- return true;
+ // If check is false then , we will allow create menu
+ if (data && data.check == false)
+ return true;
- var t = pgBrowser.tree, i = item, d = itemData, parents = [],
- immediate_parent_table_found = false,
- is_immediate_parent_table_partitioned = false;
- // To iterate over tree to check parent node
- while (i) {
- // Do not allow creating index on partitioned tables.
- if (!immediate_parent_table_found &&
- _.indexOf(['table', 'partition'], d._type) > -1) {
- immediate_parent_table_found = true;
- if ('is_partitioned' in d && d.is_partitioned) {
- is_immediate_parent_table_partitioned = true;
- }
+ var t = pgBrowser.tree, i = item, d = itemData, parents = [],
+ immediate_parent_table_found = false,
+ is_immediate_parent_table_partitioned = false;
+ // To iterate over tree to check parent node
+ while (i) {
+ // Do not allow creating index on partitioned tables.
+ if (!immediate_parent_table_found &&
+ _.indexOf(['table', 'partition'], d._type) > -1) {
+ immediate_parent_table_found = true;
+ if ('is_partitioned' in d && d.is_partitioned) {
+ is_immediate_parent_table_partitioned = true;
}
-
- // If it is schema then allow user to create index
- if (_.indexOf(['schema'], d._type) > -1)
- return !is_immediate_parent_table_partitioned;
- parents.push(d._type);
- i = t.hasParent(i) ? t.parent(i) : null;
- d = i ? t.itemData(i) : null;
}
- // If node is under catalog then do not allow 'create' menu
- if (_.indexOf(parents, 'catalog') > -1) {
- return false;
- } else {
+
+ // If it is schema then allow user to create index
+ if (_.indexOf(['schema'], d._type) > -1)
return !is_immediate_parent_table_partitioned;
- }
- }
- });
- }
+ parents.push(d._type);
+ i = t.hasParent(i) ? t.parent(i) : null;
+ d = i ? t.itemData(i) : null;
+ }
+ // If node is under catalog then do not allow 'create' menu
+ if (_.indexOf(parents, 'catalog') > -1) {
+ return false;
+ } else {
+ return !is_immediate_parent_table_partitioned;
+ }
+ },
+ });
+ }
return pgBrowser.Nodes['index'];
});
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js
index a1a27b2c..fd53f743 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js
@@ -1,26 +1,28 @@
define([
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
- 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'backform', 'pgadmin.alertifyjs',
- 'pgadmin.browser.collection', 'pgadmin.browser.table.partition.utils'
+ 'underscore.string', 'sources/pgadmin', 'pgadmin.browser',
+ 'pgadmin.alertifyjs', 'pgadmin.backform', 'pgadmin.backgrid',
+ 'pgadmin.browser.collection', 'pgadmin.browser.table.partition.utils',
],
-function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
+function(
+ gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, Backform, Backgrid
+) {
if (!pgBrowser.Nodes['coll-partition']) {
- var databases = pgAdmin.Browser.Nodes['coll-partition'] =
+ pgAdmin.Browser.Nodes['coll-partition'] =
pgAdmin.Browser.Collection.extend({
node: 'partition',
label: gettext('Partitions'),
getTreeNodeHierarchy: pgBrowser.tableChildTreeNodeHierarchy,
type: 'coll-partition',
columns: [
- 'name', 'schema', 'partition_value', 'is_partitioned', 'description'
- ]
+ 'name', 'schema', 'partition_value', 'is_partitioned', 'description',
+ ],
});
- };
+ }
if (!pgBrowser.Nodes['partition']) {
pgAdmin.Browser.Nodes['partition'] = pgBrowser.Node.extend({
- getTreeNodeHierarchy: pgBrowser.tableChildTreeNodeHierarchy,
parent_type: 'table',
collection_type: 'coll-partition',
type: 'partition',
@@ -29,8 +31,8 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
hasDepends: true,
hasStatistics: true,
statsPrettifyFields: ['Size', 'Indexes size', 'Table size',
- 'Toast table size', 'Tuple length',
- 'Dead tuple length', 'Free space'],
+ 'Toast table size', 'Tuple length',
+ 'Dead tuple length', 'Free space'],
sqlAlterHelp: 'sql-altertable.html',
sqlCreateHelp: 'sql-createtable.html',
dialogHelp: url_for('help.static', {'filename': 'table_dialog.html'}),
@@ -40,7 +42,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
Init: function() {
/* Avoid mulitple registration of menus */
if (this.initialized)
- return;
+ return;
this.initialized = true;
@@ -48,40 +50,40 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
name: 'truncate_table', node: 'partition', module: this,
applies: ['object', 'context'], callback: 'truncate_table',
category: 'Truncate', priority: 3, label: gettext('Truncate'),
- icon: 'fa fa-eraser', enable : 'canCreate'
+ icon: 'fa fa-eraser', enable : 'canCreate',
},{
name: 'truncate_table_cascade', node: 'partition', module: this,
applies: ['object', 'context'], callback: 'truncate_table_cascade',
category: 'Truncate', priority: 3, label: gettext('Truncate Cascade'),
- icon: 'fa fa-eraser', enable : 'canCreate'
+ icon: 'fa fa-eraser', enable : 'canCreate',
},{
// To enable/disable all triggers for the table
name: 'enable_all_triggers', node: 'partition', module: this,
applies: ['object', 'context'], callback: 'enable_triggers_on_table',
category: 'Trigger(s)', priority: 4, label: gettext('Enable All'),
- icon: 'fa fa-check', enable : 'canCreate_with_trigger_enable'
+ icon: 'fa fa-check', enable : 'canCreate_with_trigger_enable',
},{
name: 'disable_all_triggers', node: 'partition', module: this,
applies: ['object', 'context'], callback: 'disable_triggers_on_table',
category: 'Trigger(s)', priority: 4, label: gettext('Disable All'),
- icon: 'fa fa-times', enable : 'canCreate_with_trigger_disable'
+ icon: 'fa fa-times', enable : 'canCreate_with_trigger_disable',
},{
name: 'reset_table_stats', node: 'partition', module: this,
applies: ['object', 'context'], callback: 'reset_table_stats',
category: 'Reset', priority: 4, label: gettext('Reset Statistics'),
- icon: 'fa fa-bar-chart', enable : 'canCreate'
+ icon: 'fa fa-bar-chart', enable : 'canCreate',
},{
name: 'detach_partition', node: 'partition', module: this,
applies: ['object', 'context'], callback: 'detach_partition',
priority: 2, label: gettext('Detach Partition'),
- icon: 'fa fa-remove'
- }
+ icon: 'fa fa-remove',
+ },
]);
},
getTreeNodeHierarchy: function(i) {
var idx = 0,
- res = {},
- t = pgBrowser.tree;
+ res = {},
+ t = pgBrowser.tree;
do {
var d = t.itemData(i);
@@ -110,9 +112,9 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
},
generate_url: function(item, type, d, with_id, info) {
if (_.indexOf([
- 'stats', 'statistics', 'dependency', 'dependent', 'reset',
- 'get_relations', 'get_oftype', 'get_attach_tables'
- ], type) == -1) {
+ 'stats', 'statistics', 'dependency', 'dependent', 'reset',
+ 'get_relations', 'get_oftype', 'get_attach_tables',
+ ], type) == -1) {
return pgBrowser.Node.generate_url.apply(this, arguments);
}
@@ -136,22 +138,22 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
callbacks: {
/* Enable trigger(s) on table */
enable_triggers_on_table: function(args) {
- var params = {'enable': true };
- this.callbacks.set_triggers.apply(this, [args, params]);
+ var params = {'enable': true };
+ this.callbacks.set_triggers.apply(this, [args, params]);
},
/* Disable trigger(s) on table */
disable_triggers_on_table: function(args) {
- var params = {'enable': false };
- this.callbacks.set_triggers.apply(this, [args, params]);
+ var params = {'enable': false };
+ this.callbacks.set_triggers.apply(this, [args, params]);
},
set_triggers: function(args, params) {
// This function will send request to enable or
// disable triggers on table level
var input = args || {},
- obj = this,
- t = pgBrowser.tree,
- i = input.item || t.selected(),
- d = i && i.length == 1 ? t.itemData(i) : undefined;
+ obj = this,
+ t = pgBrowser.tree,
+ i = input.item || t.selected(),
+ d = i && i.length == 1 ? t.itemData(i) : undefined;
if (!d)
return false;
@@ -160,10 +162,10 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
url: obj.generate_url(i, 'set_trigger' , d, true),
type:'PUT',
data: params,
- dataType: "json",
+ dataType: 'json',
success: function(res) {
if (res.success == 1) {
- alertify.success(res.info);
+ Alertify.success(res.info);
t.unload(i);
t.setInode(i);
t.deselect(i);
@@ -172,74 +174,78 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
}, 10);
}
},
- error: function(xhr, status, error) {
+ error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
if (err.success == 0) {
- alertify.error(err.errormsg);
+ Alertify.error(err.errormsg);
}
- } catch (e) {}
+ } catch (e) {
+ console.warn(e.stack || e);
+ }
t.unload(i);
- }
+ },
});
},
/* Truncate table */
truncate_table: function(args) {
- var params = {'cascade': false };
- this.callbacks.truncate.apply(this, [args, params]);
+ var params = {'cascade': false };
+ this.callbacks.truncate.apply(this, [args, params]);
},
/* Truncate table with cascade */
truncate_table_cascade: function(args) {
- var params = {'cascade': true };
- this.callbacks.truncate.apply(this, [args, params]);
+ var params = {'cascade': true };
+ this.callbacks.truncate.apply(this, [args, params]);
},
truncate: function(args, params) {
var input = args || {},
- obj = this,
- t = pgBrowser.tree,
- i = input.item || t.selected(),
- d = i && i.length == 1 ? t.itemData(i) : undefined;
+ obj = this,
+ t = pgBrowser.tree,
+ i = input.item || t.selected(),
+ d = i && i.length == 1 ? t.itemData(i) : undefined;
if (!d)
return false;
- alertify.confirm(
+ Alertify.confirm(
gettext('Truncate Table'),
S(gettext('Are you sure you want to truncate table %s?')).sprintf(d.label).value(),
function (e) {
- if (e) {
- var data = d;
- $.ajax({
- url: obj.generate_url(i, 'truncate' , d, true),
- type:'PUT',
- data: params,
- dataType: "json",
- success: function(res) {
- if (res.success == 1) {
- alertify.success(res.info);
- t.removeIcon(i);
- data.icon = 'icon-partition';
- t.addIcon(i, {icon: data.icon});
- t.unload(i);
- t.setInode(i);
- t.deselect(i);
+ if (e) {
+ var data = d;
+ $.ajax({
+ url: obj.generate_url(i, 'truncate' , d, true),
+ type:'PUT',
+ data: params,
+ dataType: 'json',
+ success: function(res) {
+ if (res.success == 1) {
+ Alertify.success(res.info);
+ t.removeIcon(i);
+ data.icon = 'icon-partition';
+ t.addIcon(i, {icon: data.icon});
+ t.unload(i);
+ t.setInode(i);
+ t.deselect(i);
// Fetch updated data from server
- setTimeout(function() {
- t.select(i);
- }, 10);
- }
- },
- error: function(xhr, status, error) {
- try {
- var err = $.parseJSON(xhr.responseText);
- if (err.success == 0) {
- alertify.error(err.errormsg);
+ setTimeout(function() {
+ t.select(i);
+ }, 10);
}
- } catch (e) {}
- t.unload(i);
- }
- });
- }},
+ },
+ error: function(xhr) {
+ try {
+ var err = $.parseJSON(xhr.responseText);
+ if (err.success == 0) {
+ Alertify.error(err.errormsg);
+ }
+ } catch (e) {
+ console.warn(e.stack || e);
+ }
+ t.unload(i);
+ },
+ });
+ }},
function() {}
);
},
@@ -253,7 +259,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
if (!d)
return false;
- alertify.confirm(
+ Alertify.confirm(
gettext('Reset statistics'),
S(gettext('Are you sure you want to reset the statistics for table "%s"?')).sprintf(d._label).value(),
function (e) {
@@ -264,7 +270,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
type:'DELETE',
success: function(res) {
if (res.success == 1) {
- alertify.success(res.info);
+ Alertify.success(res.info);
t.removeIcon(i);
data.icon = 'icon-partition';
t.addIcon(i, {icon: data.icon});
@@ -277,15 +283,17 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
}, 10);
}
},
- error: function(xhr, status, error) {
+ error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
if (err.success == 0) {
- alertify.error(err.errormsg);
+ Alertify.error(err.errormsg);
}
- } catch (e) {}
+ } catch (e) {
+ console.warn(e.stack || e);
+ }
t.unload(i);
- }
+ },
});
}
},
@@ -302,18 +310,17 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
if (!d)
return false;
- alertify.confirm(
+ Alertify.confirm(
gettext('Detach Partition'),
S(gettext('Are you sure you want to detach the partition %s?')).sprintf(d._label).value(),
function (e) {
if (e) {
- var data = d;
$.ajax({
url: obj.generate_url(i, 'detach' , d, true),
type:'PUT',
success: function(res) {
if (res.success == 1) {
- alertify.success(res.info);
+ Alertify.success(res.info);
var n = t.next(i);
if (!n || !n.length) {
n = t.prev(i);
@@ -328,20 +335,22 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
}
}
},
- error: function(xhr, status, error) {
+ error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
if (err.success == 0) {
- alertify.error(err.errormsg);
+ Alertify.error(err.errormsg);
}
- } catch (e) {}
- }
+ } catch (e) {
+ console.warn(e.stack || e);
+ }
+ },
});
}
},
function() {}
);
- }
+ },
},
model: pgBrowser.Node.Model.extend({
defaults: {
@@ -374,18 +383,18 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
partitions: [],
partition_type: 'range',
is_partitioned: false,
- partition_value: undefined
+ partition_value: undefined,
},
// Default values!
initialize: function(attrs, args) {
- var self = this;
-
if (_.size(attrs) === 0) {
- var userInfo = pgBrowser.serverInfo[args.node_info.server._id].user,
- schemaInfo = args.node_info.schema;
+ var userInfo = pgBrowser.serverInfo[
+ args.node_info.server._id
+ ].user,
+ schemaInfo = args.node_info.schema;
this.set({
- 'relowner': userInfo.name, 'schema': schemaInfo._label
+ 'relowner': userInfo.name, 'schema': schemaInfo._label,
}, {silent: true});
}
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
@@ -393,13 +402,13 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
},
schema: [{
id: 'name', label: gettext('Name'), type: 'text',
- mode: ['properties', 'create', 'edit'], disabled: 'inSchema'
+ mode: ['properties', 'create', 'edit'], disabled: 'inSchema',
},{
- id: 'oid', label: gettext('OID'), type: 'text', mode: ['properties']
+ id: 'oid', label: gettext('OID'), type: 'text', mode: ['properties'],
},{
id: 'relowner', label: gettext('Owner'), type: 'text', node: 'role',
mode: ['properties', 'create', 'edit'], select2: {allowClear: false},
- disabled: 'inSchema', control: 'node-list-by-name'
+ disabled: 'inSchema', control: 'node-list-by-name',
},{
id: 'schema', label: gettext('Schema'), type: 'text', node: 'schema',
control: 'node-list-by-name', mode: ['create', 'edit', 'properties'],
@@ -410,15 +419,15 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
return false;
}
return true;
- }, cache_node: 'database', cache_level: 'database'
+ }, cache_node: 'database', cache_level: 'database',
},{
id: 'spcname', label: gettext('Tablespace'), node: 'tablespace',
type: 'text', control: 'node-list-by-name', disabled: 'inSchema',
mode: ['properties', 'create', 'edit'],
filter: function(d) {
// If tablespace name is not "pg_global" then we need to exclude them
- return (!(d && d.label.match(/pg_global/)))
- }
+ return (!(d && d.label.match(/pg_global/)));
+ },
},{
id: 'partition', type: 'group', label: gettext('Partition'),
mode: ['edit', 'create'], min_version: 100000,
@@ -427,7 +436,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
if (m.isNew() || m.get('is_partitioned'))
return true;
return false;
- }
+ },
},{
id: 'is_partitioned', label:gettext('Partitioned Table?'), cell: 'switch',
type: 'switch', mode: ['properties', 'create', 'edit'],
@@ -443,24 +452,22 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
if (!m.isNew())
return true;
return false;
- }
+ },
},{
id: 'description', label: gettext('Comment'), type: 'multiline',
- mode: ['properties', 'create', 'edit'], disabled: 'inSchema'
+ mode: ['properties', 'create', 'edit'], disabled: 'inSchema',
},
{
id: 'partition_value', label:gettext('Partition Scheme'),
- type: 'text', visible: false
+ type: 'text', visible: false,
},{
id: 'coll_inherits', label: gettext('Inherited from table(s)'),
- type: 'text', group: gettext('Advanced'), mode: ['properties']
+ type: 'text', group: gettext('Advanced'), mode: ['properties'],
},{
id: 'Columns', type: 'group', label: gettext('Columns'),
mode: ['edit', 'create'], min_version: 100000,
- visible: function(m) {
- // Always hide in case of partition table.
- return false;
- }
+ // Always hide in case of partition table.
+ visible: function() { return false; },
},{
// Tab control for columns
id: 'columns', label: gettext('Columns'), type: 'collection',
@@ -499,12 +506,12 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
initialize: function() {
Backform.UniqueColCollectionControl.prototype.initialize.apply(this, arguments);
var self = this,
- collection = self.model.get(self.field.get('name'));
+ collection = self.model.get(self.field.get('name'));
- collection.on("change:is_primary_key", function(m) {
+ collection.on('change:is_primary_key', function(m) {
var primary_key_coll = self.model.get('primary_key'),
- column_name = m.get('name'),
- primary_key;
+ column_name = m.get('name'),
+ primary_key, primary_key_column_coll;
if(m.get('is_primary_key')) {
// Add column to primary key.
@@ -512,7 +519,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
primary_key = new (primary_key_coll.model)({}, {
top: self.model,
collection: primary_key_coll,
- handler: primary_key_coll
+ handler: primary_key_coll,
});
primary_key_coll.add(primary_key);
} else {
@@ -520,39 +527,43 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
}
// Do not alter existing primary key columns.
if (_.isUndefined(primary_key.get('oid'))) {
- var primary_key_column_coll = primary_key.get('columns'),
- primary_key_column_exist = primary_key_column_coll.where({column:column_name});
+ primary_key_column_coll = primary_key.get('columns');
+ var primary_key_column_exist = primary_key_column_coll.where({column:column_name});
if (primary_key_column_exist.length == 0) {
var primary_key_column = new (primary_key_column_coll.model)(
{column: column_name}, { silent: true,
- top: self.model,
- collection: primary_key_coll,
- handler: primary_key_coll
- });
+ top: self.model,
+ collection: primary_key_coll,
+ handler: primary_key_coll,
+ });
primary_key_column_coll.add(primary_key_column);
}
- primary_key_column_coll.trigger('pgadmin:multicolumn:updated', primary_key_column_coll);
+ primary_key_column_coll.trigger(
+ 'pgadmin:multicolumn:updated', primary_key_column_coll
+ );
}
} else {
// remove column from primary key.
if (primary_key_coll.length > 0) {
- var primary_key = primary_key_coll.first();
+ primary_key = primary_key_coll.first();
// Do not alter existing primary key columns.
if (!_.isUndefined(primary_key.get('oid'))) {
return;
}
- var primary_key_column_coll = primary_key.get('columns'),
- removedCols = primary_key_column_coll.where({column:column_name});
+ primary_key_column_coll = primary_key.get('columns');
+ var removedCols = primary_key_column_coll.where({
+ column: column_name,
+ });
if (removedCols.length > 0) {
primary_key_column_coll.remove(removedCols);
_.each(removedCols, function(m) {
m.destroy();
- })
+ });
if (primary_key_column_coll.length == 0) {
setTimeout(function () {
// There will be only on primary key so remove the first one.
@@ -568,226 +579,218 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
primary_key_column_coll.trigger('pgadmin:multicolumn:updated', primary_key_column_coll);
}
}
- })
+ });
},
remove: function() {
var collection = this.model.get(this.field.get('name'));
if (collection) {
- collection.off("change:is_primary_key");
+ collection.off('change:is_primary_key');
}
Backform.UniqueColCollectionControl.prototype.remove.apply(this, arguments);
- }
+ },
}),
- allowMultipleEmptyRow: false
+ allowMultipleEmptyRow: false,
},{
id: 'inherited_tables_cnt', label: gettext('Inherited tables count'),
type: 'text', mode: ['properties'], group: gettext('Advanced'),
- disabled: 'inSchema'
+ disabled: 'inSchema',
},{
// Here we will create tab control for constraints
type: 'nested', control: 'tab', group: gettext('Constraints'),
mode: ['edit', 'create'],
schema: [{
- id: 'primary_key', label: gettext('Primary key'),
- model: pgBrowser.Nodes['primary_key'].model,
- subnode: pgBrowser.Nodes['primary_key'].model,
- editable: false, type: 'collection',
- group: gettext('Primary Key'), mode: ['edit', 'create'],
- canEdit: true, canDelete: true, deps:['is_partitioned'],
- control: 'unique-col-collection',
- columns : ['name', 'columns'],
- canAdd: function(m) {
- if (m.get('is_partitioned')) {
- setTimeout(function() {
- var coll = m.get('primary_key');
- coll.remove(coll.filter(function(model) {
- return true;
- }));
- }, 10);
- return false;
- }
+ id: 'primary_key', label: gettext('Primary key'),
+ model: pgBrowser.Nodes['primary_key'].model,
+ subnode: pgBrowser.Nodes['primary_key'].model,
+ editable: false, type: 'collection',
+ group: gettext('Primary Key'), mode: ['edit', 'create'],
+ canEdit: true, canDelete: true, deps:['is_partitioned'],
+ control: 'unique-col-collection',
+ columns : ['name', 'columns'],
+ canAdd: function(m) {
+ if (m.get('is_partitioned')) {
+ setTimeout(function() {
+ var coll = m.get('primary_key');
+ coll.remove(coll.filter(function() { return true; }));
+ }, 10);
+ return false;
+ }
- return true;
- },
- canAddRow: function(m) {
+ return true;
+ },
+ canAddRow: function(m) {
// User can only add one primary key
- var columns = m.get('columns');
+ var columns = m.get('columns');
- return (m.get('primary_key') &&
+ return (m.get('primary_key') &&
m.get('primary_key').length < 1 &&
_.some(columns.pluck('name')));
+ },
+ },{
+ id: 'foreign_key', label: gettext('Foreign key'),
+ model: pgBrowser.Nodes['foreign_key'].model,
+ subnode: pgBrowser.Nodes['foreign_key'].model,
+ editable: false, type: 'collection',
+ group: gettext('Foreign Key'), mode: ['edit', 'create'],
+ canEdit: true, canDelete: true, deps:['is_partitioned'],
+ control: 'unique-col-collection',
+ canAdd: function(m) {
+ if (m.get('is_partitioned')) {
+ setTimeout(function() {
+ var coll = m.get('foreign_key');
+ coll.remove(coll.filter(function() { return true; }));
+ }, 10);
+ return false;
}
- },{
- id: 'foreign_key', label: gettext('Foreign key'),
- model: pgBrowser.Nodes['foreign_key'].model,
- subnode: pgBrowser.Nodes['foreign_key'].model,
- editable: false, type: 'collection',
- group: gettext('Foreign Key'), mode: ['edit', 'create'],
- canEdit: true, canDelete: true, deps:['is_partitioned'],
- control: 'unique-col-collection',
- canAdd: function(m) {
- if (m.get('is_partitioned')) {
- setTimeout(function() {
- var coll = m.get('foreign_key');
- coll.remove(coll.filter(function(model) {
- return true;
- }));
- }, 10);
- return false;
- }
- return true;
- },
- columns : ['name', 'columns'],
- canAddRow: function(m) {
+ return true;
+ },
+ columns : ['name', 'columns'],
+ canAddRow: function(m) {
// User can only add if there is at least one column with name.
- var columns = m.get('columns');
- return _.some(columns.pluck('name'));
+ var columns = m.get('columns');
+ return _.some(columns.pluck('name'));
+ },
+ },{
+ id: 'check_constraint', label: gettext('Check constraint'),
+ model: pgBrowser.Nodes['check_constraint'].model,
+ subnode: pgBrowser.Nodes['check_constraint'].model,
+ editable: false, type: 'collection',
+ group: gettext('Check'), mode: ['edit', 'create'],
+ canEdit: true, canDelete: true, deps:['is_partitioned'],
+ control: 'unique-col-collection',
+ canAdd: true,
+ columns : ['name', 'consrc'],
+ },{
+ id: 'unique_constraint', label: gettext('Unique Constraint'),
+ model: pgBrowser.Nodes['unique_constraint'].model,
+ subnode: pgBrowser.Nodes['unique_constraint'].model,
+ editable: false, type: 'collection',
+ group: gettext('Unique'), mode: ['edit', 'create'],
+ canEdit: true, canDelete: true, deps:['is_partitioned'],
+ control: 'unique-col-collection',
+ columns : ['name', 'columns'],
+ canAdd: function(m) {
+ if (m.get('is_partitioned')) {
+ setTimeout(function() {
+ var coll = m.get('unique_constraint');
+ coll.remove(coll.filter(function() { return true; }));
+ }, 10);
+ return false;
}
- },{
- id: 'check_constraint', label: gettext('Check constraint'),
- model: pgBrowser.Nodes['check_constraint'].model,
- subnode: pgBrowser.Nodes['check_constraint'].model,
- editable: false, type: 'collection',
- group: gettext('Check'), mode: ['edit', 'create'],
- canEdit: true, canDelete: true, deps:['is_partitioned'],
- control: 'unique-col-collection',
- canAdd: true,
- columns : ['name', 'consrc']
- },{
- id: 'unique_constraint', label: gettext('Unique Constraint'),
- model: pgBrowser.Nodes['unique_constraint'].model,
- subnode: pgBrowser.Nodes['unique_constraint'].model,
- editable: false, type: 'collection',
- group: gettext('Unique'), mode: ['edit', 'create'],
- canEdit: true, canDelete: true, deps:['is_partitioned'],
- control: 'unique-col-collection',
- columns : ['name', 'columns'],
- canAdd: function(m) {
- if (m.get('is_partitioned')) {
- setTimeout(function() {
- var coll = m.get('unique_constraint');
- coll.remove(coll.filter(function(model) {
- return true;
- }));
- }, 10);
- return false;
- }
- return true;
- },
- canAddRow: function(m) {
+ return true;
+ },
+ canAddRow: function(m) {
// User can only add if there is at least one column with name.
- var columns = m.get('columns');
- return _.some(columns.pluck('name'));
+ var columns = m.get('columns');
+ return _.some(columns.pluck('name'));
+ },
+ },{
+ id: 'exclude_constraint', label: gettext('Exclude constraint'),
+ model: pgBrowser.Nodes['exclusion_constraint'].model,
+ subnode: pgBrowser.Nodes['exclusion_constraint'].model,
+ editable: false, type: 'collection',
+ group: gettext('Exclude'), mode: ['edit', 'create'],
+ canEdit: true, canDelete: true, deps:['is_partitioned'],
+ control: 'unique-col-collection',
+ columns : ['name', 'columns', 'constraint'],
+ canAdd: function(m) {
+ if (m.get('is_partitioned')) {
+ setTimeout(function() {
+ var coll = m.get('exclude_constraint');
+ coll.remove(coll.filter(function() { return true; }));
+ }, 10);
+ return false;
}
- },{
- id: 'exclude_constraint', label: gettext('Exclude constraint'),
- model: pgBrowser.Nodes['exclusion_constraint'].model,
- subnode: pgBrowser.Nodes['exclusion_constraint'].model,
- editable: false, type: 'collection',
- group: gettext('Exclude'), mode: ['edit', 'create'],
- canEdit: true, canDelete: true, deps:['is_partitioned'],
- control: 'unique-col-collection',
- columns : ['name', 'columns', 'constraint'],
- canAdd: function(m) {
- if (m.get('is_partitioned')) {
- setTimeout(function() {
- var coll = m.get('exclude_constraint');
- coll.remove(coll.filter(function(model) {
- return true;
- }));
- }, 10);
- return false;
- }
- return true;
- },
- canAddRow: function(m) {
+ return true;
+ },
+ canAddRow: function(m) {
// User can only add if there is at least one column with name.
- var columns = m.get('columns');
- return _.some(columns.pluck('name'));
- }
- }]
+ var columns = m.get('columns');
+ return _.some(columns.pluck('name'));
+ },
+ }],
},{
id: 'typname', label: gettext('Of type'), type: 'text',
- control: 'node-ajax-options', mode: ['properties', 'create', 'edit'],
- disabled: 'checkOfType', url: 'get_oftype', group: gettext('Advanced'),
- deps: ['coll_inherits', 'is_partitioned'], transform: function(data, cell) {
+ mode: ['properties', 'create', 'edit'], group: gettext('Advanced'),
+ disabled: 'checkOfType', url: 'get_oftype',
+ deps: ['coll_inherits', 'is_partitioned'],
+ transform: function(data, cell) {
var control = cell || this,
m = control.model;
- m.of_types_tables = data;
- return data;
+ m.of_types_tables = data;
+ return data;
},
control: Backform.NodeAjaxOptionsControl.extend({
// When of_types changes we need to clear columns collection
- onChange: function() {
- Backform.NodeAjaxOptionsControl.prototype.onChange.apply(this, arguments);
- var self = this,
- tbl_oid = undefined,
- tbl_name = self.model.get('typname'),
- data = undefined,
- arg = undefined,
- column_collection = self.model.get('columns');
+ onChange: function() {
+ Backform.NodeAjaxOptionsControl.prototype.onChange.apply(this, arguments);
+ var self = this,
+ tbl_name = self.model.get('typname'),
+ data = undefined,
+ arg = undefined,
+ column_collection = self.model.get('columns');
- if (!_.isUndefined(tbl_name) &&
+ if (!_.isUndefined(tbl_name) &&
tbl_name !== '' && column_collection.length !== 0) {
- var msg = gettext('Changing of table type will clear columns collection.');
- alertify.confirm(msg, function (e) {
- if (e) {
+ var msg = gettext('Changing of table type will clear columns collection.');
+ Alertify.confirm(msg, function (e) {
+ if (e) {
// User clicks Ok, lets clear columns collection
- column_collection.reset();
- } else {
- return this;
- }
- });
- } else if (!_.isUndefined(tbl_name) && tbl_name === '') {
- column_collection.reset();
- }
+ column_collection.reset();
+ } else {
+ return this;
+ }
+ });
+ } else if (!_.isUndefined(tbl_name) && tbl_name === '') {
+ column_collection.reset();
+ }
// Run Ajax now to fetch columns
- if (!_.isUndefined(tbl_name) && tbl_name !== '') {
- arg = { 'tname': tbl_name }
- data = self.model.fetch_columns_ajax.apply(self, [arg]);
+ if (!_.isUndefined(tbl_name) && tbl_name !== '') {
+ arg = { 'tname': tbl_name };
+ data = self.model.fetch_columns_ajax.apply(self, [arg]);
// Add into column collection
- column_collection.set(data, { merge:false,remove:false });
- }
+ column_collection.set(data, { merge:false,remove:false });
}
- })
+ },
+ }),
},{
id: 'fillfactor', label: gettext('Fill factor'), type: 'int',
mode: ['create', 'edit'], min: 10, max: 100,
- disabled: 'inSchema',group: gettext('Advanced')
+ disabled: 'inSchema',group: gettext('Advanced'),
},{
id: 'relhasoids', label: gettext('Has OIDs?'), cell: 'switch',
type: 'switch', mode: ['properties', 'create', 'edit'],
- disabled: 'inSchema', group: gettext('Advanced')
+ disabled: 'inSchema', group: gettext('Advanced'),
},{
id: 'relpersistence', label: gettext('Unlogged?'), cell: 'switch',
type: 'switch', mode: ['properties', 'create', 'edit'],
disabled: 'inSchemaWithModelCheck',
- group: gettext('Advanced')
+ group: gettext('Advanced'),
},{
id: 'conname', label: gettext('Primary key'), cell: 'string',
type: 'text', mode: ['properties'], group: gettext('Advanced'),
- disabled: 'inSchema'
+ disabled: 'inSchema',
},{
id: 'reltuples', label: gettext('Rows (estimated)'), cell: 'string',
type: 'text', mode: ['properties'], group: gettext('Advanced'),
- disabled: 'inSchema'
+ disabled: 'inSchema',
},{
id: 'rows_cnt', label: gettext('Rows (counted)'), cell: 'string',
type: 'text', mode: ['properties'], group: gettext('Advanced'),
- disabled: 'inSchema'
+ disabled: 'inSchema',
},{
id: 'relhassubclass', label: gettext('Inherits tables?'), cell: 'switch',
type: 'switch', mode: ['properties'], group: gettext('Advanced'),
- disabled: 'inSchema'
+ disabled: 'inSchema',
},{
id: 'is_sys_table', label: gettext('System table?'), cell: 'switch',
type: 'switch', mode: ['properties'],
- disabled: 'inSchema'
+ disabled: 'inSchema',
},{
type: 'nested', control: 'fieldset', label: gettext('Like'),
group: gettext('Advanced'),
@@ -795,36 +798,36 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
id: 'like_relation', label: gettext('Relation'),
type: 'text', mode: ['create', 'edit'], deps: ['typname'],
control: 'node-ajax-options', url: 'get_relations',
- disabled: 'isLikeDisable', group: gettext('Like')
+ disabled: 'isLikeDisable', group: gettext('Like'),
},{
id: 'like_default_value', label: gettext('With default values?'),
type: 'switch', mode: ['create', 'edit'], deps: ['typname'],
- disabled: 'isLikeDisable', group: gettext('Like')
+ disabled: 'isLikeDisable', group: gettext('Like'),
},{
id: 'like_constraints', label: gettext('With constraints?'),
type: 'switch', mode: ['create', 'edit'], deps: ['typname'],
- disabled: 'isLikeDisable', group: gettext('Like')
+ disabled: 'isLikeDisable', group: gettext('Like'),
},{
id: 'like_indexes', label: gettext('With indexes?'),
type: 'switch', mode: ['create', 'edit'], deps: ['typname'],
- disabled: 'isLikeDisable', group: gettext('Like')
+ disabled: 'isLikeDisable', group: gettext('Like'),
},{
id: 'like_storage', label: gettext('With storage?'),
type: 'switch', mode: ['create', 'edit'], deps: ['typname'],
- disabled: 'isLikeDisable', group: gettext('Like')
+ disabled: 'isLikeDisable', group: gettext('Like'),
},{
id: 'like_comments', label: gettext('With comments?'),
type: 'switch', mode: ['create', 'edit'], deps: ['typname'],
- disabled: 'isLikeDisable', group: gettext('Like')
- }]
+ disabled: 'isLikeDisable', group: gettext('Like'),
+ }],
},{
id: 'partition_type', label:gettext('Partition Type'),
editable: false, type: 'select2', select2: {allowClear: false},
group: 'partition', deps: ['is_partitioned'],
options:[{
- label: gettext('Range'), value: 'range'
+ label: gettext('Range'), value: 'range',
},{
- label: gettext('List'), value: 'list'
+ label: gettext('List'), value: 'list',
}],
mode:['create'],
visible: function(m) {
@@ -839,7 +842,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
if (!m.isNew() || !m.get('is_partitioned'))
return true;
return false;
- }
+ },
},{
id: 'partition_keys', label:gettext('Partition Keys'),
model: Backform.PartitionKeyModel,
@@ -878,12 +881,10 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
if (m.get('partition_keys') && m.get('partition_keys').models.length > 0) {
setTimeout(function () {
var coll = m.get('partition_keys');
- coll.remove(coll.filter(function(model) {
- return true;
- }));
+ coll.remove(coll.filter(function() { return true; }));
}, 10);
}
- }
+ },
},{
id: 'partition_scheme', label: gettext('Partition Scheme'),
type: 'note', group: 'partition', mode: ['edit'],
@@ -899,7 +900,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
if (!m.isNew()) {
this.text = m.get('partition_scheme');
}
- }
+ },
},{
id: 'partitions', label:gettext('Partitions'),
model: Backform.PartitionsModel,
@@ -918,14 +919,14 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
var self = this;
if (!this.model.isNew()) {
var node = this.field.get('schema_node'),
- node_info = this.field.get('node_info');
+ node_info = this.field.get('node_info');
// Make ajax call to get the tables to be attached
$.ajax({
url: node.generate_url.apply(
node, [
null, 'get_attach_tables', this.field.get('node_data'),
- true, node_info
+ true, node_info,
]),
type: 'GET',
@@ -935,18 +936,18 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
self.model.table_options = res.data;
}
else {
- alertify.alert(
+ Alertify.alert(
gettext('Error fetching tables to be attached'), res.data.result
);
}
},
error: function(e) {
var errmsg = $.parseJSON(e.responseText);
- alertify.alert(gettext('Error fetching tables to be attached'), errmsg.errormsg);
- }
+ Alertify.alert(gettext('Error fetching tables to be attached'), errmsg.errormsg);
+ },
});
}
- }
+ },
}
),
canAdd: function(m) {
@@ -963,15 +964,16 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
return false;
},
disabled: function(m) {
- if (m.isNew() && m.get('partitions') && m.get('partitions').models.length > 0) {
+ if (
+ m.isNew() && m.get('partitions') &&
+ m.get('partitions').models.length > 0
+ ) {
setTimeout(function () {
var coll = m.get('partitions');
- coll.remove(coll.filter(function(model) {
- return true;
- }));
+ coll.remove(coll.filter(function() { return true; }));
}, 10);
}
- }
+ },
},{
id: 'partition_note', label: gettext('Partition'),
type: 'note', group: 'partition',
@@ -986,41 +988,39 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
return true;
return false;
- }
+ },
},{
// Here - we will create tab control for storage parameters
// (auto vacuum).
type: 'nested', control: 'tab', group: gettext('Parameter'),
mode: ['edit', 'create'], deps: ['is_partitioned'],
- schema: Backform.VacuumSettingsSchema
+ schema: Backform.VacuumSettingsSchema,
},{
id: 'relacl_str', label: gettext('Privileges'), disabled: 'inSchema',
- type: 'text', mode: ['properties'], group: gettext('Security')
+ type: 'text', mode: ['properties'], group: gettext('Security'),
}, pgBrowser.SecurityGroupSchema,{
id: 'relacl', label: gettext('Privileges'), type: 'collection',
group: 'security', control: 'unique-col-collection',
model: pgBrowser.Node.PrivilegeRoleModel.extend({
- privileges: ['a','r','w','d','D','x','t']}),
+ privileges: ['a','r','w','d','D','x','t']}),
mode: ['edit', 'create'], canAdd: true, canDelete: true,
- uniqueCol : ['grantee']
+ uniqueCol : ['grantee'],
},{
id: 'seclabels', label: gettext('Security labels'), canEdit: false,
model: pgBrowser.SecLabelModel, editable: false, canAdd: true,
type: 'collection', min_version: 90100, mode: ['edit', 'create'],
- group: 'security', canDelete: true, control: 'unique-col-collection'
+ group: 'security', canDelete: true, control: 'unique-col-collection',
},{
id: 'vacuum_settings_str', label: gettext('Storage settings'),
- type: 'multiline', group: gettext('Advanced'), mode: ['properties']
+ type: 'multiline', group: gettext('Advanced'), mode: ['properties'],
}],
validate: function(keys) {
- var err = {},
- changedAttrs = this.changed,
- msg = undefined,
- name = this.get('name'),
- schema = this.get('schema'),
- relowner = this.get('relowner'),
- is_partitioned = this.get('is_partitioned'),
- partition_keys = this.get('partition_keys');
+ var msg,
+ name = this.get('name'),
+ schema = this.get('schema'),
+ relowner = this.get('relowner'),
+ is_partitioned = this.get('is_partitioned'),
+ partition_keys = this.get('partition_keys');
// If nothing to validate or VacuumSetting keys then
// return from here
@@ -1085,7 +1085,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
// Disabled if it is partitioned table
if (m.get('is_partitioned')) {
setTimeout( function() {
- m.set('coll_inherits', []);
+ m.set('coll_inherits', []);
}, 10);
return true;
}
@@ -1117,8 +1117,8 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
if (!_.isUndefined(m.get('typname')) &&
!_.isNull(m.get('typname')) &&
m.get('typname') !== '') {
- enable_flag = false;
- }
+ enable_flag = false;
+ }
}
return enable_flag;
},
@@ -1137,7 +1137,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
// Disabled if it is partitioned table
if (m.get('is_partitioned')) {
setTimeout( function() {
- m.set('typname', undefined);
+ m.set('typname', undefined);
}, 10);
return true;
}
@@ -1184,20 +1184,19 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
},
fetch_columns_ajax: function(arg) {
var self = this,
- url = 'get_columns',
- m = self.model.top || self.model,
- old_columns = _.clone(m.get('columns')),
- data = undefined,
- node = this.field.get('schema_node'),
- node_info = this.field.get('node_info'),
- full_url = node.generate_url.apply(
+ url = 'get_columns',
+ m = self.model.top || self.model,
+ data = undefined,
+ node = this.field.get('schema_node'),
+ node_info = this.field.get('node_info'),
+ full_url = node.generate_url.apply(
node, [
null, url, this.field.get('node_data'),
- this.field.get('url_with_id') || false, node_info
+ this.field.get('url_with_id') || false, node_info,
]
),
- cache_level = this.field.get('cache_level') || node.type,
- cache_node = this.field.get('cache_node');
+ cache_level = this.field.get('cache_level') || node.type,
+ cache_node = this.field.get('cache_node');
cache_node = (cache_node && pgBrowser.Nodes['cache_node']) || node;
@@ -1212,40 +1211,40 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
},
error: function() {
m.trigger('pgadmin:view:fetch:error', m, self.field);
- }
+ },
});
m.trigger('pgadmin:view:fetched', m, self.field);
data = (data && data.data) || [];
return data;
- }
+ },
}),
canCreate: function(itemData, item, data) {
//If check is false then , we will allow create menu
- if (data && data.check == false)
- return true;
+ if (data && data.check == false)
+ return true;
- var t = pgBrowser.tree, i = item, d = itemData;
+ var t = pgBrowser.tree, i = item, d = itemData;
// To iterate over tree to check parent node
- while (i) {
+ while (i) {
// If it is schema then allow user to create table
- if (_.indexOf(['schema'], d._type) > -1)
- return true;
+ if (_.indexOf(['schema'], d._type) > -1)
+ return true;
- if ('coll-table' == d._type) {
+ if ('coll-table' == d._type) {
//Check if we are not child of catalog
- var prev_i = t.hasParent(i) ? t.parent(i) : null;
- var prev_d = prev_i ? t.itemData(prev_i) : null;
- if( prev_d._type == 'catalog') {
- return false;
- } else {
- return true;
- }
+ var prev_i = t.hasParent(i) ? t.parent(i) : null;
+ var prev_d = prev_i ? t.itemData(prev_i) : null;
+ if( prev_d._type == 'catalog') {
+ return false;
+ } else {
+ return true;
}
- i = t.hasParent(i) ? t.parent(i) : null;
- d = i ? t.itemData(i) : null;
}
+ i = t.hasParent(i) ? t.parent(i) : null;
+ d = i ? t.itemData(i) : null;
+ }
// by default we do not want to allow create menu
- return true;
+ return true;
},
// Check to whether table has disable trigger(s)
canCreate_with_trigger_enable: function(itemData, item, data) {
@@ -1268,7 +1267,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
return false;
}
}
- }
+ },
});
}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js
index 0ad89576..3af61754 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js
@@ -1,7 +1,7 @@
define('pgadmin.node.rule', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
- 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'codemirror'
-], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, CodeMirror) {
+ 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform',
+], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform) {
/**
Create and add a rule collection into nodes
@@ -11,13 +11,13 @@ define('pgadmin.node.rule', [
display under under properties.
*/
if (!pgBrowser.Nodes['coll-rule']) {
- var rules = pgAdmin.Browser.Nodes['coll-rule'] =
+ pgAdmin.Browser.Nodes['coll-rule'] =
pgAdmin.Browser.Collection.extend({
node: 'rule',
label: gettext('Rules'),
type: 'coll-rule',
getTreeNodeHierarchy: pgBrowser.tableChildTreeNodeHierarchy,
- columns: ["name", "owner", "comment"]
+ columns: ['name', 'owner', 'comment'],
});
}
@@ -65,7 +65,7 @@ define('pgadmin.node.rule', [
/* Avoid mulitple registration of menus */
if (this.initialized)
- return;
+ return;
this.initialized = true;
@@ -81,32 +81,32 @@ define('pgadmin.node.rule', [
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 1, label: gettext('Rule...'),
icon: 'wcTabIcon icon-rule', data: {action: 'create', check: true},
- enable: 'canCreate'
+ enable: 'canCreate',
},{
name: 'create_rule_onView', node: 'view', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 5, label: gettext('Rule...'),
icon: 'wcTabIcon icon-rule', data: {action: 'create', check: true},
- enable: 'canCreate'
+ enable: 'canCreate',
},{
name: 'create_rule', node: 'rule', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 1, label: gettext('Rule...'),
icon: 'wcTabIcon icon-rule', data: {action: 'create', check: true},
- enable: 'canCreate'
+ enable: 'canCreate',
},{
name: 'create_rule', node: 'table', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Rule...'),
icon: 'wcTabIcon icon-rule', data: {action: 'create', check: true},
- enable: 'canCreate'
+ enable: 'canCreate',
},{
name: 'create_rule', node: 'partition', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Rule...'),
icon: 'wcTabIcon icon-rule', data: {action: 'create', check: true},
- enable: 'canCreate'
- }
+ enable: 'canCreate',
+ },
]);
},
@@ -119,7 +119,7 @@ define('pgadmin.node.rule', [
id: 'name', label: gettext('Name'),
type: 'text', disabled: function(m) {
// disable name field it it is system rule
- if (m && m.get('name') == "_RETURN") {
+ if (m && m.get('name') == '_RETURN') {
return true;
}
if (m.isNew()) {
@@ -128,18 +128,18 @@ define('pgadmin.node.rule', [
return false;
}
return true;
- }
+ },
},
{
id: 'oid', label: gettext('OID'),
- type: 'text', disabled: true, mode: ['properties']
+ type: 'text', disabled: true, mode: ['properties'],
},
{
id: 'schema', label:'',
type: 'text', visible: false, disabled: function(m) {
// It is used while generating sql
m.set('schema', m.node_info.schema.label);
- }
+ },
},
{
id: 'view', label:'',
@@ -147,47 +147,47 @@ define('pgadmin.node.rule', [
// It is used while generating sql
m.set('view', this.node_data.label);
- }
+ },
},
{
id: 'event', label: gettext('Event'), control: 'select2',
group: gettext('Definition'), type: 'text',
select2: {
width: '100%',
- allowClear: false
+ allowClear: false,
},
options:[
{label: 'Select', value: 'Select'},
{label: 'Insert', value: 'Insert'},
{label: 'Update', value: 'Update'},
- {label: 'Delete', value: 'Delete'}
- ]
+ {label: 'Delete', value: 'Delete'},
+ ],
},
{
id: 'do_instead', label: gettext('Do Instead'), group: gettext('Definition'),
- type: 'switch'
+ type: 'switch',
},
{
id: 'condition', label: gettext('Condition'),
type: 'text', group: gettext('Definition'),
- control: Backform.SqlFieldControl
+ control: Backform.SqlFieldControl,
},
{
id: 'statements', label: gettext('Commands'),
type: 'text', group: gettext('Definition'),
- control: Backform.SqlFieldControl
+ control: Backform.SqlFieldControl,
},
{
id: 'system_rule', label: gettext('System rule?'),
- type: 'switch', mode: ['properties']
+ type: 'switch', mode: ['properties'],
},
{
id: 'enabled', label: gettext('Enabled?'),
- type: 'switch', mode: ['properties']
+ type: 'switch', mode: ['properties'],
},
{
- id: 'comment', label: gettext('Comment'), cell: 'string', type: 'multiline'
- }
+ id: 'comment', label: gettext('Comment'), cell: 'string', type: 'multiline',
+ },
],
validate: function() {
@@ -208,7 +208,7 @@ define('pgadmin.node.rule', [
this.errorModel.unset('name');
}
return null;
- }
+ },
}),
// Show or hide create rule menu option on parent node
@@ -231,7 +231,6 @@ define('pgadmin.node.rule', [
//Check if we are not child of rule
var prev_i = t.hasParent(i) ? t.parent(i) : null,
- prev_d = prev_i ? t.itemData(prev_i) : null,
prev_j = t.hasParent(prev_i) ? t.parent(prev_i) : null,
prev_e = prev_j ? t.itemData(prev_j) : null,
prev_k = t.hasParent(prev_j) ? t.parent(prev_j) : null,
@@ -249,7 +248,6 @@ define('pgadmin.node.rule', [
*/
else if('view' == d._type || 'table' == d._type){
prev_i = t.hasParent(i) ? t.parent(i) : null;
- prev_d = prev_i ? t.itemData(prev_i) : null;
prev_j = t.hasParent(prev_i) ? t.parent(prev_i) : null;
prev_e = prev_j ? t.itemData(prev_j) : null;
if(prev_e._type == 'schema') {
@@ -265,9 +263,9 @@ define('pgadmin.node.rule', [
// By default we do not want to allow create menu
return true;
- }
+ },
- });
+ });
}
return pgBrowser.Nodes['coll-rule'];
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/partition.utils.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/partition.utils.js
index 542463fa..80610cfe 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/partition.utils.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/partition.utils.js
@@ -1,30 +1,30 @@
-define('pgadmin.node.table_partition_utils',
- ['sources/gettext', 'jquery', 'underscore', 'pgadmin.browser',
- 'backform','backgrid', 'pgadmin.browser.collection'],
-function(gettext, $, _, pgBrowser, Backform, Backgrid) {
+define('pgadmin.node.table_partition_utils', [
+ 'sources/gettext', 'jquery', 'underscore', 'backbone', 'pgadmin.browser',
+ 'pgadmin.backform','pgadmin.backgrid', 'pgadmin.browser.collection',
+], function(gettext, $, _, Backbone, pgBrowser, Backform, Backgrid) {
Backgrid.PartitionRow = Backgrid.Row.extend({
- modelDuplicateColor: "lightYellow",
+ modelDuplicateColor: 'lightYellow',
- modelUniqueColor: "#fff",
+ modelUniqueColor: '#fff',
initialize: function () {
Backgrid.Row.prototype.initialize.apply(this, arguments);
var self = this;
- self.model.on("change:is_attach", function() {
+ self.model.on('change:is_attach', function() {
setTimeout(function() {
self.columns.each(function(col) {
if (col.get('name') == 'partition_name') {
var idx = self.columns.indexOf(col),
- cf = col.get("cellFunction"),
+ cf = col.get('cellFunction'),
cell = new (cf.apply(col, [self.model]))({
column: col,
- model: self.model
+ model: self.model,
}),
- oldCell = self.cells[idx];
- oldCell.remove();
- self.cells[idx] = cell;
- self.render();
+ oldCell = self.cells[idx];
+ oldCell.remove();
+ self.cells[idx] = cell;
+ self.render();
}
});
}, 10);
@@ -33,16 +33,16 @@ function(gettext, $, _, pgBrowser, Backform, Backgrid) {
self.listenTo(self.model, 'pgadmin-session:model:unique', self.modelUnique);
},
modelDuplicate: function() {
- $(this.el).removeClass("new");
+ $(this.el).removeClass('new');
this.el.style.backgroundColor = this.modelDuplicateColor;
},
modelUnique: function() {
this.el.style.backgroundColor = this.modelUniqueColor;
- }
+ },
});
var getPartitionCell = function(model) {
- var is_attach = model.get("is_attach");
+ var is_attach = model.get('is_attach');
if (is_attach) {
var options = [];
model.set({'partition_name': undefined}, {silent:true});
@@ -57,147 +57,148 @@ function(gettext, $, _, pgBrowser, Backform, Backgrid) {
};
Backform.PartitionKeyModel = pgBrowser.Node.Model.extend({
- defaults: {
- key_type: 'column',
- pt_column: undefined,
- expression: undefined
- },
- keys:['pt_column'],
- schema: [{
- id: 'key_type', label: gettext('Key type'), type:'select2', editable: true,
- cell:'select2', cellHeaderClasses: 'width_percent_25',
- select2: {allowClear: false},
- options:[{
- label: gettext('Column'), value: 'column'
- },{
- label: gettext('Expression'), value: 'expression'
- }]
- },{
- id: 'pt_column', label: gettext('Column'), type:'text',
- cell: Backgrid.Extension.Select2DepCell.extend({
- keyPathAccessor: function(obj, path) {
- var res = obj;
- if(_.isArray(res)) {
- return _.map(res, function(o) { return o['pt_column']
- });
- }
- path = path.split('.');
- for (var i = 0; i < path.length; i++) {
- if (_.isNull(res)) return null;
- if (_.isEmpty(path[i])) continue;
- if (!_.isUndefined(res[path[i]])) res = res[path[i]];
- }
- return _.isObject(res) && !_.isArray(res) ? null : res;
- },
- initialize: function() {
+ defaults: {
+ key_type: 'column',
+ pt_column: undefined,
+ expression: undefined,
+ },
+ keys:['pt_column'],
+ schema: [{
+ id: 'key_type', label: gettext('Key type'), type:'select2', editable: true,
+ cell:'select2', cellHeaderClasses: 'width_percent_25',
+ select2: {allowClear: false},
+ options:[{
+ label: gettext('Column'), value: 'column',
+ },{
+ label: gettext('Expression'), value: 'expression',
+ }],
+ },{
+ id: 'pt_column', label: gettext('Column'), type:'text',
+ cell: Backgrid.Extension.Select2DepCell.extend({
+ keyPathAccessor: function(obj, path) {
+ var res = obj;
+ if(_.isArray(res)) {
+ return _.map(res, function(o) { return o['pt_column'];
+ });
+ }
+ path = path.split('.');
+ for (var i = 0; i < path.length; i++) {
+ if (_.isNull(res)) return null;
+ if (_.isEmpty(path[i])) continue;
+ if (!_.isUndefined(res[path[i]])) res = res[path[i]];
+ }
+ return _.isObject(res) && !_.isArray(res) ? null : res;
+ },
+ initialize: function() {
// Here we will decide if we need to call URL
// Or fetch the data from parent columns collection
- var self = this;
- if(this.model.handler) {
- Backgrid.Extension.Select2DepCell.prototype.initialize.apply(this, arguments);
+ var self = this;
+ if(this.model.handler) {
+ Backgrid.Extension.Select2DepCell.prototype.initialize.apply(this, arguments);
// Do not listen for any event(s) for existing constraint.
- if (_.isUndefined(self.model.get('oid'))) {
- var tableCols = self.model.top.get('columns');
- self.listenTo(tableCols, 'remove' , self.resetColOptions);
- self.listenTo(tableCols, 'change:name', self.resetColOptions);
- }
+ if (_.isUndefined(self.model.get('oid'))) {
+ var tableCols = self.model.top.get('columns');
+ self.listenTo(tableCols, 'remove' , self.resetColOptions);
+ self.listenTo(tableCols, 'change:name', self.resetColOptions);
+ }
- self.custom_options();
- }
- },
- resetColOptions: function(m) {
- var self = this;
+ self.custom_options();
+ }
+ },
+ resetColOptions: function() {
+ var self = this;
- setTimeout(function () {
- self.custom_options();
- self.render.apply(self);
- }, 50);
- },
- custom_options: function() {
+ setTimeout(function () {
+ self.custom_options();
+ self.render.apply(self);
+ }, 50);
+ },
+ custom_options: function() {
// We will add all the columns entered by user in table model
- var columns = this.model.top.get('columns'),
- typename = this.model.top.get('typname'),
- of_types_tables = this.model.top.of_types_tables,
- added_columns_from_tables = [];
+ var columns = this.model.top.get('columns'),
+ typename = this.model.top.get('typname'),
+ of_types_tables = this.model.top.of_types_tables,
+ added_columns_from_tables = [];
- if (columns.length > 0) {
- _.each(columns.models, function(m) {
- var col = m.get('name');
- if(!_.isUndefined(col) && !_.isNull(col)) {
- added_columns_from_tables.push(
+ if (columns.length > 0) {
+ _.each(columns.models, function(m) {
+ var col = m.get('name');
+ if(!_.isUndefined(col) && !_.isNull(col)) {
+ added_columns_from_tables.push(
{label: col, value: col, image:'icon-column'}
);
- }
- });
- } else if (!_.isUndefined(typename) && !_.isNull(typename)
+ }
+ });
+ } else if (!_.isUndefined(typename) && !_.isNull(typename)
&& !_.isUndefined(of_types_tables) && of_types_tables.length > 0) {
// Iterate through all the of_type tables
- _.each(of_types_tables, function(type) {
- if (type.label == typename) {
+ _.each(of_types_tables, function(type) {
+ if (type.label == typename) {
// Iterate all the columns of selected "OF TYPE".
- _.each(type.oftype_columns, function(col) {
- added_columns_from_tables.push(
+ _.each(type.oftype_columns, function(col) {
+ added_columns_from_tables.push(
{label: col.name, value: col.name, image:'icon-column'}
);
- });
- }
- });
- }
+ });
+ }
+ });
+ }
// Set the values in to options so that user can select
- this.column.set('options', added_columns_from_tables);
- },
- remove: function() {
- if(this.model.handler) {
- var self = this,
- tableCols = self.model.top.get('columns');
- self.stopListening(tableCols, 'remove' , self.resetColOptions);
- self.stopListening(tableCols, 'change:name' , self.resetColOptions);
- Backgrid.Extension.Select2DepCell.prototype.remove.apply(this, arguments);
- }
- }
- }),
- deps: ['key_type'],
- cellHeaderClasses: 'width_percent_30',
- transform : function(data){
- var res = [];
- if (data && _.isArray(data)) {
- _.each(data, function(d) {
- res.push({label: d.label, value: d.label, image:'icon-column'});
- })
- }
- return res;
- },
- select2:{allowClear:false},
- editable: function(m) {
- if (m.get('key_type') == 'expression') {
- setTimeout( function() {
- m.set('pt_column', undefined);
- }, 10);
- return false;
- }
- return true;
- }
- },{
- id: 'expression', label: gettext('Expression'), type:'text',
- cell:Backgrid.Extension.StringDepCell,
- cellHeaderClasses: 'width_percent_45',
- deps: ['key_type'],
- editable: function(m) {
- if (m.get('key_type') == 'column') {
- setTimeout( function() {
- m.set('expression', undefined);
- }, 10);
- return false;
- }
- return true;
- }
- }
+ this.column.set('options', added_columns_from_tables);
+ },
+ remove: function() {
+ if(this.model.handler) {
+ var self = this,
+ tableCols = self.model.top.get('columns');
+ self.stopListening(tableCols, 'remove' , self.resetColOptions);
+ self.stopListening(tableCols, 'change:name' , self.resetColOptions);
+ Backgrid.Extension.Select2DepCell.prototype.remove.apply(this, arguments);
+ }
+ },
+ }),
+ deps: ['key_type'],
+ cellHeaderClasses: 'width_percent_30',
+ transform : function(data){
+ var res = [];
+ if (data && _.isArray(data)) {
+ _.each(data, function(d) {
+ res.push({label: d.label, value: d.label, image:'icon-column'});
+ });
+ }
+ return res;
+ },
+ select2:{allowClear:false},
+ editable: function(m) {
+ if (m.get('key_type') == 'expression') {
+ setTimeout( function() {
+ m.set('pt_column', undefined);
+ }, 10);
+ return false;
+ }
+ return true;
+ },
+ },{
+ id: 'expression', label: gettext('Expression'), type:'text',
+ cell:Backgrid.Extension.StringDepCell,
+ cellHeaderClasses: 'width_percent_45',
+ deps: ['key_type'],
+ editable: function(m) {
+ if (m.get('key_type') == 'column') {
+ setTimeout( function() {
+ m.set('expression', undefined);
+ }, 10);
+ return false;
+ }
+ return true;
+ },
+ },
],
- validate: function(keys) {
+ validate: function() {
var col_type = this.get('key_type'),
- pt_column = this.get('pt_column'),
- expression = this.get('expression');
+ pt_column = this.get('pt_column'),
+ expression = this.get('expression'),
+ msg;
// Have to clear existing validation before initiating current state
// validation only
@@ -205,27 +206,27 @@ function(gettext, $, _, pgBrowser, Backform, Backgrid) {
if (_.isUndefined(col_type) || _.isNull(col_type) ||
String(col_type).replace(/^\s+|\s+$/g, '') == '') {
- var msg = gettext('Partition key type cannot be empty.');
+ msg = gettext('Partition key type cannot be empty.');
this.errorModel.set('key_type', msg);
return msg;
}
else if (col_type == 'column' &&
_.isUndefined(pt_column) || _.isNull(pt_column) ||
String(pt_column).replace(/^\s+|\s+$/g, '') == '') {
- var msg = gettext('Partition key column cannot be empty.');
+ msg = gettext('Partition key column cannot be empty.');
this.errorModel.set('pt_column', msg);
return msg;
}
else if (col_type == 'expression' &&
_.isUndefined(expression) || _.isNull(expression) ||
String(expression).replace(/^\s+|\s+$/g, '') == '') {
- var msg = gettext('Partition key expression cannot be empty.');
+ msg = gettext('Partition key expression cannot be empty.');
this.errorModel.set('expression', msg);
return msg;
}
return null;
- }
+ },
});
Backform.PartitionsModel = pgBrowser.Node.Model.extend({
@@ -235,11 +236,11 @@ function(gettext, $, _, pgBrowser, Backform, Backgrid) {
partition_name: undefined,
values_from: undefined,
values_to: undefined,
- values_in: undefined
+ values_in: undefined,
},
keys:['partition_name'],
schema: [{
- id: 'oid', label: gettext('OID'), type: 'text'
+ id: 'oid', label: gettext('OID'), type: 'text',
},{
id: 'is_attach', label:gettext('Operation'), cell: 'switch',
type: 'switch', options: { 'onText': gettext('Attach'), 'offText': gettext('Create')},
@@ -248,7 +249,7 @@ function(gettext, $, _, pgBrowser, Backform, Backgrid) {
if (m instanceof Backbone.Model && m.isNew() && !m.top.isNew())
return true;
return false;
- }
+ },
},{
id: 'partition_name', label: gettext('Name'), type: 'text', cell:'string',
cellHeaderClasses: 'width_percent_25',
@@ -256,19 +257,19 @@ function(gettext, $, _, pgBrowser, Backform, Backgrid) {
if (m instanceof Backbone.Model && m.isNew())
return true;
return false;
- }, cellFunction: getPartitionCell
+ }, cellFunction: getPartitionCell,
},{
id: 'values_from', label: gettext('From'), type:'text',
cell:Backgrid.Extension.StringDepCell,
cellHeaderClasses: 'width_percent_20',
editable: function(m) {
- if(m.handler && m.handler.top &&
+ if(m.handler && m.handler.top &&
m.handler.top.attributes &&
m.handler.top.attributes.partition_type == 'range' &&
m instanceof Backbone.Model && m.isNew())
return true;
- return false;
- }
+ return false;
+ },
},{
id: 'values_to', label: gettext('To'), type:'text',
cell:Backgrid.Extension.StringDepCell,
@@ -280,7 +281,7 @@ function(gettext, $, _, pgBrowser, Backform, Backgrid) {
m instanceof Backbone.Model && m.isNew())
return true;
return false;
- }
+ },
},{
id: 'values_in', label: gettext('In'), type:'text',
cell:Backgrid.Extension.StringDepCell,
@@ -292,13 +293,14 @@ function(gettext, $, _, pgBrowser, Backform, Backgrid) {
m instanceof Backbone.Model && m.isNew())
return true;
return false;
- }
+ },
}],
- validate: function(keys) {
+ validate: function() {
var partition_name = this.get('partition_name'),
- values_from = this.get('values_from'),
- values_to = this.get('values_to'),
- values_in = this.get('values_in');
+ values_from = this.get('values_from'),
+ values_to = this.get('values_to'),
+ values_in = this.get('values_in'),
+ msg;
// Have to clear existing validation before initiating current state
// validation only
@@ -306,34 +308,34 @@ function(gettext, $, _, pgBrowser, Backform, Backgrid) {
if (_.isUndefined(partition_name) || _.isNull(partition_name) ||
String(partition_name).replace(/^\s+|\s+$/g, '') == '') {
- var msg = gettext('Partition name cannot be empty.');
- this.errorModel.set('partition_name', msg);
- return msg;
+ msg = gettext('Partition name cannot be empty.');
+ this.errorModel.set('partition_name', msg);
+ return msg;
}
if (this.top.get('partition_type') == 'range') {
if (_.isUndefined(values_from) || _.isNull(values_from) ||
String(values_from).replace(/^\s+|\s+$/g, '') == '') {
- var msg = gettext('For range partition From field cannot be empty.');
+ msg = gettext('For range partition From field cannot be empty.');
this.errorModel.set('values_from', msg);
return msg;
} else if (_.isUndefined(values_to) || _.isNull(values_to) ||
String(values_to).replace(/^\s+|\s+$/g, '') == '') {
- var msg = gettext('For range partition To field cannot be empty.');
+ msg = gettext('For range partition To field cannot be empty.');
this.errorModel.set('values_to', msg);
return msg;
}
} else if (this.top.get('partition_type') == 'list') {
if (_.isUndefined(values_in) || _.isNull(values_in) ||
String(values_in).replace(/^\s+|\s+$/g, '') == '') {
- var msg = gettext('For list partition In field cannot be empty.');
+ msg = gettext('For list partition In field cannot be empty.');
this.errorModel.set('values_in', msg);
return msg;
}
}
return null;
- }
+ },
});
});
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
index 78ab8f3b..2eb7f59f 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
@@ -1,13 +1,15 @@
define('pgadmin.node.table', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
- 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs',
+ 'underscore.string', 'sources/pgadmin', 'pgadmin.browser',
+ 'pgadmin.alertifyjs', 'pgadmin.backform', 'pgadmin.backgrid',
'pgadmin.browser.collection', 'pgadmin.node.column',
- 'pgadmin.node.constraints', 'pgadmin.browser.table.partition.utils'
+ 'pgadmin.node.constraints', 'pgadmin.browser.table.partition.utils',
], function(
- gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
+ gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, Backform, Backgrid
+) {
if (!pgBrowser.Nodes['coll-table']) {
- var databases = pgBrowser.Nodes['coll-table'] =
+ pgBrowser.Nodes['coll-table'] =
pgBrowser.Collection.extend({
node: 'table',
label: gettext('Tables'),
@@ -15,10 +17,10 @@ define('pgadmin.node.table', [
columns: ['name', 'relowner', 'is_partitioned', 'description'],
hasStatistics: true,
statsPrettifyFields: ['Size', 'Indexes size', 'Table size',
- 'Toast table size', 'Tuple length',
- 'Dead tuple length', 'Free space']
+ 'Toast table size', 'Tuple length',
+ 'Dead tuple length', 'Free space'],
});
- };
+ }
if (!pgBrowser.Nodes['table']) {
pgBrowser.Nodes['table'] = pgBrowser.Node.extend({
@@ -30,8 +32,8 @@ define('pgadmin.node.table', [
hasDepends: true,
hasStatistics: true,
statsPrettifyFields: ['Size', 'Indexes size', 'Table size',
- 'Toast table size', 'Tuple length',
- 'Dead tuple length', 'Free space'],
+ 'Toast table size', 'Tuple length',
+ 'Dead tuple length', 'Free space'],
sqlAlterHelp: 'sql-altertable.html',
sqlCreateHelp: 'sql-createtable.html',
dialogHelp: url_for('help.static', {'filename': 'table_dialog.html'}),
@@ -42,7 +44,7 @@ define('pgadmin.node.table', [
Init: function() {
/* Avoid multiple registration of menus */
if (this.initialized)
- return;
+ return;
this.initialized = true;
@@ -51,51 +53,51 @@ define('pgadmin.node.table', [
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 1, label: gettext('Table...'),
icon: 'wcTabIcon icon-table', data: {action: 'create', check: true},
- enable: 'canCreate'
+ enable: 'canCreate',
},{
name: 'create_table', node: 'table', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 1, label: gettext('Table...'),
icon: 'wcTabIcon icon-table', data: {action: 'create', check: true},
- enable: 'canCreate'
+ enable: 'canCreate',
},{
name: 'create_table__on_schema', node: 'schema', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Table...'),
icon: 'wcTabIcon icon-table', data: {action: 'create', check: false},
- enable: 'canCreate'
+ enable: 'canCreate',
},{
name: 'truncate_table', node: 'table', module: this,
applies: ['object', 'context'], callback: 'truncate_table',
category: 'Truncate', priority: 3, label: gettext('Truncate'),
- icon: 'fa fa-eraser', enable : 'canCreate'
+ icon: 'fa fa-eraser', enable : 'canCreate',
},{
name: 'truncate_table_cascade', node: 'table', module: this,
applies: ['object', 'context'], callback: 'truncate_table_cascade',
category: 'Truncate', priority: 3, label: gettext('Truncate Cascade'),
- icon: 'fa fa-eraser', enable : 'canCreate'
+ icon: 'fa fa-eraser', enable : 'canCreate',
},{
// To enable/disable all triggers for the table
name: 'enable_all_triggers', node: 'table', module: this,
applies: ['object', 'context'], callback: 'enable_triggers_on_table',
category: 'Trigger(s)', priority: 4, label: gettext('Enable All'),
- icon: 'fa fa-check', enable : 'canCreate_with_trigger_enable'
+ icon: 'fa fa-check', enable : 'canCreate_with_trigger_enable',
},{
name: 'disable_all_triggers', node: 'table', module: this,
applies: ['object', 'context'], callback: 'disable_triggers_on_table',
category: 'Trigger(s)', priority: 4, label: gettext('Disable All'),
- icon: 'fa fa-times', enable : 'canCreate_with_trigger_disable'
+ icon: 'fa fa-times', enable : 'canCreate_with_trigger_disable',
},{
name: 'reset_table_stats', node: 'table', module: this,
applies: ['object', 'context'], callback: 'reset_table_stats',
category: 'Reset', priority: 4, label: gettext('Reset Statistics'),
- icon: 'fa fa-bar-chart', enable : 'canCreate'
+ icon: 'fa fa-bar-chart', enable : 'canCreate',
},{
name: 'count_table_rows', node: 'table', module: this,
applies: ['object', 'context'], callback: 'count_table_rows',
category: 'Count', priority: 2, label: gettext('Count Rows'),
- enable: true
- }
+ enable: true,
+ },
]);
pgBrowser.Events.on(
'pgadmin:browser:node:table:updated', this.onTableUpdated, this
@@ -114,22 +116,22 @@ define('pgadmin.node.table', [
callbacks: {
/* Enable trigger(s) on table */
enable_triggers_on_table: function(args) {
- var params = {'enable': true };
- this.callbacks.set_triggers.apply(this, [args, params]);
+ var params = {'enable': true };
+ this.callbacks.set_triggers.apply(this, [args, params]);
},
/* Disable trigger(s) on table */
disable_triggers_on_table: function(args) {
- var params = {'enable': false };
- this.callbacks.set_triggers.apply(this, [args, params]);
+ var params = {'enable': false };
+ this.callbacks.set_triggers.apply(this, [args, params]);
},
set_triggers: function(args, params) {
// This function will send request to enable or
// disable triggers on table level
var input = args || {},
- obj = this,
- t = pgBrowser.tree,
- i = input.item || t.selected(),
- d = i && i.length == 1 ? t.itemData(i) : undefined;
+ obj = this,
+ t = pgBrowser.tree,
+ i = input.item || t.selected(),
+ d = i && i.length == 1 ? t.itemData(i) : undefined;
if (!d)
return false;
@@ -137,10 +139,10 @@ define('pgadmin.node.table', [
url: obj.generate_url(i, 'set_trigger' , d, true),
type:'PUT',
data: params,
- dataType: "json",
+ dataType: 'json',
success: function(res) {
if (res.success == 1) {
- alertify.success(res.info);
+ Alertify.success(res.info);
t.unload(i);
t.setInode(i);
t.deselect(i);
@@ -149,76 +151,80 @@ define('pgadmin.node.table', [
}, 10);
}
},
- error: function(xhr, status, error) {
+ error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
if (err.success == 0) {
- alertify.error(err.errormsg);
+ Alertify.error(err.errormsg);
}
- } catch (e) {}
+ } catch (e) {
+ console.warn(e.stack || e);
+ }
t.unload(i);
- }
+ },
});
},
/* Truncate table */
truncate_table: function(args) {
- var params = {'cascade': false };
- this.callbacks.truncate.apply(this, [args, params]);
+ var params = {'cascade': false };
+ this.callbacks.truncate.apply(this, [args, params]);
},
/* Truncate table with cascade */
truncate_table_cascade: function(args) {
- var params = {'cascade': true };
- this.callbacks.truncate.apply(this, [args, params]);
+ var params = {'cascade': true };
+ this.callbacks.truncate.apply(this, [args, params]);
},
truncate: function(args, params) {
var input = args || {},
- obj = this,
- t = pgBrowser.tree,
- i = input.item || t.selected(),
- d = i && i.length == 1 ? t.itemData(i) : undefined;
+ obj = this,
+ t = pgBrowser.tree,
+ i = input.item || t.selected(),
+ d = i && i.length == 1 ? t.itemData(i) : undefined;
if (!d)
return false;
- alertify.confirm(
+ Alertify.confirm(
gettext('Truncate Table'),
S(gettext('Are you sure you want to truncate table %s?')).sprintf(d.label).value(),
function (e) {
- if (e) {
- var data = d;
- $.ajax({
- url: obj.generate_url(i, 'truncate' , d, true),
- type:'PUT',
- data: params,
- dataType: "json",
- success: function(res) {
- if (res.success == 1) {
- alertify.success(res.info);
- t.removeIcon(i);
- data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
- t.addIcon(i, {icon: data.icon});
- t.unload(i);
- t.setInode(i);
- t.deselect(i);
- // Fetch updated data from server
- setTimeout(function() {
- t.select(i);
- }, 10);
- }
- },
- error: function(xhr, status, error) {
- try {
- var err = $.parseJSON(xhr.responseText);
- if (err.success == 0) {
- alertify.error(err.errormsg);
+ if (e) {
+ var data = d;
+ $.ajax({
+ url: obj.generate_url(i, 'truncate' , d, true),
+ type:'PUT',
+ data: params,
+ dataType: 'json',
+ success: function(res) {
+ if (res.success == 1) {
+ Alertify.success(res.info);
+ t.removeIcon(i);
+ data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
+ t.addIcon(i, {icon: data.icon});
+ t.unload(i);
+ t.setInode(i);
+ t.deselect(i);
+ // Fetch updated data from server
+ setTimeout(function() {
+ t.select(i);
+ }, 10);
}
- } catch (e) {}
- t.unload(i);
- }
- });
- }
- }, function() {}
- );
+ },
+ error: function(xhr) {
+ try {
+ var err = $.parseJSON(xhr.responseText);
+ if (err.success == 0) {
+ Alertify.error(err.errormsg);
+ }
+ } catch (e) {
+ console.warn(e.stack || e);
+ }
+ t.unload(i);
+ },
+ });
+ }
+ }, function() {}
+ );
},
reset_table_stats: function(args) {
var input = args || {},
@@ -230,7 +236,7 @@ define('pgadmin.node.table', [
if (!d)
return false;
- alertify.confirm(
+ Alertify.confirm(
gettext('Reset statistics'),
S(gettext('Are you sure you want to reset the statistics for table "%s"?')).sprintf(d._label).value(),
function (e) {
@@ -241,7 +247,7 @@ define('pgadmin.node.table', [
type:'DELETE',
success: function(res) {
if (res.success == 1) {
- alertify.success(res.info);
+ Alertify.success(res.info);
t.removeIcon(i);
data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
t.addIcon(i, {icon: data.icon});
@@ -254,15 +260,17 @@ define('pgadmin.node.table', [
}, 10);
}
},
- error: function(xhr, status, error) {
+ error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
if (err.success == 0) {
- alertify.error(err.errormsg);
+ Alertify.error(err.errormsg);
}
- } catch (e) {}
+ } catch (e) {
+ console.warn(e.stack || e);
+ }
t.unload(i);
- }
+ },
});
}
},
@@ -271,10 +279,10 @@ define('pgadmin.node.table', [
},
count_table_rows: function(args) {
var input = args || {},
- obj = this,
- t = pgBrowser.tree,
- i = input.item || t.selected(),
- d = i && i.length == 1 ? t.itemData(i) : undefined;
+ obj = this,
+ t = pgBrowser.tree,
+ i = input.item || t.selected(),
+ d = i && i.length == 1 ? t.itemData(i) : undefined;
if (!d)
return false;
@@ -283,26 +291,28 @@ define('pgadmin.node.table', [
url: obj.generate_url(i, 'count_rows' , d, true),
type:'GET',
success: function(res) {
- alertify.success(res.info);
- d.rows_cnt = res.data.total_rows;
- t.unload(i);
- t.setInode(i);
- t.deselect(i);
- setTimeout(function() {
- t.select(i);
- }, 10);
+ Alertify.success(res.info);
+ d.rows_cnt = res.data.total_rows;
+ t.unload(i);
+ t.setInode(i);
+ t.deselect(i);
+ setTimeout(function() {
+ t.select(i);
+ }, 10);
},
- error: function(xhr, status, error) {
+ error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
if (err.success == 0) {
- alertify.error(err.errormsg);
+ Alertify.error(err.errormsg);
}
- } catch (e) {}
+ } catch (e) {
+ console.warn(e.stack || e);
+ }
t.unload(i);
- }
+ },
});
- }
+ },
},
model: pgBrowser.Node.Model.extend({
defaults: {
@@ -334,18 +344,18 @@ define('pgadmin.node.table', [
primary_key: [],
partitions: [],
partition_type: 'range',
- is_partitioned: false
+ is_partitioned: false,
},
// Default values!
initialize: function(attrs, args) {
- var self = this;
-
if (_.size(attrs) === 0) {
- var userInfo = pgBrowser.serverInfo[args.node_info.server._id].user,
- schemaInfo = args.node_info.schema;
+ var userInfo = pgBrowser.serverInfo[
+ args.node_info.server._id
+ ].user,
+ schemaInfo = args.node_info.schema;
this.set({
- 'relowner': userInfo.name, 'schema': schemaInfo._label
+ 'relowner': userInfo.name, 'schema': schemaInfo._label,
}, {silent: true});
}
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
@@ -353,13 +363,13 @@ define('pgadmin.node.table', [
},
schema: [{
id: 'name', label: gettext('Name'), type: 'text',
- mode: ['properties', 'create', 'edit'], disabled: 'inSchema'
+ mode: ['properties', 'create', 'edit'], disabled: 'inSchema',
},{
- id: 'oid', label: gettext('OID'), type: 'text', mode: ['properties']
+ id: 'oid', label: gettext('OID'), type: 'text', mode: ['properties'],
},{
id: 'relowner', label: gettext('Owner'), type: 'text', node: 'role',
mode: ['properties', 'create', 'edit'], select2: {allowClear: false},
- disabled: 'inSchema', control: 'node-list-by-name'
+ disabled: 'inSchema', control: 'node-list-by-name',
},{
id: 'schema', label: gettext('Schema'), type: 'text', node: 'schema',
control: 'node-list-by-name', mode: ['create', 'edit'],
@@ -370,15 +380,15 @@ define('pgadmin.node.table', [
return false;
}
return true;
- }, cache_node: 'database', cache_level: 'database'
+ }, cache_node: 'database', cache_level: 'database',
},{
id: 'spcname', label: gettext('Tablespace'), node: 'tablespace',
type: 'text', control: 'node-list-by-name', disabled: 'inSchema',
mode: ['properties', 'create', 'edit'],
filter: function(d) {
// If tablespace name is not "pg_global" then we need to exclude them
- return (!(d && d.label.match(/pg_global/)))
- }
+ return (!(d && d.label.match(/pg_global/)));
+ },
},{
id: 'partition', type: 'group', label: gettext('Partition'),
mode: ['edit', 'create'], min_version: 100000,
@@ -387,14 +397,14 @@ define('pgadmin.node.table', [
if (m.isNew() || m.get('is_partitioned'))
return true;
return false;
- }
+ },
},{
id: 'is_partitioned', label:gettext('Partitioned Table?'), cell: 'switch',
type: 'switch', mode: ['properties', 'create', 'edit'],
visible: function(m) {
if(!_.isUndefined(m.node_info) && !_.isUndefined(m.node_info.server)
&& !_.isUndefined(m.node_info.server.version) &&
- m.node_info.server.version >= 100000)
+ m.node_info.server.version >= 100000)
return true;
return false;
@@ -403,31 +413,31 @@ define('pgadmin.node.table', [
if (!m.isNew())
return true;
return false;
- }
+ },
},{
id: 'description', label: gettext('Comment'), type: 'multiline',
- mode: ['properties', 'create', 'edit'], disabled: 'inSchema'
+ mode: ['properties', 'create', 'edit'], disabled: 'inSchema',
},{
id: 'coll_inherits', label: gettext('Inherited from table(s)'),
url: 'get_inherits', type: 'array', group: gettext('Columns'),
disabled: 'checkInheritance', deps: ['typname', 'is_partitioned'],
mode: ['create', 'edit'],
select2: { multiple: true, allowClear: true,
- placeholder: gettext('Select to inherit from...')},
+ placeholder: gettext('Select to inherit from...')},
transform: function(data, cell) {
var control = cell || this,
m = control.model;
- m.inherited_tables_list = data;
- return data;
+ m.inherited_tables_list = data;
+ return data;
},
control: Backform.MultiSelectAjaxControl.extend({
// When changes we need to add/clear columns collection
onChange: function() {
Backform.MultiSelectAjaxControl.prototype.onChange.apply(this, arguments);
var self = this,
- // current table list and previous table list
- cTbl_list = self.model.get('coll_inherits') || [],
- pTbl_list = self.model.previous('coll_inherits') || [];
+ // current table list and previous table list
+ cTbl_list = self.model.get('coll_inherits') || [],
+ pTbl_list = self.model.previous('coll_inherits') || [];
if (!_.isUndefined(cTbl_list)) {
var tbl_name = undefined,
@@ -463,13 +473,11 @@ define('pgadmin.node.table', [
// Create copy of old model if anything goes wrong at-least we have backup
// Then send AJAX request to fetch table specific columns
var self = this,
- url = 'get_columns',
m = self.model.top || self.model,
data = undefined,
- old_columns = _.clone(m.get('columns')),
column_collection = m.get('columns');
- var arg = {'tid': tid}
+ var arg = {'tid': tid};
data = self.model.fetch_columns_ajax.apply(self, [arg]);
// Update existing column collection
@@ -486,20 +494,20 @@ define('pgadmin.node.table', [
var tbl_oid = undefined;
// iterate over list to find table oid
_.each(this.model.inherited_tables_list, function(obj) {
- if(obj.label === tblname) {
- tbl_oid = obj.tid;
- }
+ if(obj.label === tblname) {
+ tbl_oid = obj.tid;
+ }
});
return tbl_oid;
- }
- })
+ },
+ }),
},{
id: 'coll_inherits', label: gettext('Inherited from table(s)'),
- type: 'text', group: gettext('Advanced'), mode: ['properties']
+ type: 'text', group: gettext('Advanced'), mode: ['properties'],
},{
id: 'inherited_tables_cnt', label: gettext('Inherited tables count'),
type: 'text', mode: ['properties'], group: gettext('Advanced'),
- disabled: 'inSchema'
+ disabled: 'inSchema',
},{
// Tab control for columns
id: 'columns', label: gettext('Columns'), type: 'collection',
@@ -538,20 +546,20 @@ define('pgadmin.node.table', [
initialize: function() {
Backform.UniqueColCollectionControl.prototype.initialize.apply(this, arguments);
var self = this,
- collection = self.model.get(self.field.get('name'));
+ collection = self.model.get(self.field.get('name'));
- collection.on("change:is_primary_key", function(m) {
+ collection.on('change:is_primary_key', function(m) {
var primary_key_coll = self.model.get('primary_key'),
- column_name = m.get('name'),
- primary_key;
+ column_name = m.get('name'),
+ primary_key, primary_key_column_coll;
if(m.get('is_primary_key')) {
- // Add column to primary key.
+ // Add column to primary key.
if (primary_key_coll.length < 1) {
primary_key = new (primary_key_coll.model)({}, {
top: self.model,
collection: primary_key_coll,
- handler: primary_key_coll
+ handler: primary_key_coll,
});
primary_key_coll.add(primary_key);
} else {
@@ -559,189 +567,185 @@ define('pgadmin.node.table', [
}
// Do not alter existing primary key columns.
if (_.isUndefined(primary_key.get('oid'))) {
- var primary_key_column_coll = primary_key.get('columns'),
- primary_key_column_exist = primary_key_column_coll.where({column:column_name});
+ primary_key_column_coll = primary_key.get('columns');
+ var primary_key_column_exist = primary_key_column_coll.where({column:column_name});
if (primary_key_column_exist.length == 0) {
- var primary_key_column = new (primary_key_column_coll.model)(
- {column: column_name}, { silent: true,
- top: self.model,
- collection: primary_key_coll,
- handler: primary_key_coll
- });
+ var primary_key_column = new (
+ primary_key_column_coll.model
+ )({column: column_name}, {
+ silent: true,
+ top: self.model,
+ collection: primary_key_coll,
+ handler: primary_key_coll,
+ });
primary_key_column_coll.add(primary_key_column);
}
- primary_key_column_coll.trigger('pgadmin:multicolumn:updated', primary_key_column_coll);
+ primary_key_column_coll.trigger(
+ 'pgadmin:multicolumn:updated', primary_key_column_coll
+ );
}
} else {
- // remove column from primary key.
+ // remove column from primary key.
if (primary_key_coll.length > 0) {
- var primary_key = primary_key_coll.first();
+ primary_key = primary_key_coll.first();
// Do not alter existing primary key columns.
if (!_.isUndefined(primary_key.get('oid'))) {
return;
}
- var primary_key_column_coll = primary_key.get('columns'),
- removedCols = primary_key_column_coll.where({column:column_name});
+ primary_key_column_coll = primary_key.get('columns');
+ var removedCols = primary_key_column_coll.where({column:column_name});
if (removedCols.length > 0) {
primary_key_column_coll.remove(removedCols);
_.each(removedCols, function(m) {
m.destroy();
- })
+ });
if (primary_key_column_coll.length == 0) {
- /* Ideally above line of code should be "primary_key_coll.reset()".
- * But our custom DataCollection (extended from Backbone collection in datamodel.js)
- * does not respond to reset event, it only supports add, remove, change events.
- * And hence no custom event listeners/validators get called for reset event.
- */
- primary_key_coll.remove(primary_key_coll.first());
+ /* Ideally above line of code should be "primary_key_coll.reset()".
+ * But our custom DataCollection (extended from Backbone collection in datamodel.js)
+ * does not respond to reset event, it only supports add, remove, change events.
+ * And hence no custom event listeners/validators get called for reset event.
+ */
+ primary_key_coll.remove(primary_key_coll.first());
}
}
primary_key_column_coll.trigger('pgadmin:multicolumn:updated', primary_key_column_coll);
}
}
- })
+ });
},
remove: function() {
var collection = this.model.get(this.field.get('name'));
if (collection) {
- collection.off("change:is_primary_key");
+ collection.off('change:is_primary_key');
}
Backform.UniqueColCollectionControl.prototype.remove.apply(this, arguments);
- }
+ },
}),
- allowMultipleEmptyRow: false
+ allowMultipleEmptyRow: false,
},{
// Here we will create tab control for constraints
type: 'nested', control: 'tab', group: gettext('Constraints'),
mode: ['edit', 'create'],
schema: [{
- id: 'primary_key', label: gettext('Primary key'),
- model: pgBrowser.Nodes['primary_key'].model,
- subnode: pgBrowser.Nodes['primary_key'].model,
- editable: false, type: 'collection',
- group: gettext('Primary Key'), mode: ['edit', 'create'],
- canEdit: true, canDelete: true, deps:['is_partitioned'],
- control: 'unique-col-collection',
- columns : ['name', 'columns'],
- canAdd: function(m) {
- if (m.get('is_partitioned')) {
- setTimeout(function() {
- var coll = m.get('primary_key');
- coll.remove(coll.filter(function(model) {
- return true;
- }));
- }, 10);
- return false;
- }
+ id: 'primary_key', label: gettext('Primary key'),
+ model: pgBrowser.Nodes['primary_key'].model,
+ subnode: pgBrowser.Nodes['primary_key'].model,
+ editable: false, type: 'collection',
+ group: gettext('Primary Key'), mode: ['edit', 'create'],
+ canEdit: true, canDelete: true, deps:['is_partitioned'],
+ control: 'unique-col-collection',
+ columns : ['name', 'columns'],
+ canAdd: function(m) {
+ if (m.get('is_partitioned')) {
+ setTimeout(function() {
+ var coll = m.get('primary_key');
+ coll.remove(coll.filter(function() { return true; }));
+ }, 10);
+ return false;
+ }
- return true;
- },
- canAddRow: function(m) {
- // User can only add one primary key
- var columns = m.get('columns');
+ return true;
+ },
+ canAddRow: function(m) {
+ // User can only add one primary key
+ var columns = m.get('columns');
- return (m.get('primary_key') &&
- m.get('primary_key').length < 1 &&
- _.some(columns.pluck('name')));
+ return (m.get('primary_key') &&
+ m.get('primary_key').length < 1 &&
+ _.some(columns.pluck('name')));
+ },
+ },{
+ id: 'foreign_key', label: gettext('Foreign key'),
+ model: pgBrowser.Nodes['foreign_key'].model,
+ subnode: pgBrowser.Nodes['foreign_key'].model,
+ editable: false, type: 'collection',
+ group: gettext('Foreign Key'), mode: ['edit', 'create'],
+ canEdit: true, canDelete: true, deps:['is_partitioned'],
+ control: 'unique-col-collection',
+ canAdd: function(m) {
+ if (m.get('is_partitioned')) {
+ setTimeout(function() {
+ var coll = m.get('foreign_key');
+ coll.remove(coll.filter(function() { return true; }));
+ }, 10);
+ return false;
}
- },{
- id: 'foreign_key', label: gettext('Foreign key'),
- model: pgBrowser.Nodes['foreign_key'].model,
- subnode: pgBrowser.Nodes['foreign_key'].model,
- editable: false, type: 'collection',
- group: gettext('Foreign Key'), mode: ['edit', 'create'],
- canEdit: true, canDelete: true, deps:['is_partitioned'],
- control: 'unique-col-collection',
- canAdd: function(m) {
- if (m.get('is_partitioned')) {
- setTimeout(function() {
- var coll = m.get('foreign_key');
- coll.remove(coll.filter(function(model) {
- return true;
- }));
- }, 10);
- return false;
- }
- return true;
- },
- columns : ['name', 'columns'],
- canAddRow: function(m) {
- // User can only add if there is at least one column with name.
- var columns = m.get('columns');
- return _.some(columns.pluck('name'));
+ return true;
+ },
+ columns : ['name', 'columns'],
+ canAddRow: function(m) {
+ // User can only add if there is at least one column with name.
+ var columns = m.get('columns');
+ return _.some(columns.pluck('name'));
+ },
+ },{
+ id: 'check_constraint', label: gettext('Check constraint'),
+ model: pgBrowser.Nodes['check_constraint'].model,
+ subnode: pgBrowser.Nodes['check_constraint'].model,
+ editable: false, type: 'collection',
+ group: gettext('Check'), mode: ['edit', 'create'],
+ canEdit: true, canDelete: true, deps:['is_partitioned'],
+ control: 'unique-col-collection',
+ canAdd: true,
+ columns : ['name', 'consrc'],
+ },{
+ id: 'unique_constraint', label: gettext('Unique Constraint'),
+ model: pgBrowser.Nodes['unique_constraint'].model,
+ subnode: pgBrowser.Nodes['unique_constraint'].model,
+ editable: false, type: 'collection',
+ group: gettext('Unique'), mode: ['edit', 'create'],
+ canEdit: true, canDelete: true, deps:['is_partitioned'],
+ control: 'unique-col-collection',
+ columns : ['name', 'columns'],
+ canAdd: function(m) {
+ if (m.get('is_partitioned')) {
+ setTimeout(function() {
+ var coll = m.get('unique_constraint');
+ coll.remove(coll.filter(function() { return true; }));
+ }, 10);
+ return false;
}
- },{
- id: 'check_constraint', label: gettext('Check constraint'),
- model: pgBrowser.Nodes['check_constraint'].model,
- subnode: pgBrowser.Nodes['check_constraint'].model,
- editable: false, type: 'collection',
- group: gettext('Check'), mode: ['edit', 'create'],
- canEdit: true, canDelete: true, deps:['is_partitioned'],
- control: 'unique-col-collection',
- canAdd: true,
- columns : ['name', 'consrc']
- },{
- id: 'unique_constraint', label: gettext('Unique Constraint'),
- model: pgBrowser.Nodes['unique_constraint'].model,
- subnode: pgBrowser.Nodes['unique_constraint'].model,
- editable: false, type: 'collection',
- group: gettext('Unique'), mode: ['edit', 'create'],
- canEdit: true, canDelete: true, deps:['is_partitioned'],
- control: 'unique-col-collection',
- columns : ['name', 'columns'],
- canAdd: function(m) {
- if (m.get('is_partitioned')) {
- setTimeout(function() {
- var coll = m.get('unique_constraint');
- coll.remove(coll.filter(function(model) {
- return true;
- }));
- }, 10);
- return false;
- }
- return true;
- },
- canAddRow: function(m) {
- // User can only add if there is at least one column with name.
- var columns = m.get('columns');
- return _.some(columns.pluck('name'));
+ return true;
+ },
+ canAddRow: function(m) {
+ // User can only add if there is at least one column with name.
+ var columns = m.get('columns');
+ return _.some(columns.pluck('name'));
+ },
+ },{
+ id: 'exclude_constraint', label: gettext('Exclude constraint'),
+ model: pgBrowser.Nodes['exclusion_constraint'].model,
+ subnode: pgBrowser.Nodes['exclusion_constraint'].model,
+ editable: false, type: 'collection',
+ group: gettext('Exclude'), mode: ['edit', 'create'],
+ canEdit: true, canDelete: true, deps:['is_partitioned'],
+ control: 'unique-col-collection',
+ columns : ['name', 'columns', 'constraint'],
+ canAdd: function(m) {
+ if (m.get('is_partitioned')) {
+ setTimeout(function() {
+ var coll = m.get('exclude_constraint');
+ coll.remove(coll.filter(function() { return true; }));
+ }, 10);
+ return false;
}
- },{
- id: 'exclude_constraint', label: gettext('Exclude constraint'),
- model: pgBrowser.Nodes['exclusion_constraint'].model,
- subnode: pgBrowser.Nodes['exclusion_constraint'].model,
- editable: false, type: 'collection',
- group: gettext('Exclude'), mode: ['edit', 'create'],
- canEdit: true, canDelete: true, deps:['is_partitioned'],
- control: 'unique-col-collection',
- columns : ['name', 'columns', 'constraint'],
- canAdd: function(m) {
- if (m.get('is_partitioned')) {
- setTimeout(function() {
- var coll = m.get('exclude_constraint');
- coll.remove(coll.filter(function(model) {
- return true;
- }));
- }, 10);
- return false;
- }
- return true;
- },
- canAddRow: function(m) {
- // User can only add if there is at least one column with name.
- var columns = m.get('columns');
- return _.some(columns.pluck('name'));
- }
- }]
+ return true;
+ },
+ canAddRow: function(m) {
+ // User can only add if there is at least one column with name.
+ var columns = m.get('columns');
+ return _.some(columns.pluck('name'));
+ },
+ }],
},{
id: 'typname', label: gettext('Of type'), type: 'text',
mode: ['properties', 'create', 'edit'],
@@ -749,108 +753,103 @@ define('pgadmin.node.table', [
deps: ['coll_inherits'], transform: function(data, cell) {
var control = cell || this,
m = control.model;
- m.of_types_tables = data;
- return data;
+ m.of_types_tables = data;
+ return data;
},
control: Backform.NodeAjaxOptionsControl.extend({
- // When of_types changes we need to clear columns collection
- onChange: function() {
- Backform.NodeAjaxOptionsControl.prototype.onChange.apply(this, arguments);
- var self = this,
- tbl_oid = undefined,
- tbl_name = self.model.get('typname'),
- data = undefined,
- arg = undefined,
- column_collection = self.model.get('columns');
-
- if (!_.isUndefined(tbl_name) && !_.isNull(tbl_name) &&
- tbl_name !== '' && column_collection.length !== 0) {
- var title = gettext('Remove column definitions?'),
- msg = gettext('Changing \'Of type\' will remove column definitions.');
-
- alertify.confirm(title, msg, function (e) {
+ // When of_types changes we need to clear columns collection
+ onChange: function() {
+ Backform.NodeAjaxOptionsControl.prototype.onChange.apply(this, arguments);
+ var self = this,
+ tbl_name = self.model.get('typname'),
+ data = undefined,
+ arg = undefined,
+ column_collection = self.model.get('columns');
+
+ if (!_.isUndefined(tbl_name) && !_.isNull(tbl_name) &&
+ tbl_name !== '' && column_collection.length !== 0) {
+ var title = gettext('Remove column definitions?'),
+ msg = gettext('Changing \'Of type\' will remove column definitions.');
+
+ Alertify.confirm(
+ title, msg, function () {
// User clicks Ok, lets clear columns collection
column_collection.remove(
- column_collection.filter(function(model) {
- return true;
- }
- )
+ column_collection.filter(function() { return true; })
);
},
function() {
setTimeout(function() {
self.model.set('typname', null);
- }, 10)
+ }, 10);
}
);
- } else if (!_.isUndefined(tbl_name) && tbl_name === '') {
- column_collection.remove(
- column_collection.filter(function(model) {
- return true;
- }
- )
+ } else if (!_.isUndefined(tbl_name) && tbl_name === '') {
+ column_collection.remove(
+ column_collection.filter(function() { return true; })
);
- }
+ }
- // Run Ajax now to fetch columns
- if (!_.isUndefined(tbl_name) && tbl_name !== '') {
- arg = { 'tname': tbl_name }
- data = self.model.fetch_columns_ajax.apply(self, [arg]);
- // Add into column collection
- column_collection.set(data, { merge:false,remove:false });
- }
+ // Run Ajax now to fetch columns
+ if (!_.isUndefined(tbl_name) && tbl_name !== '') {
+ arg = { 'tname': tbl_name };
+ data = self.model.fetch_columns_ajax.apply(self, [arg]);
+ // Add into column collection
+ column_collection.set(data, { merge:false,remove:false });
}
- })
+ },
+ }),
},{
id: 'fillfactor', label: gettext('Fill factor'), type: 'int',
mode: ['create', 'edit'], min: 10, max: 100,
- disabled: 'inSchema',group: gettext('Advanced')
+ disabled: 'inSchema',group: gettext('Advanced'),
},{
id: 'relhasoids', label: gettext('Has OIDs?'), cell: 'switch',
type: 'switch', mode: ['properties', 'create', 'edit'],
- disabled: 'inSchema', group: gettext('Advanced')
+ disabled: 'inSchema', group: gettext('Advanced'),
},{
id: 'relpersistence', label: gettext('Unlogged?'), cell: 'switch',
type: 'switch', mode: ['properties', 'create', 'edit'],
disabled: 'inSchemaWithModelCheck',
- group: gettext('Advanced')
+ group: gettext('Advanced'),
},{
id: 'conname', label: gettext('Primary key'), cell: 'string',
type: 'text', mode: ['properties'], group: gettext('Advanced'),
- disabled: 'inSchema'
+ disabled: 'inSchema',
},{
id: 'reltuples', label: gettext('Rows (estimated)'), cell: 'string',
type: 'text', mode: ['properties'], group: gettext('Advanced'),
- disabled: 'inSchema'
+ disabled: 'inSchema',
},{
id: 'rows_cnt', label: gettext('Rows (counted)'), cell: 'string',
type: 'text', mode: ['properties'], group: gettext('Advanced'),
disabled: 'inSchema', control: Backform.InputControl.extend({
formatter: {
- fromRaw: function (rawData, model) {
- var t = pgAdmin.Browser.tree,
+ fromRaw: function (rawData) {
+ var t = pgAdmin.Browser.tree,
i = t.selected(),
d = i && i.length == 1 ? t.itemData(i) : undefined;
- // Return the actual rows count if the selected node has already counted.
- if(d && d.rows_cnt && parseInt(d.rows_cnt, 10) > 0)
- return d.rows_cnt;
- else
- return rawData;
- },
- toRaw: function (formattedData, model) {
- return formattedData;
- }
- }
- })
+ // Return the actual rows count if the selected node
+ // has already counted.
+ if(d && d.rows_cnt && parseInt(d.rows_cnt, 10) > 0)
+ return d.rows_cnt;
+ else
+ return rawData;
+ },
+ toRaw: function (formattedData) {
+ return formattedData;
+ },
+ },
+ }),
},{
id: 'relhassubclass', label: gettext('Inherits tables?'), cell: 'switch',
type: 'switch', mode: ['properties'], group: gettext('Advanced'),
- disabled: 'inSchema'
+ disabled: 'inSchema',
},{
id: 'is_sys_table', label: gettext('System table?'), cell: 'switch',
type: 'switch', mode: ['properties'],
- disabled: 'inSchema'
+ disabled: 'inSchema',
},{
type: 'nested', control: 'fieldset', label: gettext('Like'),
group: gettext('Advanced'),
@@ -858,42 +857,42 @@ define('pgadmin.node.table', [
id: 'like_relation', label: gettext('Relation'),
type: 'text', mode: ['create', 'edit'], deps: ['typname'],
control: 'node-ajax-options', url: 'get_relations',
- disabled: 'isLikeDisable', group: gettext('Like')
+ disabled: 'isLikeDisable', group: gettext('Like'),
},{
id: 'like_default_value', label: gettext('With default values?'),
type: 'switch', mode: ['create', 'edit'], deps: ['typname'],
- disabled: 'isLikeDisable', group: gettext('Like')
+ disabled: 'isLikeDisable', group: gettext('Like'),
},{
id: 'like_constraints', label: gettext('With constraints?'),
type: 'switch', mode: ['create', 'edit'], deps: ['typname'],
- disabled: 'isLikeDisable', group: gettext('Like')
+ disabled: 'isLikeDisable', group: gettext('Like'),
},{
id: 'like_indexes', label: gettext('With indexes?'),
type: 'switch', mode: ['create', 'edit'], deps: ['typname'],
- disabled: 'isLikeDisable', group: gettext('Like')
+ disabled: 'isLikeDisable', group: gettext('Like'),
},{
id: 'like_storage', label: gettext('With storage?'),
type: 'switch', mode: ['create', 'edit'], deps: ['typname'],
- disabled: 'isLikeDisable', group: gettext('Like')
+ disabled: 'isLikeDisable', group: gettext('Like'),
},{
id: 'like_comments', label: gettext('With comments?'),
type: 'switch', mode: ['create', 'edit'], deps: ['typname'],
- disabled: 'isLikeDisable', group: gettext('Like')
- }]
+ disabled: 'isLikeDisable', group: gettext('Like'),
+ }],
},{
id: 'partition_type', label:gettext('Partition Type'),
editable: false, type: 'select2', select2: {allowClear: false},
group: 'partition', deps: ['is_partitioned'],
options:[{
- label: gettext('Range'), value: 'range'
+ label: gettext('Range'), value: 'range',
},{
- label: gettext('List'), value: 'list'
+ label: gettext('List'), value: 'list',
}],
mode:['create'],
visible: function(m) {
if(!_.isUndefined(m.node_info) && !_.isUndefined(m.node_info.server)
&& !_.isUndefined(m.node_info.server.version) &&
- m.node_info.server.version >= 100000)
+ m.node_info.server.version >= 100000)
return true;
return false;
@@ -902,7 +901,7 @@ define('pgadmin.node.table', [
if (!m.isNew() || !m.get('is_partitioned'))
return true;
return false;
- }
+ },
},{
id: 'partition_keys', label:gettext('Partition Keys'),
model: Backform.PartitionKeyModel,
@@ -919,17 +918,17 @@ define('pgadmin.node.table', [
},
canAddRow: function(m) {
var columns = m.get('columns'),
- typename = m.get('typname'),
- columns_exist= false;
+ typename = m.get('typname'),
+ columns_exist= false;
var max_row_count = 1000;
if (m.get('partition_type') && m.get('partition_type') == 'list')
max_row_count = 1;
- /* If columns are not specified by the user then it may be
- * possible that he/she selected 'OF TYPE', so we should check
- * for that as well.
- */
+ /* If columns are not specified by the user then it may be
+ * possible that he/she selected 'OF TYPE', so we should check
+ * for that as well.
+ */
if (columns.length <= 0 && !_.isUndefined(typename)
&& !_.isNull(typename) && m.of_types_tables.length > 0){
_.each(m.of_types_tables, function(data) {
@@ -942,14 +941,14 @@ define('pgadmin.node.table', [
}
return (m.get('partition_keys') &&
- m.get('partition_keys').length < max_row_count && columns_exist
+ m.get('partition_keys').length < max_row_count && columns_exist
);
},
visible: function(m) {
if(!_.isUndefined(m.node_info) && !_.isUndefined(m.node_info.server)
&& !_.isUndefined(m.node_info.server.version) &&
- m.node_info.server.version >= 100000)
+ m.node_info.server.version >= 100000)
return true;
return false;
@@ -958,19 +957,18 @@ define('pgadmin.node.table', [
if (m.get('partition_keys') && m.get('partition_keys').models.length > 0) {
setTimeout(function () {
var coll = m.get('partition_keys');
- coll.remove(coll.filter(function(model) {
- return true;
- }));
+ coll.remove(coll.filter(function() { return true; }));
+
}, 10);
}
- }
+ },
},{
id: 'partition_scheme', label: gettext('Partition Scheme'),
type: 'note', group: 'partition', mode: ['edit'],
visible: function(m) {
if(!_.isUndefined(m.node_info) && !_.isUndefined(m.node_info.server)
&& !_.isUndefined(m.node_info.server.version) &&
- m.node_info.server.version >= 100000)
+ m.node_info.server.version >= 100000)
return true;
return false;
@@ -979,7 +977,7 @@ define('pgadmin.node.table', [
if (!m.isNew()) {
this.text = m.get('partition_scheme');
}
- }
+ },
},{
id: 'partition_key_note', label: gettext('Partition Keys'),
type: 'note', group: 'partition', mode: ['create'],
@@ -993,17 +991,17 @@ define('pgadmin.node.table', [
'
',
gettext('Example'),
':',
- gettext("Let's say, we want to create a partition table based per year for the column 'saledate', having datatype 'date/timestamp', then we need to specify the expression as 'extract(YEAR from saledate)' as partition key."),
- '
'
+ gettext('Let\'s say, we want to create a partition table based per year for the column \'saledate\', having datatype \'date/timestamp\', then we need to specify the expression as \'extract(YEAR from saledate)\' as partition key.'),
+ '',
].join(''),
visible: function(m) {
if(!_.isUndefined(m.node_info) && !_.isUndefined(m.node_info.server)
&& !_.isUndefined(m.node_info.server.version) &&
- m.node_info.server.version >= 100000)
+ m.node_info.server.version >= 100000)
return true;
return false;
- }
+ },
}, {
id: 'partitions', label:gettext('Partitions'),
model: Backform.PartitionsModel,
@@ -1022,15 +1020,15 @@ define('pgadmin.node.table', [
var self = this;
if (!this.model.isNew()) {
var node = this.field.get('schema_node'),
- node_info = this.field.get('node_info');
+ node_info = this.field.get('node_info');
// Make ajax call to get the tables to be attached
$.ajax({
url: node.generate_url.apply(
- node, [
- null, 'get_attach_tables', this.field.get('node_data'),
- true, node_info
- ]),
+ node, [
+ null, 'get_attach_tables', this.field.get('node_data'),
+ true, node_info,
+ ]),
type: 'GET',
async: false,
@@ -1039,18 +1037,18 @@ define('pgadmin.node.table', [
self.model.table_options = res.data;
}
else {
- alertify.alert(
+ Alertify.alert(
gettext('Error fetching tables to be attached'), res.data.result
);
}
},
error: function(e) {
var errmsg = $.parseJSON(e.responseText);
- alertify.alert(gettext('Error fetching tables to be attached'), errmsg.errormsg);
- }
+ Alertify.alert(gettext('Error fetching tables to be attached'), errmsg.errormsg);
+ },
});
}
- }
+ },
}
),
canAdd: function(m) {
@@ -1061,7 +1059,7 @@ define('pgadmin.node.table', [
visible: function(m) {
if(!_.isUndefined(m.node_info) && !_.isUndefined(m.node_info.server)
&& !_.isUndefined(m.node_info.server.version) &&
- m.node_info.server.version >= 100000)
+ m.node_info.server.version >= 100000)
return true;
return false;
@@ -1070,12 +1068,10 @@ define('pgadmin.node.table', [
if (m.isNew() && m.get('partitions') && m.get('partitions').models.length > 0) {
setTimeout(function () {
var coll = m.get('partitions');
- coll.remove(coll.filter(function(model) {
- return true;
- }));
+ coll.remove(coll.filter(function() { return true; }));
}, 10);
}
- }
+ },
},{
id: 'partition_note', label: gettext('Partitions'),
type: 'note', group: 'partition',
@@ -1090,57 +1086,55 @@ define('pgadmin.node.table', [
' ',
gettext('Example'),
':
',
- gettext("From/To: Enabled for range partition. Consider partitioned table with multiple keys of type Integer, then values should be specified like '100','200'."),
+ gettext('From/To: Enabled for range partition. Consider partitioned table with multiple keys of type Integer, then values should be specified like \'100\',\'200\'.'),
'
',
gettext('In: Enabled for list partition. Values must be comma(,) separated and quoted with single quote.'),
- '
'
+ '',
].join(''),
visible: function(m) {
if(!_.isUndefined(m.node_info) && !_.isUndefined(m.node_info.server)
&& !_.isUndefined(m.node_info.server.version) &&
- m.node_info.server.version >= 100000)
+ m.node_info.server.version >= 100000)
return true;
return false;
- }
+ },
},{
// Here - we will create tab control for storage parameters
// (auto vacuum).
type: 'nested', control: 'tab', group: gettext('Parameter'),
mode: ['edit', 'create'], deps: ['is_partitioned'],
- schema: Backform.VacuumSettingsSchema
+ schema: Backform.VacuumSettingsSchema,
},{
id: 'relacl_str', label: gettext('Privileges'), disabled: 'inSchema',
- type: 'text', mode: ['properties'], group: gettext('Security')
+ type: 'text', mode: ['properties'], group: gettext('Security'),
}, pgBrowser.SecurityGroupSchema,{
id: 'relacl', label: gettext('Privileges'), type: 'collection',
group: 'security', control: 'unique-col-collection',
model: pgBrowser.Node.PrivilegeRoleModel.extend({
- privileges: ['a','r','w','d','D','x','t']}),
+ privileges: ['a','r','w','d','D','x','t']}),
mode: ['edit', 'create'], canAdd: true, canDelete: true,
- uniqueCol : ['grantee']
+ uniqueCol : ['grantee'],
},{
id: 'seclabels', label: gettext('Security labels'), canEdit: false,
model: pgBrowser.SecLabelModel, editable: false, canAdd: true,
type: 'collection', min_version: 90100, mode: ['edit', 'create'],
- group: 'security', canDelete: true, control: 'unique-col-collection'
+ group: 'security', canDelete: true, control: 'unique-col-collection',
},{
id: 'vacuum_settings_str', label: gettext('Storage settings'),
- type: 'multiline', group: gettext('Advanced'), mode: ['properties']
+ type: 'multiline', group: gettext('Advanced'), mode: ['properties'],
}],
- validate: function(keys) {
- var err = {},
- changedAttrs = this.changed,
- msg = undefined,
- name = this.get('name'),
- schema = this.get('schema'),
- relowner = this.get('relowner'),
- is_partitioned = this.get('is_partitioned'),
- partition_keys = this.get('partition_keys');
+ validate: function() {
+ var msg,
+ name = this.get('name'),
+ schema = this.get('schema'),
+ relowner = this.get('relowner'),
+ is_partitioned = this.get('is_partitioned'),
+ partition_keys = this.get('partition_keys');
if (
_.isUndefined(name) || _.isNull(name) ||
- String(name).replace(/^\s+|\s+$/g, '') == ''
+ String(name).replace(/^\s+|\s+$/g, '') == ''
) {
msg = gettext('Table name cannot be empty.');
this.errorModel.set('name', msg);
@@ -1149,7 +1143,7 @@ define('pgadmin.node.table', [
this.errorModel.unset('name');
if (
_.isUndefined(schema) || _.isNull(schema) ||
- String(schema).replace(/^\s+|\s+$/g, '') == ''
+ String(schema).replace(/^\s+|\s+$/g, '') == ''
) {
msg = gettext('Table schema cannot be empty.');
this.errorModel.set('schema', msg);
@@ -1158,7 +1152,7 @@ define('pgadmin.node.table', [
this.errorModel.unset('schema');
if (
_.isUndefined(relowner) || _.isNull(relowner) ||
- String(relowner).replace(/^\s+|\s+$/g, '') == ''
+ String(relowner).replace(/^\s+|\s+$/g, '') == ''
) {
msg = gettext('Table owner cannot be empty.');
this.errorModel.set('relowner', msg);
@@ -1167,7 +1161,7 @@ define('pgadmin.node.table', [
this.errorModel.unset('relowner');
if (
is_partitioned && this.isNew() &&
- !_.isNull(partition_keys) && partition_keys.length <= 0
+ !_.isNull(partition_keys) && partition_keys.length <= 0
) {
msg = gettext('Please specify at least one key for partitioned table.');
this.errorModel.set('partition_keys', msg);
@@ -1189,7 +1183,7 @@ define('pgadmin.node.table', [
if(
(!_.isUndefined(m.get('coll_inherits')) && m.get('coll_inherits').length != 0)
||
- (!_.isUndefined(m.get('typname')) && String(m.get('typname')).replace(/^\s+|\s+$/g, '') !== '')
+ (!_.isUndefined(m.get('typname')) && String(m.get('typname')).replace(/^\s+|\s+$/g, '') !== '')
) {
// Either of_types or coll_inherits has value
return false;
@@ -1204,15 +1198,15 @@ define('pgadmin.node.table', [
// Disabled if it is partitioned table
if (m.get('is_partitioned')) {
setTimeout( function() {
- m.set('coll_inherits', []);
+ m.set('coll_inherits', []);
}, 10);
return true;
}
// coll_inherits || typname
if(!m.inSchema.apply(this, [m]) &&
- ( _.isUndefined(m.get('typname')) ||
- _.isNull(m.get('typname')) ||
+ ( _.isUndefined(m.get('typname')) ||
+ _.isNull(m.get('typname')) ||
String(m.get('typname')).replace(/^\s+|\s+$/g, '') == '')) {
return false;
}
@@ -1221,8 +1215,8 @@ define('pgadmin.node.table', [
// We will disable Like if ofType is defined
isLikeDisable: function(m) {
if(!m.inSchemaWithModelCheck.apply(this, [m]) &&
- ( _.isUndefined(m.get('typname')) ||
- _.isNull(m.get('typname')) ||
+ ( _.isUndefined(m.get('typname')) ||
+ _.isNull(m.get('typname')) ||
String(m.get('typname')).replace(/^\s+|\s+$/g, '') == '')) {
return false;
}
@@ -1234,10 +1228,10 @@ define('pgadmin.node.table', [
if(!m.inSchema.apply(this, [m])) {
// if of_type then disable add in grid
if (!_.isUndefined(m.get('typname')) &&
- !_.isNull(m.get('typname')) &&
+ !_.isNull(m.get('typname')) &&
m.get('typname') !== '') {
- enable_flag = false;
- }
+ enable_flag = false;
+ }
}
return enable_flag;
},
@@ -1245,8 +1239,8 @@ define('pgadmin.node.table', [
check_grid_row_edit_delete: function(m) {
var flag = true;
if(!_.isUndefined(m.get('inheritedfrom')) &&
- !_.isNull(m.get('inheritedfrom')) &&
- String(m.get('inheritedfrom')).replace(/^\s+|\s+$/g, '') !== '') {
+ !_.isNull(m.get('inheritedfrom')) &&
+ String(m.get('inheritedfrom')).replace(/^\s+|\s+$/g, '') !== '') {
flag = false;
}
return flag;
@@ -1255,9 +1249,9 @@ define('pgadmin.node.table', [
checkOfType: function(m) {
//coll_inherits || typname
if(!m.inSchemaWithModelCheck.apply(this, [m]) &&
- (_.isUndefined(m.get('coll_inherits')) ||
- _.isNull(m.get('coll_inherits')) ||
- String(m.get('coll_inherits')).replace(/^\s+|\s+$/g, '') == '')) {
+ (_.isUndefined(m.get('coll_inherits')) ||
+ _.isNull(m.get('coll_inherits')) ||
+ String(m.get('coll_inherits')).replace(/^\s+|\s+$/g, '') == '')) {
return false;
}
return true;
@@ -1279,7 +1273,7 @@ define('pgadmin.node.table', [
// We need to check additional condition to toggle enable/disable
// for table auto-vacuum
if(!m.inSchema.apply(this, [m]) &&
- m.get('autovacuum_enabled') === true) {
+ m.get('autovacuum_enabled') === true) {
return false;
}
return true;
@@ -1288,27 +1282,26 @@ define('pgadmin.node.table', [
// We need to check additional condition to toggle enable/disable
// for toast table auto-vacuum
if(!m.inSchemaWithModelCheck.apply(this, [m]) &&
- m.get('toast_autovacuum_enabled') == true) {
+ m.get('toast_autovacuum_enabled') == true) {
return false;
}
return true;
},
fetch_columns_ajax: function(arg) {
var self = this,
- url = 'get_columns',
- m = self.model.top || self.model,
- old_columns = _.clone(m.get('columns')),
- data = undefined,
- node = this.field.get('schema_node'),
- node_info = this.field.get('node_info'),
- full_url = node.generate_url.apply(
- node, [
- null, url, this.field.get('node_data'),
- this.field.get('url_with_id') || false, node_info
- ]
- ),
- cache_level = this.field.get('cache_level') || node.type,
- cache_node = this.field.get('cache_node');
+ url = 'get_columns',
+ m = self.model.top || self.model,
+ data = undefined,
+ node = this.field.get('schema_node'),
+ node_info = this.field.get('node_info'),
+ full_url = node.generate_url.apply(
+ node, [
+ null, url, this.field.get('node_data'),
+ this.field.get('url_with_id') || false, node_info,
+ ]
+ ),
+ cache_level = this.field.get('cache_level') || node.type,
+ cache_node = this.field.get('cache_node');
cache_node = (cache_node && pgBrowser.Nodes[cache_node]) || node;
@@ -1323,40 +1316,40 @@ define('pgadmin.node.table', [
},
error: function() {
m.trigger('pgadmin:view:fetch:error', m, self.field);
- }
+ },
});
m.trigger('pgadmin:view:fetched', m, self.field);
data = (data && data.data) || [];
return data;
- }
+ },
}),
canCreate: function(itemData, item, data) {
- //If check is false then , we will allow create menu
- if (data && data.check == false)
- return true;
+ //If check is false then , we will allow create menu
+ if (data && data.check == false)
+ return true;
- var t = pgBrowser.tree, i = item, d = itemData;
- // To iterate over tree to check parent node
- while (i) {
- // If it is schema then allow user to create table
- if (_.indexOf(['schema'], d._type) > -1)
- return true;
+ var t = pgBrowser.tree, i = item, d = itemData;
+ // To iterate over tree to check parent node
+ while (i) {
+ // If it is schema then allow user to create table
+ if (_.indexOf(['schema'], d._type) > -1)
+ return true;
- if ('coll-table' == d._type) {
- //Check if we are not child of catalog
- var prev_i = t.hasParent(i) ? t.parent(i) : null,
+ if ('coll-table' == d._type) {
+ //Check if we are not child of catalog
+ var prev_i = t.hasParent(i) ? t.parent(i) : null,
prev_d = prev_i ? t.itemData(prev_i) : null;
- if( prev_d._type == 'catalog') {
- return false;
- } else {
- return true;
- }
+ if( prev_d._type == 'catalog') {
+ return false;
+ } else {
+ return true;
}
- i = t.hasParent(i) ? t.parent(i) : null;
- d = i ? t.itemData(i) : null;
}
- // by default we do not want to allow create menu
- return true;
+ i = t.hasParent(i) ? t.parent(i) : null;
+ d = i ? t.itemData(i) : null;
+ }
+ // by default we do not want to allow create menu
+ return true;
},
// Check to whether table has disable trigger(s)
canCreate_with_trigger_enable: function(itemData, item, data) {
@@ -1381,22 +1374,24 @@ define('pgadmin.node.table', [
}
},
onTableUpdated: function(_node, _oldNodeData, _newNodeData) {
+ var key, childIDs;
if (
- _newNodeData.is_partitioned && 'affected_partitions' in _newNodeData
+ _newNodeData.is_partitioned &&
+ 'affected_partitions' in _newNodeData
) {
var partitions = _newNodeData.affected_partitions,
- idx, node_info, self = this,
- newPartitionsIDs = [],
- insertChildTreeNodes = [],
- insertChildrenNodes = function() {
- if (!insertChildTreeNodes.length)
- return;
- var option = insertChildTreeNodes.pop();
- pgBrowser.addChildTreeNodes(
- option.treeHierarchy, option.parent, option.type,
- option.childrenIDs, insertChildrenNodes
- );
- };
+ self = this,
+ newPartitionsIDs = [],
+ insertChildTreeNodes = [],
+ insertChildrenNodes = function() {
+ if (!insertChildTreeNodes.length)
+ return;
+ var option = insertChildTreeNodes.pop();
+ pgBrowser.addChildTreeNodes(
+ option.treeHierarchy, option.parent, option.type,
+ option.childrenIDs, insertChildrenNodes
+ );
+ }, schemaNode ;
if ('detached' in partitions && partitions.detached.length > 0) {
// Remove it from the partition collections node first
@@ -1406,15 +1401,15 @@ define('pgadmin.node.table', [
)
);
- var schemaNode = pgBrowser.findParentTreeNodeByType(
- _node, 'schema'
- ),
- detachedBySchema = _.groupBy(
- partitions.detached,
- function(_d) { return parseInt(_d.schema_id); }
- ), childIDs;
+ schemaNode = pgBrowser.findParentTreeNodeByType(
+ _node, 'schema'
+ );
+ var detachedBySchema = _.groupBy(
+ partitions.detached,
+ function(_d) { return parseInt(_d.schema_id); }
+ );
- for (var key in detachedBySchema) {
+ for (key in detachedBySchema) {
schemaNode = pgBrowser.findSiblingTreeNode(schemaNode, key);
if (schemaNode) {
@@ -1431,8 +1426,11 @@ define('pgadmin.node.table', [
insertChildTreeNodes.push({
'parent': tablesCollNode,
'type': 'table',
- 'treeHierarchy': pgAdmin.Browser.Nodes.schema.getTreeNodeHierarchy(schemaNode),
- 'childrenIDs': _.clone(childIDs)
+ 'treeHierarchy':
+ pgAdmin.Browser.Nodes.schema.getTreeNodeHierarchy(
+ schemaNode
+ ),
+ 'childrenIDs': _.clone(childIDs),
});
}
}
@@ -1440,15 +1438,15 @@ define('pgadmin.node.table', [
}
if ('attached' in partitions && partitions.attached.length > 0) {
- var schemaNode = pgBrowser.findParentTreeNodeByType(
- _node, 'schema'
- ),
- attachedBySchema = _.groupBy(
- partitions.attached,
- function(_d) { return parseInt(_d.schema_id); }
- ), childIDs;
-
- for (var key in attachedBySchema) {
+ schemaNode = pgBrowser.findParentTreeNodeByType(
+ _node, 'schema'
+ );
+ var attachedBySchema = _.groupBy(
+ partitions.attached,
+ function(_d) { return parseInt(_d.schema_id); }
+ );
+
+ for (key in attachedBySchema) {
schemaNode = pgBrowser.findSiblingTreeNode(schemaNode, key);
if (schemaNode) {
@@ -1472,8 +1470,6 @@ define('pgadmin.node.table', [
}
if (newPartitionsIDs.length) {
- node_info = self.getTreeNodeHierarchy(_node);
-
var partitionsCollNode = pgBrowser.findChildCollectionTreeNode(
_node, 'coll-partition'
);
@@ -1483,7 +1479,7 @@ define('pgadmin.node.table', [
'parent': partitionsCollNode,
'type': 'partition',
'treeHierarchy': self.getTreeNodeHierarchy(_node),
- 'childrenIDs': newPartitionsIDs
+ 'childrenIDs': newPartitionsIDs,
});
}
}
@@ -1494,7 +1490,7 @@ define('pgadmin.node.table', [
// Clear Table's cache as column's type is dependent on two node
// 1) Type node 2) Domain node
this.clear_cache.apply(this, null);
- }
+ },
});
}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
index bb5a5927..fbe7659e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
@@ -1,10 +1,10 @@
define('pgadmin.node.trigger', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'backform', 'pgadmin.alertifyjs',
- 'pgadmin.browser.collection'
+ 'pgadmin.browser.collection',
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
- var CustomSwitchControl = Backform.CustomSwitchControl = Backform.SwitchControl.extend({
+ Backform.CustomSwitchControl = Backform.SwitchControl.extend({
template: _.template([
'',
'
' +
- gettext('Schedules are specified using a cron-style format.
For each selected time or date element, the schedule will execute. e.g. To execute at 5 minutes past every hour, simply select ‘05’ in the Minutes list box.
Values from more than one field may be specified in order to further control the schedule. e.g. To execute at 12:05 and 14:05 every Monday and Thursday, you would click minute 05, hours 12 and 14, and weekdays Monday and Thursday.
For additional flexibility, the Month Days check list includes an extra Last Day option. This matches the last day of the month, whether it happens to be the 28th, 29th, 30th or 31st.
') +
- '
'
+ Backform.helpMessageClassName + '">' +
+ gettext('Schedules are specified using a cron-style format.
For each selected time or date element, the schedule will execute. e.g. To execute at 5 minutes past every hour, simply select ‘05’ in the Minutes list box.
Values from more than one field may be specified in order to further control the schedule. e.g. To execute at 12:05 and 14:05 every Monday and Thursday, you would click minute 05, hours 12 and 14, and weekdays Monday and Thursday.
For additional flexibility, the Month Days check list includes an extra Last Day option. This matches the last day of the month, whether it happens to be the 28th, 29th, 30th or 31st.