diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.js index 3f6678b..ebdef6b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.js @@ -178,9 +178,11 @@ define('pgadmin.node.domain', [ id: 'basetype', label: gettext('Base type'), cell: 'string', control: 'node-ajax-options', type: 'text', url: 'get_types', mode:['properties', 'create', 'edit'], group: gettext('Definition'), - cache_level: 'database', cache_node: 'schema', disabled: function(m) { + first_empty: true, cache_node: 'type', + disabled: function(m) { return !m.isNew(); - }, first_empty: true, transform: function(d) { + }, + transform: function(d) { this.model.type_options = d; return d; } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js index 9bda9ce..7e266cb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js @@ -94,7 +94,7 @@ define('pgadmin.node.fts_configuration', [ cache_node = this.field.get('cache_node'); cache_node = (cache_node && - pgAdmin.Browser.Nodes['cache_node']) + pgAdmin.Browser.Nodes[cache_node]) || node; /* diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js index 90c3f8f..dcedd7e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js @@ -297,6 +297,7 @@ define('pgadmin.node.column', [ control: 'node-ajax-options', url: 'get_types', node: 'table', cellHeaderClasses:'width_percent_30', first_empty: true, select2: { allowClear: false }, group: gettext('Definition'), + cache_node: 'table', transform: function(data, cell) { /* 'transform' function will be called by control, and cell both. * The way, we use the transform in cell, and control is different. 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 23d4226..d0113e6 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 @@ -100,6 +100,14 @@ define('pgadmin.node.table', [ pgBrowser.Events.on( 'pgadmin:browser:node:table:updated', this.onTableUpdated, this ); + pgBrowser.Events.on( + 'pgadmin:browser:node:type:cache_cleared', + this.handle_cache, this + ); + pgBrowser.Events.on( + 'pgadmin:browser:node:domain:cache_cleared', + this.handle_cache, this + ); }, canDrop: pgBrowser.Nodes['schema'].canChildDrop, canDropCascade: pgBrowser.Nodes['schema'].canChildDrop, @@ -1305,7 +1313,7 @@ define('pgadmin.node.table', [ 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; + cache_node = (cache_node && pgBrowser.Nodes[cache_node]) || node; m.trigger('pgadmin:view:fetching', m, self.field); // Fetching Columns data for the selected table. @@ -1484,6 +1492,11 @@ define('pgadmin.node.table', [ } insertChildrenNodes(); } + }, + handle_cache: function() { + // 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/types/static/js/type.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js index 0751539..5c168cd 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js @@ -86,8 +86,8 @@ define('pgadmin.node.type', [ },{ id: 'type', label: gettext('Type'), control: 'node-ajax-options', type: 'text', url: 'get_types', disabled: false, node: 'type', + cache_node: 'domain', editable: true, cell: 'node-ajax-options', select2: {allowClear: false}, - editable: true, transform: function(d, control){ control.model.type_options = d; return d; diff --git a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js index 5465208..2bd9453 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js @@ -50,7 +50,7 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', schema: [{ id: 'grantee', label: gettext('Grantee'), type:'text', group: null, editable: true, cellHeaderClasses: 'width_percent_40', - node: 'role', + node: 'role', options_cached: false, disabled : function(m) { if (!(m instanceof Backbone.Model)) { // This has been called during generating the header cell diff --git a/web/pgadmin/browser/static/js/node.js b/web/pgadmin/browser/static/js/node.js index 7b5ba6f..78a0079 100644 --- a/web/pgadmin/browser/static/js/node.js +++ b/web/pgadmin/browser/static/js/node.js @@ -1578,6 +1578,13 @@ define( * fetches the new data. */ this.cached = {}; + + // Trigger Notify event about node's cache + var self = this; + pgBrowser.Events.trigger( + 'pgadmin:browser:node:' + self.type + ':cache_cleared', + item, self + ); }, cache_level: function(node_info, with_id) { if (node_info) { diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js index a1dbf18..7aca37c 100644 --- a/web/pgadmin/browser/static/js/node.ui.js +++ b/web/pgadmin/browser/static/js/node.ui.js @@ -343,8 +343,8 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) { Backgrid.Extension.Select2Cell.prototype.initialize.apply(this, arguments); var url = this.column.get('url') || this.defaults.url, - options_cached = this.column.get('options_cached'); - + is_options_cached = _.has(this.column.attributes, 'options_cached'), + options_cached = is_options_cached && this.column.get('options_cached'); // Hmm - we found the url option. // That means - we needs to fetch the options from that node. if (url && !options_cached) { @@ -362,7 +362,7 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) { cache_level, cache_node = column.get('cache_node'); - cache_node = (cache_node && pgAdmin.Browser.Nodes['cache_node']) || node; + cache_node = (cache_node && pgAdmin.Browser.Nodes[cache_node]) || node; if (column.has('cache_level')) { cache_level = column.get('cache_level'); @@ -414,7 +414,10 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) { } else { column.set('options', data); } - column.set('options_cached', true); + + if(is_options_cached) { + column.set('options_cached', true); + } } } });