From c421bef0d09b27dabbbfd5d6e669777e79b49695 Mon Sep 17 00:00:00 2001 From: Harshal Dhumal Date: Fri, 22 Jan 2016 18:18:59 +0530 Subject: [PATCH] Changed the Unique Columns of the Variable Control based on the input from the user. i.e. Set the uniqueCol as ['name', 'role'] in case of hasRole is set to true in schema for it, ['name', ['database'] in case of hasDatabase is set to true, otherwise ['name']. Also - fixed a typo in the callback function headerDataChanged(..). --- .../servers/static/js/variable.js | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/static/js/variable.js b/web/pgadmin/browser/server_groups/servers/static/js/variable.js index 2ead1a009..fd3a0bb49 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/variable.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/variable.js @@ -191,20 +191,28 @@ hasDatabase: false, hasRole: false, - defaults: _.extend({ - uniqueCol: ['name', 'role', 'database'] - }, - Backform.UniqueColCollectionControl.prototype.defaults - ), - initialize: function(opts) { - var self = this; + var self = this, + uniqueCols = ['name']; + /* + * Read from field schema whether user wants to use database and role + * fields in Variable control. + */ + self.hasDatabase = opts.field.get('hasDatabase'); + self.hasRole = opts.field.get('hasRole'); + + // Update unique coll field based on above flag status. + if (self.hasDatabase) { + uniqueCols.push('database') + } else if (self.hasRole) { + uniqueCols.push('role') + } // Overriding the uniqueCol in the field if (opts && opts.field) { if (opts.field instanceof Backform.Field) { opts.field.set({ - uniqueCol: ['name', 'role', 'database'], + uniqueCol: uniqueCols, model: pgNode.VariableModel }, { @@ -212,7 +220,7 @@ }); } else { opts.field.extend({ - uniqueCol: ['name', 'role', 'database'], + uniqueCol: uniqueCols, model: pgNode.VariableModel }); } @@ -222,8 +230,7 @@ self, arguments ); - self.hasDatabase = self.field.get('hasDatabase'); - self.hasRole = self.field.get('hasRole'); + self.availVariables = {}; var node = self.field.get('node').type, @@ -566,7 +573,7 @@ checkVars.push('database'); } - if (self.role) { + if (self.hasRole) { checkVars.push('role'); }