forked from extern/egroupware
activating observer for admin instead of app_refresh and using it to invalidate client-side account-cache
This commit is contained in:
parent
864c3189cc
commit
23cbc01e2c
@ -92,7 +92,7 @@ app.classes.admin = AppJS.extend(
|
||||
);
|
||||
|
||||
// Register app refresh now that iframe is available
|
||||
register_app_refresh('admin',jQuery.proxy(this.refresh,this));
|
||||
//register_app_refresh('admin',jQuery.proxy(this.refresh,this));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -138,12 +138,13 @@ app.classes.admin = AppJS.extend(
|
||||
* @param {string} _targetapp which app's window should be refreshed, default current
|
||||
* @return {false|*} false to stop regular refresh, thought all observers are run
|
||||
*/
|
||||
/* as replacement for register_app_refresh in et2_ready, would allow to retire app_refresh stuff ...
|
||||
observer: function(_msg, _app, _id, _type, _msg_type, _targetapp)
|
||||
{
|
||||
switch(_app)
|
||||
{
|
||||
case 'admin':
|
||||
// invalidate client-side account-cache
|
||||
this.egw.invalidate_account(_id, _type);
|
||||
// group deleted, added or updated
|
||||
if (_id < 0)
|
||||
{
|
||||
@ -160,7 +161,7 @@ app.classes.admin = AppJS.extend(
|
||||
}
|
||||
}
|
||||
}
|
||||
},*/
|
||||
},
|
||||
|
||||
/**
|
||||
* Special handling for egw_refresh() in admin, to refresh the iframe when
|
||||
|
@ -104,7 +104,64 @@ egw.extend('user', egw.MODULE_GLOBAL, function()
|
||||
list = list.concat(accountStore[type]);
|
||||
}
|
||||
return list;
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate client-side account cache
|
||||
*
|
||||
* For _type == "add" we invalidate the whole cache currently.
|
||||
*
|
||||
* @param {number} _id nummeric account_id, !_id will invalidate whole cache
|
||||
* @param {string} _type "add", "delete", "update" or "edit"
|
||||
*/
|
||||
invalidate_account: function(_id, _type)
|
||||
{
|
||||
if (jQuery.isEmptyObject(accountStore)) return;
|
||||
|
||||
switch(_type)
|
||||
{
|
||||
case 'delete':
|
||||
case 'edit':
|
||||
case 'update':
|
||||
if (_id)
|
||||
{
|
||||
var store = _id < 0 ? accountStore.groups : accountStore.accounts;
|
||||
for(var i=0; i < store.length; ++i)
|
||||
{
|
||||
if (_id == store[i].value)
|
||||
{
|
||||
if (_type == 'delete')
|
||||
{
|
||||
delete(store[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.link_title('home-accounts', _id, function(_label)
|
||||
{
|
||||
store[i].label = _label;
|
||||
if (_id < 0)
|
||||
{
|
||||
for(var j=0; j < accountStore.owngroups.length; ++j)
|
||||
{
|
||||
if (_id == accountStore.owngroups[j].value)
|
||||
{
|
||||
accountStore.owngroups[j].label = _label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, this, true); // true = force reload
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
// fall through
|
||||
default:
|
||||
accountStore = {};
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user