1) Added partition module in webpack config.

2) Fixed missing logic of partition from primary_key.js and unique_constraint.js as this two files are newly created for webpack.
3) Changed the node name from 'check_constraint' to 'check_constraints'. Also changed the same in test case url.
REL-1_X
Akshay Joshi 2017-07-31 18:24:14 +05:30
parent bdefdf5d4e
commit a7f58e2b92
9 changed files with 59 additions and 30 deletions

View File

@ -46,7 +46,7 @@ class CheckConstraintModule(CollectionNodeModule):
- Load the module script for the Check Constraint, when any of the
Check node is initialized.
"""
NODE_TYPE = 'check_constraint'
NODE_TYPE = 'check_constraints'
COLLECTION_LABEL = _("Check Constraints")
def __init__(self, *args, **kwargs):

View File

@ -25,7 +25,7 @@ class CheckConstraintAddTestCase(BaseTestGenerator):
"""This class will add check constraint to existing table"""
scenarios = [
('Add check constraint to table',
dict(url='/browser/check_constraint/obj/'))
dict(url='/browser/check_constraints/obj/'))
]
def setUp(self):

View File

@ -25,7 +25,7 @@ class CheckConstraintDeleteTestCase(BaseTestGenerator):
"""This class will delete check constraint to existing table"""
scenarios = [
('Delete check constraint to table',
dict(url='/browser/check_constraint/obj/'))
dict(url='/browser/check_constraints/obj/'))
]
def setUp(self):

View File

@ -25,7 +25,7 @@ class CheckConstraintGetTestCase(BaseTestGenerator):
"""This class will fetch check constraint to existing table"""
scenarios = [
('Fetch check constraint to table',
dict(url='/browser/check_constraint/obj/'))
dict(url='/browser/check_constraints/obj/'))
]
def setUp(self):

View File

@ -26,7 +26,7 @@ class CheckConstraintPutTestCase(BaseTestGenerator):
"""This class will update check constraint to existing table"""
scenarios = [
('Update check constraint to table',
dict(url='/browser/check_constraint/obj/'))
dict(url='/browser/check_constraints/obj/'))
]
def setUp(self):

View File

@ -17,9 +17,10 @@ define('pgadmin.node.primary_key', [
hasDepends: true,
hasStatistics: true,
statsPrettifyFields: ['Index size'],
parent_type: 'table',
parent_type: ['table','partition'],
canDrop: true,
canDropCascade: true,
getTreeNodeHierarchy: pgBrowser.tableChildTreeNodeHierarchy,
Init: function() {
/* Avoid multiple registration of menus */
if (this.initialized)
@ -42,11 +43,26 @@ define('pgadmin.node.primary_key', [
if (data && data.check == false)
return true;
var t = pgBrowser.tree, i = item, d = itemData, parents = [];
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) {
// 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 it is schema then allow user to c reate table
if (_.indexOf(['schema'], d._type) > -1) {
if (is_immediate_parent_table_partitioned) {
return false;
}
// There should be only one primary key per table.
var children = t.children(arguments[1], false),
primary_key_found = false;
@ -67,7 +83,7 @@ define('pgadmin.node.primary_key', [
if (_.indexOf(parents, 'catalog') > -1) {
return false;
} else {
return true;
return !is_immediate_parent_table_partitioned;
}
},

View File

@ -17,9 +17,10 @@ define('pgadmin.node.unique_constraint', [
hasDepends: true,
hasStatistics: true,
statsPrettifyFields: ['Index size'],
parent_type: 'table',
parent_type: ['table','partition'],
canDrop: true,
canDropCascade: true,
getTreeNodeHierarchy: pgBrowser.tableChildTreeNodeHierarchy,
Init: function() {
/* Avoid multiple registration of menus */
if (this.initialized)
@ -42,12 +43,23 @@ define('pgadmin.node.unique_constraint', [
if (data && data.check == false)
return true;
var t = pgBrowser.tree, i = item, d = itemData, parents = [];
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) {
// 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 it is schema then allow user to c reate table
if (_.indexOf(['schema'], d._type) > -1) {
return true;
return !is_immediate_parent_table_partitioned;
}
parents.push(d._type);
i = t.hasParent(i) ? t.parent(i) : null;
@ -57,7 +69,7 @@ define('pgadmin.node.unique_constraint', [
if (_.indexOf(parents, 'catalog') > -1) {
return false;
} else {
return true;
return !is_immediate_parent_table_partitioned;
}
},

View File

@ -15,8 +15,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
type: 'coll-partition',
columns: [
'name', 'schema', 'partition_value', 'is_partitioned', 'description'
],
hasStatistics: true
]
});
};
@ -86,7 +85,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
t = pgBrowser.tree;
do {
d = t.itemData(i);
var d = t.itemData(i);
if (
d._type in pgBrowser.Nodes && pgBrowser.Nodes[d._type].hasId
) {
@ -126,7 +125,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
info || {} : this.getTreeNodeHierarchy(item);
return S('table/%s/%s/%s/%s/%s/%s').sprintf(
encodeURIComponent(type), encodeURIComponent(info['server-group']._id),
encodeURIComponent(type), encodeURIComponent(info['server_group']._id),
encodeURIComponent(info['server']._id),
encodeURIComponent(info['database']._id),
encodeURIComponent(info['partition'].schema_id),
@ -149,11 +148,12 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
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;
var input = args || {},
obj = this,
t = pgBrowser.tree,
i = input.item || t.selected(),
d = i && i.length == 1 ? t.itemData(i) : undefined;
if (!d)
return false;
@ -197,11 +197,11 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
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;
var input = args || {},
obj = this,
t = pgBrowser.tree,
i = input.item || t.selected(),
d = i && i.length == 1 ? t.itemData(i) : undefined;
if (!d)
return false;
@ -1195,7 +1195,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
var self = this,
url = 'get_columns',
m = self.model.top || self.model,
old_columns = _.clone(m.get('columns'))
old_columns = _.clone(m.get('columns')),
data = undefined,
node = this.field.get('schema_node'),
node_info = this.field.get('node_info'),
@ -1242,8 +1242,8 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
if ('coll-table' == d._type) {
//Check if we are not child of catalog
prev_i = t.hasParent(i) ? t.parent(i) : null;
prev_d = prev_i ? t.itemData(prev_i) : null;
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 {

View File

@ -195,7 +195,8 @@ module.exports = {
',pgadmin.node.catalog_object_column' +
',pgadmin.node.view' +
',pgadmin.node.mview' +
',pgadmin.node.table',
',pgadmin.node.table' +
',pgadmin.node.partition',
},
}, {
test: require.resolve('./node_modules/acitree/js/jquery.aciTree.min'),