Ensure the datatype cache is updated when a domain is added. Fixes #2778
parent
b2e844c0ad
commit
c5d1fc8189
|
@ -178,9 +178,11 @@ define('pgadmin.node.domain', [
|
||||||
id: 'basetype', label: gettext('Base type'), cell: 'string',
|
id: 'basetype', label: gettext('Base type'), cell: 'string',
|
||||||
control: 'node-ajax-options', type: 'text', url: 'get_types',
|
control: 'node-ajax-options', type: 'text', url: 'get_types',
|
||||||
mode:['properties', 'create', 'edit'], group: gettext('Definition'),
|
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();
|
return !m.isNew();
|
||||||
}, first_empty: true, transform: function(d) {
|
},
|
||||||
|
transform: function(d) {
|
||||||
this.model.type_options = d;
|
this.model.type_options = d;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ define('pgadmin.node.fts_configuration', [
|
||||||
cache_node = this.field.get('cache_node');
|
cache_node = this.field.get('cache_node');
|
||||||
|
|
||||||
cache_node = (cache_node &&
|
cache_node = (cache_node &&
|
||||||
pgAdmin.Browser.Nodes['cache_node'])
|
pgAdmin.Browser.Nodes[cache_node])
|
||||||
|| node;
|
|| node;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -297,6 +297,7 @@ define('pgadmin.node.column', [
|
||||||
control: 'node-ajax-options', url: 'get_types', node: 'table',
|
control: 'node-ajax-options', url: 'get_types', node: 'table',
|
||||||
cellHeaderClasses:'width_percent_30', first_empty: true,
|
cellHeaderClasses:'width_percent_30', first_empty: true,
|
||||||
select2: { allowClear: false }, group: gettext('Definition'),
|
select2: { allowClear: false }, group: gettext('Definition'),
|
||||||
|
cache_node: 'table',
|
||||||
transform: function(data, cell) {
|
transform: function(data, cell) {
|
||||||
/* 'transform' function will be called by control, and cell both.
|
/* 'transform' function will be called by control, and cell both.
|
||||||
* The way, we use the transform in cell, and control is different.
|
* The way, we use the transform in cell, and control is different.
|
||||||
|
|
|
@ -100,6 +100,14 @@ define('pgadmin.node.table', [
|
||||||
pgBrowser.Events.on(
|
pgBrowser.Events.on(
|
||||||
'pgadmin:browser:node:table:updated', this.onTableUpdated, this
|
'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,
|
canDrop: pgBrowser.Nodes['schema'].canChildDrop,
|
||||||
canDropCascade: 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_level = this.field.get('cache_level') || node.type,
|
||||||
cache_node = this.field.get('cache_node');
|
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);
|
m.trigger('pgadmin:view:fetching', m, self.field);
|
||||||
// Fetching Columns data for the selected table.
|
// Fetching Columns data for the selected table.
|
||||||
|
@ -1484,6 +1492,11 @@ define('pgadmin.node.table', [
|
||||||
}
|
}
|
||||||
insertChildrenNodes();
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,8 +86,8 @@ define('pgadmin.node.type', [
|
||||||
},{
|
},{
|
||||||
id: 'type', label: gettext('Type'), control: 'node-ajax-options',
|
id: 'type', label: gettext('Type'), control: 'node-ajax-options',
|
||||||
type: 'text', url: 'get_types', disabled: false, node: 'type',
|
type: 'text', url: 'get_types', disabled: false, node: 'type',
|
||||||
|
cache_node: 'domain', editable: true,
|
||||||
cell: 'node-ajax-options', select2: {allowClear: false},
|
cell: 'node-ajax-options', select2: {allowClear: false},
|
||||||
editable: true,
|
|
||||||
transform: function(d, control){
|
transform: function(d, control){
|
||||||
control.model.type_options = d;
|
control.model.type_options = d;
|
||||||
return d;
|
return d;
|
||||||
|
|
|
@ -50,7 +50,7 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform',
|
||||||
schema: [{
|
schema: [{
|
||||||
id: 'grantee', label: gettext('Grantee'), type:'text', group: null,
|
id: 'grantee', label: gettext('Grantee'), type:'text', group: null,
|
||||||
editable: true, cellHeaderClasses: 'width_percent_40',
|
editable: true, cellHeaderClasses: 'width_percent_40',
|
||||||
node: 'role',
|
node: 'role', options_cached: false,
|
||||||
disabled : function(m) {
|
disabled : function(m) {
|
||||||
if (!(m instanceof Backbone.Model)) {
|
if (!(m instanceof Backbone.Model)) {
|
||||||
// This has been called during generating the header cell
|
// This has been called during generating the header cell
|
||||||
|
|
|
@ -1578,6 +1578,13 @@ define(
|
||||||
* fetches the new data.
|
* fetches the new data.
|
||||||
*/
|
*/
|
||||||
this.cached = {};
|
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) {
|
cache_level: function(node_info, with_id) {
|
||||||
if (node_info) {
|
if (node_info) {
|
||||||
|
|
|
@ -343,8 +343,8 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
|
||||||
Backgrid.Extension.Select2Cell.prototype.initialize.apply(this, arguments);
|
Backgrid.Extension.Select2Cell.prototype.initialize.apply(this, arguments);
|
||||||
|
|
||||||
var url = this.column.get('url') || this.defaults.url,
|
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.
|
// Hmm - we found the url option.
|
||||||
// That means - we needs to fetch the options from that node.
|
// That means - we needs to fetch the options from that node.
|
||||||
if (url && !options_cached) {
|
if (url && !options_cached) {
|
||||||
|
@ -362,7 +362,7 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
|
||||||
cache_level,
|
cache_level,
|
||||||
cache_node = column.get('cache_node');
|
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')) {
|
if (column.has('cache_level')) {
|
||||||
cache_level = column.get('cache_level');
|
cache_level = column.get('cache_level');
|
||||||
|
@ -414,7 +414,10 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
|
||||||
} else {
|
} else {
|
||||||
column.set('options', data);
|
column.set('options', data);
|
||||||
}
|
}
|
||||||
column.set('options_cached', true);
|
|
||||||
|
if(is_options_cached) {
|
||||||
|
column.set('options_cached', true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue