From 28621999f22805852cd19ad7dca2a72cfb676e7e Mon Sep 17 00:00:00 2001 From: Murtuza Zabuawala Date: Tue, 17 Jan 2017 10:25:26 +0000 Subject: [PATCH] Improve display of columns of exclusion contraints and foreign keys in the properties lists. Fixes #2065 --- .../exclusion_constraint/js/exclusion_constraint.js | 12 ++++++++---- .../templates/foreign_key/js/foreign_key.js | 9 +++++++-- web/pgadmin/static/js/backform.pgadmin.js | 5 +++++ web/pgadmin/static/js/backgrid/backgrid.pgadmin.js | 5 +++++ 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js index 9250d9fd9..cfe15195b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js @@ -427,9 +427,9 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) { controls.push(control); }); - // We should not show add but in properties mode + // We should not show in properties mode if (data.mode == 'properties') { - $header.find("button.add").remove(); + $header.html(''); } self.$header = $header; @@ -443,12 +443,12 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) { ), showGridControl: function(data) { - var self = this, titleTmpl = _.template("
"), $gridBody = $("
").append( - titleTmpl({label: data.label}) + // Append titleTmpl only if create/edit mode + data.mode !== 'properties' ? titleTmpl({label: data.label}) : '' ); $gridBody.append(self.generateHeader(data)); @@ -487,6 +487,10 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) { ); }, 10); + // 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; }, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js index 4e508732d..5fbb36298 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js @@ -348,7 +348,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) { // We should not show add but in properties mode if (data.mode == 'properties') { - $header.find("button.add").remove(); + $header.html(''); } self.$header = $header; @@ -370,7 +370,8 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) { ""].join("\n")), $gridBody = $("
").append( - titleTmpl({label: data.label}) + // 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) @@ -419,6 +420,10 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) { ); }, 10); + // 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; }, diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js index ae2cea353..f35b03d8d 100644 --- a/web/pgadmin/static/js/backform.pgadmin.js +++ b/web/pgadmin/static/js/backform.pgadmin.js @@ -1949,6 +1949,11 @@ options: (this.field.get('options') || this.defaults.options) }); + // If disabled then no need to show placeholder + if(data.disabled || data.mode === 'properties') { + select2Opts['placeholder'] = ''; + } + /* * Add empty option as Select2 requires any empty '