mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Extract the tests and refactor some of the methods.
Extract some of the ACI Tree functionalities, and decouple it from the main source. Also - create some abstractions from the repeated code around the enable/disable the schema children object create/edit/delete functionalities, and also created the dialog wrappers for backup and restore dialogs. Reviewed by: Khushboo and Ashesh Refactored by: Ashesh
This commit is contained in:
committed by
Ashesh Vashi
parent
920934759f
commit
7dd6372eeb
@@ -115,17 +115,17 @@ define([
|
||||
// Fetch Data
|
||||
collection.fetch({
|
||||
reset: true,
|
||||
error: function(xhr, error, message) {
|
||||
error: function(model, error, xhr) {
|
||||
pgBrowser.Events.trigger(
|
||||
'pgadmin:collection:retrieval:error', 'properties', xhr, error,
|
||||
message, item, that
|
||||
error.message, item, that
|
||||
);
|
||||
if (!Alertify.pgHandleItemError(
|
||||
xhr, error, message, {item: item, info: info}
|
||||
xhr, error, error.message, {item: item, info: info}
|
||||
)) {
|
||||
Alertify.pgNotifier(error, xhr, S(
|
||||
gettext('Error retrieving properties - %s.')
|
||||
).sprintf(message || that.label).value(), function() {
|
||||
).sprintf(error.message || that.label).value(), function() {
|
||||
console.warn(arguments);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
define('pgadmin.browser.node', [
|
||||
'sources/tree/pgadmin_tree_node',
|
||||
'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'sources/pgadmin',
|
||||
'pgadmin.browser.menu', 'backbone', 'pgadmin.alertifyjs', 'pgadmin.browser.datamodel',
|
||||
'backform', 'sources/browser/generate_url', 'sources/utils', 'pgadmin.browser.utils',
|
||||
'pgadmin.backform',
|
||||
], function(gettext, $, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform, generateUrl, commonUtils) {
|
||||
], function(
|
||||
pgadminTreeNode,
|
||||
gettext, $, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform, generateUrl, commonUtils
|
||||
) {
|
||||
|
||||
var wcDocker = window.wcDocker,
|
||||
keyCode = {
|
||||
@@ -28,7 +32,7 @@ define('pgadmin.browser.node', [
|
||||
//
|
||||
// It is unlikely - we will instantiate an object for this class.
|
||||
// (Inspired by Backbone.extend function)
|
||||
pgBrowser.Node.extend = function(props) {
|
||||
pgBrowser.Node.extend = function(props, initialize) {
|
||||
var parent = this;
|
||||
var child;
|
||||
|
||||
@@ -44,6 +48,10 @@ define('pgadmin.browser.node', [
|
||||
// Make sure - a child have all the callbacks of the parent.
|
||||
child.callbacks = _.extend({}, parent.callbacks, props.callbacks);
|
||||
|
||||
// Let's not bind the callbacks, or initialize the child.
|
||||
if (initialize === false)
|
||||
return child;
|
||||
|
||||
var bindToChild = function(cb) {
|
||||
if (typeof(child.callbacks[cb]) == 'function') {
|
||||
child.callbacks[cb] = child.callbacks[cb].bind(child);
|
||||
@@ -1566,7 +1574,6 @@ define('pgadmin.browser.node', [
|
||||
* depends, statistics
|
||||
*/
|
||||
generate_url: function(item, type, d, with_id, info) {
|
||||
|
||||
var opURL = {
|
||||
'create': 'obj',
|
||||
'drop': 'obj',
|
||||
@@ -1608,24 +1615,7 @@ define('pgadmin.browser.node', [
|
||||
Collection: pgBrowser.DataCollection,
|
||||
// Base class for Node Data Model
|
||||
Model: pgBrowser.DataModel,
|
||||
getTreeNodeHierarchy: function(i) {
|
||||
var idx = 0,
|
||||
res = {},
|
||||
t = pgBrowser.tree,
|
||||
d;
|
||||
do {
|
||||
d = t.itemData(i);
|
||||
if (d._type in pgBrowser.Nodes && pgBrowser.Nodes[d._type].hasId) {
|
||||
res[d._type] = _.extend({}, d, {
|
||||
'priority': idx,
|
||||
});
|
||||
idx -= 1;
|
||||
}
|
||||
i = t.hasParent(i) ? t.parent(i) : null;
|
||||
} while (i);
|
||||
|
||||
return res;
|
||||
},
|
||||
getTreeNodeHierarchy: pgadminTreeNode.getTreeNodeHierarchyFromIdentifier.bind(pgBrowser),
|
||||
cache: function(url, node_info, level, data) {
|
||||
var cached = this.cached = this.cached || {},
|
||||
hash = url,
|
||||
|
||||
Reference in New Issue
Block a user