mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2026-01-04 20:34:37 +00:00
data/DiffStore: add autoDestroyRstore flag
when this flag is set, the diffstore will automatically try to destroy the rstore when it is destroyed itself for this we have to move the rstore into the object (instead of using a closure) Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
86811eaa27
commit
65277f6a2e
@ -24,6 +24,20 @@ Ext.define('Proxmox.data.DiffStore', {
|
||||
|
||||
sortAfterUpdate: false,
|
||||
|
||||
// if set to true, destroy rstore on destruction
|
||||
autoDestroyRstore: false,
|
||||
|
||||
onDestroy: function() {
|
||||
let me = this;
|
||||
if (me.autoDestroyRstore) {
|
||||
if (Ext.isFunction(me.rstore.destroy)) {
|
||||
me.rstore.destroy();
|
||||
}
|
||||
delete me.rstore;
|
||||
}
|
||||
me.callParent();
|
||||
},
|
||||
|
||||
constructor: function(config) {
|
||||
var me = this;
|
||||
|
||||
@ -46,6 +60,8 @@ Ext.define('Proxmox.data.DiffStore', {
|
||||
|
||||
me.callParent([config]);
|
||||
|
||||
me.rstore = rstore;
|
||||
|
||||
var first_load = true;
|
||||
|
||||
var cond_add_item = function(data, id) {
|
||||
@ -80,13 +96,13 @@ Ext.define('Proxmox.data.DiffStore', {
|
||||
|
||||
// remove vanished items
|
||||
allItems.each(function(olditem) {
|
||||
var item = rstore.getById(olditem.getId());
|
||||
var item = me.rstore.getById(olditem.getId());
|
||||
if (!item) {
|
||||
me.remove(olditem);
|
||||
}
|
||||
});
|
||||
|
||||
rstore.each(function(item) {
|
||||
me.rstore.each(function(item) {
|
||||
cond_add_item(item.data, item.getId());
|
||||
});
|
||||
|
||||
@ -103,12 +119,12 @@ Ext.define('Proxmox.data.DiffStore', {
|
||||
me.fireEvent('datachanged', me);
|
||||
};
|
||||
|
||||
if (rstore.isLoaded()) {
|
||||
if (me.rstore.isLoaded()) {
|
||||
// if store is already loaded,
|
||||
// insert items instantly
|
||||
loadFn(rstore, [], true);
|
||||
loadFn(me.rstore, [], true);
|
||||
}
|
||||
|
||||
me.mon(rstore, 'load', loadFn);
|
||||
me.mon(me.rstore, 'load', loadFn);
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user