Admin: Push for categories

This commit is contained in:
nathan 2022-10-27 11:13:04 -06:00
parent ce5e30dc4c
commit 166168b5bf
4 changed files with 58 additions and 10 deletions

View File

@ -74,9 +74,16 @@ class admin_cmd_customfield extends admin_cmd
if(array_keys($this->set) == array('id','name'))
{
// Delete
$so = new Api\Storage\Base('phpgwapi','egw_customfields',null,'',true);
$so = new Api\Storage\Base('phpgwapi', 'egw_customfields', null, '', true);
$so->delete($this->set['id']);
$deleted = true;
$push = new Api\Json\Push(Api\Json\Push::ALL);
$push->apply("egw.push", [[
'app' => Api\Storage\Customfields::PUSH_APP,
'id' => $this->set['id'],
'type' => 'delete'
]]);
}
else
{

View File

@ -212,7 +212,8 @@ class admin_customfields
'row_id' => 'cf_id',
'order' => 'cf_order',// IO name of the column to sort
'sort' => 'ASC',// IO direction of the sort: 'ASC' or 'DESC'
'actions' => $this->get_actions()
'actions' => $this->get_actions(),
'dataStorePrefix' => 'customfield'
);
}
$content['nm']['appname'] = $this->appname;

View File

@ -326,12 +326,13 @@ class AdminApp extends EgwApp
push(pushData : PushData)
{
// Filter out what we're not interested in
if([this.appname, "api-cats"].indexOf(pushData.app) == -1)
if([this.appname, "api-cats", "api-cf"].indexOf(pushData.app) == -1)
{
return;
}
const cat_template = "admin.categories.index";
const cf_template = "admin.customfields";
if(this.appname.indexOf(pushData.app) != -1 && pushData.id > 0)
{
@ -349,6 +350,10 @@ class AdminApp extends EgwApp
{
(<et2_nextmatch>etemplate2.getByTemplate(cat_template)[0].widgetContainer.getWidgetById("nm")).refresh(pushData.id, pushData.type);
}
else if(pushData.app == "api-cf" && etemplate2.getByTemplate(cf_template).length == 1)
{
(<et2_nextmatch>etemplate2.getByTemplate(cf_template)[0].widgetContainer.getWidgetById("nm")).refresh(pushData.id, pushData.type);
}
}
/**

View File

@ -13,6 +13,7 @@
namespace EGroupware\Api\Storage;
use EGroupware\Api;
use EGroupware\Api\Json\Push;
/**
* Managing custom-field definitions
@ -51,6 +52,11 @@ class Customfields implements \IteratorAggregate
*/
protected $iterator;
/**
* App name used to push custom field changes
*/
const PUSH_APP = 'api-cf';
/**
* Constructor
*
@ -441,6 +447,35 @@ class Customfields implements \IteratorAggregate
}
self::invalidate_cache($cf['app']);
// push category change
$type = 'update';
if(!$cf['id'])
{
$cfs = self::get($cf['app'], true);
$cf = $cfs[$cf['name']];
$type = 'add';
}
$accounts = Push::ALL;
if(count($cf['private']) > 0)
{
$accounts = [];
foreach($cf['private'] as $account_id)
{
$accounts = array_merge(
$account_id > 0 ? [$account_id] :
$GLOBALS['egw']->accounts->members($account_id, true)
);
}
}
$push = new Push($accounts);
$push->apply("egw.push", [[
'app' => self::PUSH_APP,
'id' => $cf['id'],
'type' => $type,
'acl' => ['private' => $cf['private']],
'account_id' => $GLOBALS['egw_info']['user']['account_id']
]]);
}
/**