mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Deleting the object (model & nested model/collection) during showing
the node properties.
This commit is contained in:
parent
1c0e477823
commit
58fcbd943a
@ -199,6 +199,36 @@ function(_, pgAdmin, $, Backbone) {
|
|||||||
|
|
||||||
return self;
|
return self;
|
||||||
},
|
},
|
||||||
|
// Create a reset function, which allow us to remove the nested object.
|
||||||
|
reset: function() {
|
||||||
|
var obj;
|
||||||
|
for(id in this.objects) {
|
||||||
|
obj = this.get(id);
|
||||||
|
|
||||||
|
if (obj) {
|
||||||
|
if (obj instanceof pgBrowser.DataModel) {
|
||||||
|
obj.reset();
|
||||||
|
delete obj;
|
||||||
|
} else if (obj instanceof Backbone.Model) {
|
||||||
|
obj.clear({silent: true});
|
||||||
|
delete obj;
|
||||||
|
} else if (obj instanceof pgBrowser.DataCollection) {
|
||||||
|
obj.reset({silent: true});
|
||||||
|
delete obj;
|
||||||
|
} else if (obj instanceof Backbone.Collection) {
|
||||||
|
obj.each(function(m) {
|
||||||
|
if (m instanceof Bakbone.DataModel) {
|
||||||
|
obj.reset();
|
||||||
|
obj.clear({silent: true});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Backbone.Collection.prototype.reset.apply(obj, {silent: true});
|
||||||
|
delete obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.clear({silent: true});
|
||||||
|
},
|
||||||
sessChanged: function() {
|
sessChanged: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@ -755,6 +785,20 @@ function(_, pgAdmin, $, Backbone) {
|
|||||||
return (_.size(res) == 0 ? null : res);
|
return (_.size(res) == 0 ? null : res);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// Override the reset function, so that - we can reset the model
|
||||||
|
// properly.
|
||||||
|
reset: function(opts) {
|
||||||
|
this.each(function(m) {
|
||||||
|
if (!m)
|
||||||
|
return;
|
||||||
|
if (m instanceof pgBrowser.DataModel) {
|
||||||
|
m.reset();
|
||||||
|
} else {
|
||||||
|
m.clear({silent: true});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Backbone.Collection.prototype.reset.apply(this, arguments);
|
||||||
|
},
|
||||||
objFindInSession: function(m, type) {
|
objFindInSession: function(m, type) {
|
||||||
var hasPrimaryKey = m.primary_key &&
|
var hasPrimaryKey = m.primary_key &&
|
||||||
typeof(m.primary_key) == 'function',
|
typeof(m.primary_key) == 'function',
|
||||||
|
@ -67,16 +67,20 @@ function($, _, S, pgAdmin, Backbone, Alertify, Backform) {
|
|||||||
gridView = {
|
gridView = {
|
||||||
'remove': function() {
|
'remove': function() {
|
||||||
if (this.grid) {
|
if (this.grid) {
|
||||||
|
if (this.grid.collection) {
|
||||||
|
this.grid.collection.reset(null, {silent: true});
|
||||||
|
delete (this.grid.collection);
|
||||||
|
}
|
||||||
delete (this.grid);
|
delete (this.grid);
|
||||||
this.grid = null;
|
this.grid = null;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
grid: grid
|
||||||
};
|
};
|
||||||
gridView.grid = grid;
|
|
||||||
|
|
||||||
if (view) {
|
if (view) {
|
||||||
// Release the view
|
// Release the view
|
||||||
view.remove();
|
view.remove({data: true});
|
||||||
// Deallocate the view
|
// Deallocate the view
|
||||||
delete view;
|
delete view;
|
||||||
view = null;
|
view = null;
|
||||||
|
@ -652,7 +652,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
|
|||||||
// creating new view.
|
// creating new view.
|
||||||
if (view) {
|
if (view) {
|
||||||
// Release the view
|
// Release the view
|
||||||
view.remove();
|
view.remove({data: true});
|
||||||
// Deallocate the view
|
// Deallocate the view
|
||||||
delete view;
|
delete view;
|
||||||
view = null;
|
view = null;
|
||||||
@ -773,7 +773,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
|
|||||||
// creating the new view.
|
// creating the new view.
|
||||||
if (view) {
|
if (view) {
|
||||||
// Release the view
|
// Release the view
|
||||||
view.remove();
|
view.remove({data: true});
|
||||||
// Deallocate the view
|
// Deallocate the view
|
||||||
delete view;
|
delete view;
|
||||||
view = null;
|
view = null;
|
||||||
@ -1143,6 +1143,17 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
|
|||||||
properties();
|
properties();
|
||||||
onEdit = editInNewPanel.bind(panel);
|
onEdit = editInNewPanel.bind(panel);
|
||||||
}
|
}
|
||||||
|
if (panel.closeable()) {
|
||||||
|
var onCloseFunc = function() {
|
||||||
|
var j = this.$container.find('.obj_properties').first(),
|
||||||
|
view = j && j.data('obj-view');
|
||||||
|
|
||||||
|
if (view) {
|
||||||
|
view.remove({data: true});
|
||||||
|
}
|
||||||
|
}.bind(panel);
|
||||||
|
panel.on(wcDocker.EVENT.CLOSED, onCloseFunc);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Generate the URL for different operations
|
* Generate the URL for different operations
|
||||||
|
@ -594,6 +594,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
},
|
||||||
|
remove: function(opts) {
|
||||||
|
if (opts && opts.data) {
|
||||||
|
if (this.model) {
|
||||||
|
if (this.model.reset) {
|
||||||
|
this.model.reset();
|
||||||
|
}
|
||||||
|
this.model.clear({silent: true});
|
||||||
|
delete (this.model);
|
||||||
|
}
|
||||||
|
if (this.errorModel) {
|
||||||
|
this.errorModel.clear({silent: true});
|
||||||
|
delete (this.errorModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.cleanup();
|
||||||
|
Backform.Form.prototype.remove.apply(this, arguments);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user