diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.js index 746f1849..635af9cb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.js @@ -1,8 +1,10 @@ define('pgadmin.node.collation', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', - 'pgadmin.node.schema.dir/child', 'pgadmin.browser.collection', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, schemaChild) { + 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', + 'pgadmin.browser.collection', +], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, schemaChild, + schemaChildTreeNode) { if (!pgBrowser.Nodes['coll-collation']) { pgAdmin.Browser.Nodes['coll-collation'] = @@ -11,6 +13,8 @@ define('pgadmin.node.collation', [ label: gettext('Collations'), type: 'coll-collation', columns: ['name', 'owner', 'description'], + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints.js index 76cd54d7..7b17197e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints.js @@ -13,7 +13,7 @@ define('pgadmin.node.domain_constraints', [ label: gettext('Domain Constraints'), type: 'coll-domain_constraints', columns: ['name', 'description'], - canDrop: true, + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, canDropCascade: false, }); } 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 fb2f746d..df3d1227 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 @@ -2,10 +2,11 @@ define('pgadmin.node.domain', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'backbone', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.backgrid', - 'pgadmin.node.schema.dir/child', 'pgadmin.browser.collection', + 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', + 'pgadmin.browser.collection', ], function( gettext, url_for, $, _, Backbone, pgAdmin, pgBrowser, Backform, Backgrid, - schemaChild + schemaChild, schemaChildTreeNode ) { // Define Domain Collection Node @@ -16,6 +17,8 @@ define('pgadmin.node.domain', [ label: gettext('Domains'), type: 'coll-domain', columns: ['name', 'owner', 'description'], + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js index 4da0a2d0..2b40788a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js @@ -2,10 +2,11 @@ define('pgadmin.node.foreign_table', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'backbone', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.backgrid', - 'pgadmin.node.schema.dir/child', 'pgadmin.browser.collection', + 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', + 'pgadmin.browser.collection', ], function( gettext, url_for, $, _, Backbone, pgAdmin, pgBrowser, Backform, Backgrid, - schemaChild + schemaChild, schemaChildTreeNode ) { if (!pgBrowser.Nodes['coll-foreign_table']) { @@ -15,6 +16,8 @@ define('pgadmin.node.foreign_table', [ label: gettext('Foreign Tables'), type: 'coll-foreign_table', columns: ['name', 'owner', 'description'], + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } 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 705e41d7..26620fdc 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 @@ -1,10 +1,11 @@ define('pgadmin.node.fts_configuration', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'backbone', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.backgrid', - 'pgadmin.node.schema.dir/child', 'pgadmin.browser.collection', + 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', + 'pgadmin.browser.collection', ], function( gettext, url_for, $, _, Backbone, pgAdmin, pgBrowser, Backform, Backgrid, - schemaChild + schemaChild, schemaChildTreeNode ) { // Model for tokens control @@ -406,6 +407,8 @@ define('pgadmin.node.fts_configuration', [ label: gettext('FTS Configurations'), type: 'coll-fts_configuration', columns: ['name', 'description'], + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/static/js/fts_dictionary.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/static/js/fts_dictionary.js index b1163c66..2d10af6d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/static/js/fts_dictionary.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/static/js/fts_dictionary.js @@ -1,9 +1,11 @@ define('pgadmin.node.fts_dictionary', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', - 'pgadmin.node.schema.dir/child', 'pgadmin.browser.collection', + 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', + 'pgadmin.browser.collection', ], function( - gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, schemaChild + gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, schemaChild, + schemaChildTreeNode ) { // Extend the browser's node model class to create a option/value pair @@ -52,6 +54,8 @@ define('pgadmin.node.fts_dictionary', [ label: gettext('FTS Dictionaries'), type: 'coll-fts_dictionary', columns: ['name', 'description'], + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/static/js/fts_parser.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/static/js/fts_parser.js index 959110ea..9918b911 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/static/js/fts_parser.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/static/js/fts_parser.js @@ -1,8 +1,8 @@ define('pgadmin.node.fts_parser', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.node.schema.dir/child', - 'pgadmin.browser.collection', -], function(gettext, url_for, $, _, pgAdmin, pgBrowser, schemaChild) { + 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection', +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, schemaChild, schemaChildTreeNode) { // Extend the collection class for fts parser if (!pgBrowser.Nodes['coll-fts_parser']) { @@ -12,6 +12,8 @@ define('pgadmin.node.fts_parser', [ label: gettext('FTS Parsers'), type: 'coll-fts_parser', columns: ['name', 'description'], + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/static/js/fts_template.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/static/js/fts_template.js index 4a39ee10..01f73b6e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/static/js/fts_template.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/static/js/fts_template.js @@ -1,8 +1,8 @@ define('pgadmin.node.fts_template', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.node.schema.dir/child', - 'pgadmin.browser.collection', -], function(gettext, url_for, $, _, pgAdmin, pgBrowser, schemaChild) { + 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection', +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, schemaChild, schemaChildTreeNode) { // Extend the collection class for fts template if (!pgBrowser.Nodes['coll-fts_template']) { @@ -12,6 +12,8 @@ define('pgadmin.node.fts_template', [ label: gettext('FTS Templates'), type: 'coll-fts_template', columns: ['name', 'description'], + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.js index 55fa3b6b..06b394a9 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.js @@ -2,10 +2,11 @@ define('pgadmin.node.function', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'backbone', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', - 'pgadmin.node.schema.dir/child', 'pgadmin.browser.collection', - 'pgadmin.browser.server.privilege', + 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', + 'pgadmin.browser.collection', 'pgadmin.browser.server.privilege', ], function( - gettext, url_for, $, _, Backbone, pgAdmin, pgBrowser, Backform, schemaChild + gettext, url_for, $, _, Backbone, pgAdmin, pgBrowser, Backform, schemaChild, + schemaChildTreeNode ) { if (!pgBrowser.Nodes['coll-function']) { @@ -16,6 +17,8 @@ define('pgadmin.node.function', [ type: 'coll-function', columns: ['name', 'funcowner', 'description'], hasStatistics: true, + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/procedure.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/procedure.js index a721248c..bbe2b8f2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/procedure.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/procedure.js @@ -3,8 +3,10 @@ define('pgadmin.node.procedure', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'alertify', 'pgadmin.node.function', 'pgadmin.node.schema.dir/child', + 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection', 'pgadmin.browser.server.privilege', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, Function, schemaChild) { +], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, Function, + schemaChild, schemaChildTreeNode) { if (!pgBrowser.Nodes['coll-procedure']) { pgAdmin.Browser.Nodes['coll-procedure'] = @@ -14,6 +16,8 @@ define('pgadmin.node.procedure', [ type: 'coll-procedure', columns: ['name', 'funcowner', 'description'], hasStatistics: true, + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function.js index 283c6a07..73792e96 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function.js @@ -2,10 +2,10 @@ define('pgadmin.node.trigger_function', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', - 'pgadmin.node.schema.dir/child', 'pgadmin.browser.collection', - 'pgadmin.browser.server.privilege', + 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', + 'pgadmin.browser.collection', 'pgadmin.browser.server.privilege', ], function( - gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, schemaChild + gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, schemaChild, schemaChildTreeNode ) { if (!pgBrowser.Nodes['coll-trigger_function']) { @@ -16,6 +16,8 @@ define('pgadmin.node.trigger_function', [ type: 'coll-trigger_function', columns: ['name', 'funcowner', 'description'], hasStatistics: true, + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.js index f4504cb2..bbe6546d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.js @@ -1,8 +1,10 @@ define('pgadmin.node.package', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', - 'pgadmin.node.schema.dir/child', 'pgadmin.browser.collection', -], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, schemaChild) { + 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', + 'pgadmin.browser.collection', +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, schemaChild, + schemaChildTreeNode) { // Extend the browser's collection class for package collection if (!pgBrowser.Nodes['coll-package']) { @@ -12,6 +14,8 @@ define('pgadmin.node.package', [ label: gettext('Packages'), type: 'coll-package', columns: ['name' ,'owner', 'description'], + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js index 08b6745c..e4ca39b5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js @@ -1,9 +1,11 @@ define('pgadmin.node.sequence', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', - 'pgadmin.node.schema.dir/child', 'pgadmin.browser.collection', + 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', + 'pgadmin.browser.collection', ], function( - gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, schemaChild + gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, schemaChild, + schemaChildTreeNode ) { // Extend the browser's collection class for sequence collection @@ -15,6 +17,8 @@ define('pgadmin.node.sequence', [ type: 'coll-sequence', columns: ['name', 'seqowner', 'comment'], hasStatistics: true, + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js index a146dabc..5af9e743 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js @@ -1,8 +1,10 @@ define('pgadmin.node.synonym', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', - 'pgadmin.node.schema.dir/child', 'pgadmin.browser.collection', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, schemaChild) { + 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', + 'pgadmin.browser.collection', +], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, + schemaChild, schemaChildTreeNode) { if (!pgBrowser.Nodes['coll-synonym']) { pgAdmin.Browser.Nodes['coll-synonym'] = @@ -11,6 +13,8 @@ define('pgadmin.node.synonym', [ label: gettext('Synonyms'), type: 'coll-synonym', columns: ['name', 'owner','is_public_synonym'], + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } 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 95506baf..e4492825 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 @@ -1,9 +1,10 @@ define('pgadmin.node.column', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'backbone', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.backgrid', - 'pgadmin.browser.collection', + 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection', ], function( - gettext, url_for, $, _, Backbone, pgAdmin, pgBrowser, Backform, Backgrid + gettext, url_for, $, _, Backbone, pgAdmin, pgBrowser, Backform, Backgrid, + SchemaChildTreeNode ) { if (!pgBrowser.Nodes['coll-column']) { @@ -13,6 +14,8 @@ define('pgadmin.node.column', [ label: gettext('Columns'), type: 'coll-column', columns: ['name', 'atttypid', 'description'], + canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: SchemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js index 5732013f..bb1986bd 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js @@ -21,6 +21,8 @@ define('pgadmin.node.index', [ columns: ['name', 'description'], hasStatistics: true, statsPrettifyFields: ['Size', 'Index size'], + canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: SchemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js index ecb28e16..ebfd46a2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js @@ -19,6 +19,8 @@ function( columns: [ 'name', 'schema', 'partition_value', 'is_partitioned', 'description', ], + canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: SchemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js index 8add5b5c..e6858138 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js @@ -2,7 +2,7 @@ define('pgadmin.node.rule', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.node.schema.dir/schema_child_tree_node', -], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, schemaChildTreeNode) { +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, SchemaChildTreeNode) { /** Create and add a rule collection into nodes @@ -18,6 +18,8 @@ define('pgadmin.node.rule', [ label: gettext('Rules'), type: 'coll-rule', columns: ['name', 'owner', 'comment'], + canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: SchemaChildTreeNode.isTreeItemOfChildOfSchema, }); } @@ -45,7 +47,7 @@ define('pgadmin.node.rule', [ hasSQL: true, hasDepends: true, canDrop: function(itemData, item){ - schemaChildTreeNode.isTreeItemOfChildOfSchema.apply(this, [itemData, item]); + SchemaChildTreeNode.isTreeItemOfChildOfSchema.apply(this, [itemData, item]); if(_.has(itemData, 'label') && itemData.label === '_RETURN') return false; else { @@ -53,7 +55,7 @@ define('pgadmin.node.rule', [ } }, canDropCascade: function(itemData, item){ - schemaChildTreeNode.isTreeItemOfChildOfSchema.apply(this, [itemData, item]); + SchemaChildTreeNode.isTreeItemOfChildOfSchema.apply(this, [itemData, item]); if(_.has(itemData, 'label') && itemData.label === '_RETURN') return false; else { 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 dc7a7333..c8a09297 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 @@ -4,13 +4,13 @@ define('pgadmin.node.table', [ 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', 'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.tables.js/show_advanced_tab', - 'pgadmin.node.schema.dir/child', 'pgadmin.browser.collection', - 'pgadmin.node.column', 'pgadmin.node.constraints', - 'pgadmin.browser.table.partition.utils', + 'pgadmin.node.schema.dir/child','pgadmin.node.schema.dir/schema_child_tree_node', + 'pgadmin.browser.collection', 'pgadmin.node.column', + 'pgadmin.node.constraints', 'pgadmin.browser.table.partition.utils', ], function( tableFunctions, gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, Backform, Backgrid, - ShowAdvancedTab, SchemaChild + ShowAdvancedTab, SchemaChild, SchemaChildTreeNode ) { if (!pgBrowser.Nodes['coll-table']) { @@ -24,6 +24,8 @@ define('pgadmin.node.table', [ statsPrettifyFields: ['Size', 'Indexes size', 'Table size', 'Toast table size', 'Tuple length', 'Dead tuple length', 'Free space'], + canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: SchemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js index 2663b08e..d2613a7e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js @@ -35,6 +35,8 @@ define('pgadmin.node.trigger', [ label: gettext('Triggers'), type: 'coll-trigger', columns: ['name', 'description'], + canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: SchemaChildTreeNode.isTreeItemOfChildOfSchema, }); } 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 12045cf1..d19024b9 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 @@ -2,10 +2,10 @@ define('pgadmin.node.type', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.node.schema.dir/child', - 'pgadmin.browser.collection', + 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection', ], function( gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, Backgrid, - schemaChild + schemaChild, schemaChildTreeNode ) { if (!pgBrowser.Nodes['coll-type']) { @@ -15,6 +15,8 @@ define('pgadmin.node.type', [ label: gettext('Types'), type: 'coll-type', columns: ['name', 'typeowner', 'description'], + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js index 2b91673c..780e7d03 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js @@ -2,10 +2,10 @@ define('pgadmin.node.mview', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/pgadmin', 'pgadmin.alertifyjs', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.node.schema.dir/child', - 'pgadmin.browser.server.privilege', + 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.server.privilege', ], function( gettext, url_for, $, _, pgAdmin, Alertify, pgBrowser, Backform, - schemaChild + schemaChild, schemaChildTreeNode ) { /** @@ -22,6 +22,8 @@ define('pgadmin.node.mview', [ label: gettext('Materialized Views'), type: 'coll-mview', columns: ['name', 'owner'], + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.js index 1c339847..96e7cd40 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.js @@ -1,10 +1,10 @@ define('pgadmin.node.view', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', - 'pgadmin.node.schema.dir/child', 'pgadmin.browser.server.privilege', - 'pgadmin.node.rule', + 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', + 'pgadmin.browser.server.privilege', 'pgadmin.node.rule', ], function( - gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, schemaChild + gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, schemaChild, schemaChildTreeNode ) { @@ -22,6 +22,8 @@ define('pgadmin.node.view', [ label: gettext('Views'), type: 'coll-view', columns: ['name', 'owner'], + canDrop: schemaChildTreeNode.isTreeItemOfChildOfSchema, + canDropCascade: schemaChildTreeNode.isTreeItemOfChildOfSchema, }); } diff --git a/web/pgadmin/browser/static/js/collection.js b/web/pgadmin/browser/static/js/collection.js index ae77f81c..cda6fb98 100644 --- a/web/pgadmin/browser/static/js/collection.js +++ b/web/pgadmin/browser/static/js/collection.js @@ -124,7 +124,10 @@ define([ }.bind(panel); // Add the new column for the multi-select menus - if (that.canDrop || that.canDropCascade) { + if((_.isFunction(that.canDrop) ? + that.canDrop.apply(that, [data, item]) : that.canDrop) || + (_.isFunction(that.canDropCascade) ? + that.canDropCascade.apply(that, [data, item]) : that.canDropCascade)) { gridSchema.columns.unshift({ name: 'oid', cell: Backgrid.Extension.SelectRowCell.extend({ @@ -215,7 +218,10 @@ define([ tooltip: gettext('Delete/Drop'), extraClasses: ['btn-default', 'delete_multiple'], icon: 'fa fa-lg fa-trash-o', - disabled: !that.canDrop, + disabled: _.isFunction(that.canDrop) ? + function() { + return !(that.canDrop.apply(self, arguments)); + } : (!that.canDrop), register: function(btn) { btn.on('click',() => { onDrop('drop'); @@ -229,7 +235,10 @@ define([ tooltip: gettext('Drop Cascade'), extraClasses: ['btn-default', 'delete_multiple_cascade'], icon: '', - disabled: !that.canDropCascade, + disabled: _.isFunction(that.canDropCascade) ? + function() { + return !(that.canDropCascade.apply(self, arguments)); + } : (!that.canDropCascade), register: function(btn) { btn.on('click',() => { onDrop('dropCascade');