Enable proper actions on both organisations and contacts when expanding an organisation

This commit is contained in:
Nathan Gray 2015-03-10 15:41:53 +00:00
parent 60f1ca4033
commit aa5564d569
2 changed files with 81 additions and 73 deletions

View File

@ -141,7 +141,7 @@ class addressbook_ui extends addressbook_bo
{ {
$msg = lang('You need to select some contacts first'); $msg = lang('You need to select some contacts first');
} }
elseif ($content['nm']['action'] == 'view') // org-view via context menu elseif ($content['nm']['action'] == 'view_org') // org-view via context menu
{ {
$content['nm']['org_view'] = array_shift($content['nm']['selected']); $content['nm']['org_view'] = array_shift($content['nm']['selected']);
} }
@ -360,83 +360,89 @@ class addressbook_ui extends addressbook_bo
*/ */
public function get_actions($tid_filter=null, $org_view=null) public function get_actions($tid_filter=null, $org_view=null)
{ {
// we have no org view (view of one org has context menu like regular "add contacts" view, as it shows contacts // Contact view
if (!isset($this->org_views[(string) $org_view])) $actions = array(
{ 'view' => array(
$actions = array( 'caption' => 'CRM-View',
'view' => array( 'default' => $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list'] != '~edit~',
'caption' => 'CRM-View', 'allowOnMultiple' => false,
'default' => $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list'] != '~edit~', 'group' => $group=1,
'allowOnMultiple' => false, 'onExecute' => 'javaScript:app.addressbook.view',
'group' => $group=1, 'disableClass' => 'contact_organisation',
'onExecute' => 'javaScript:app.addressbook.view', 'hideOnDisabled' => true,
// Children added below // Children added below
'children' => array() 'children' => array()
), ),
'open' => array( 'open' => array(
'caption' => 'Open', 'caption' => 'Open',
'default' => $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list'] == '~edit~', 'default' => $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list'] == '~edit~',
'allowOnMultiple' => false, 'allowOnMultiple' => false,
'url' => 'menuaction=addressbook.addressbook_ui.edit&contact_id=$id', 'disableClass' => 'contact_organisation',
'popup' => egw_link::get_registry('addressbook', 'edit_popup'), 'hideOnDisabled' => true,
'group' => $group, 'url' => 'menuaction=addressbook.addressbook_ui.edit&contact_id=$id',
), 'popup' => egw_link::get_registry('addressbook', 'edit_popup'),
'add' => array( 'group' => $group,
'caption' => 'Add', ),
'group' => $group, 'add' => array(
'children' => array( 'caption' => 'Add',
'new' => array( 'group' => $group,
'caption' => 'New', 'disableClass' => 'contact_organisation',
'url' => 'menuaction=addressbook.addressbook_ui.edit', 'hideOnDisabled' => true,
'popup' => egw_link::get_registry('addressbook', 'add_popup'), 'children' => array(
'icon' => 'new', 'new' => array(
), 'caption' => 'New',
'copy' => array( 'url' => 'menuaction=addressbook.addressbook_ui.edit',
'caption' => 'Copy', 'popup' => egw_link::get_registry('addressbook', 'add_popup'),
'url' => 'menuaction=addressbook.addressbook_ui.edit&makecp=1&contact_id=$id', 'icon' => 'new',
'popup' => egw_link::get_registry('addressbook', 'add_popup'), ),
'allowOnMultiple' => false, 'copy' => array(
'icon' => 'copy', 'caption' => 'Copy',
), 'url' => 'menuaction=addressbook.addressbook_ui.edit&makecp=1&contact_id=$id',
'popup' => egw_link::get_registry('addressbook', 'add_popup'),
'allowOnMultiple' => false,
'icon' => 'copy',
), ),
), ),
); ),
// CRM view options );
$crm_count = 0; // CRM view options
$crm_apps = array('infolog','tracker'); $crm_count = 0;
$crm_apps = array('infolog','tracker');
foreach($crm_apps as $app)
{
if ($GLOBALS['egw_info']['user']['apps'][$app]) $crm_count++;
}
if($crm_count > 1)
{
foreach($crm_apps as $app) foreach($crm_apps as $app)
{ {
if ($GLOBALS['egw_info']['user']['apps'][$app]) $crm_count++; $actions['view']['children']["view-$app"] = array(
} 'caption' => $app,
if($crm_count > 1) 'icon' => "$app/navbar"
{ );
foreach($crm_apps as $app)
{
$actions['view']['children']["view-$app"] = array(
'caption' => $app,
'icon' => "$app/navbar"
);
}
} }
} }
else // org view
{ // org view
$actions = array( $actions += array(
'view' => array( 'view_org' => array(
'caption' => 'View', 'caption' => 'View',
'default' => true, 'default' => true,
'allowOnMultiple' => false, 'allowOnMultiple' => false,
'group' => $group=1, 'group' => $group=1,
), 'disableClass' => 'contact_contact',
'add' => array( 'hideOnDisabled' => true
'caption' => 'Add', ),
'group' => $group, 'add_org' => array(
'allowOnMultiple' => false, 'caption' => 'Add',
'url' => 'menuaction=addressbook.addressbook_ui.edit&org=$id', 'group' => $group,
'popup' => egw_link::get_registry('addressbook', 'add_popup'), 'allowOnMultiple' => false,
), 'disableClass' => 'contact_contact',
); 'hideOnDisabled' => true,
} 'url' => 'menuaction=addressbook.addressbook_ui.edit&org=$id',
'popup' => egw_link::get_registry('addressbook', 'add_popup'),
),
);
++$group; // other AB related stuff group: lists, AB's, categories ++$group; // other AB related stuff group: lists, AB's, categories
// categories submenu // categories submenu
@ -1612,6 +1618,7 @@ window.egw_LAB.wait(function() {
$row['class'] .= 'rowNoDelete '; $row['class'] .= 'rowNoDelete ';
} }
$row['class'] .= 'rowNoEdit '; // no edit in OrgView $row['class'] .= 'rowNoEdit '; // no edit in OrgView
$row['class'] .= 'contact_organisation ';
} }
else else
{ {
@ -1645,6 +1652,7 @@ window.egw_LAB.wait(function() {
{ {
$row['class'] .= 'rowNoEdit '; $row['class'] .= 'rowNoEdit ';
} }
$row['class'] .= 'contact_contact ';
unset($row['jpegphoto']); // unused and messes up json encoding (not utf-8) unset($row['jpegphoto']); // unused and messes up json encoding (not utf-8)

View File

@ -32,7 +32,7 @@
<nextmatch-header label="Home email" id="email_home"/> <nextmatch-header label="Home email" id="email_home"/>
</vbox> </vbox>
</row> </row>
<row class="row" valign="top"> <row class="$row_cont[cat_id] $row_cont[class]" valign="top">
<image label="$row_cont[type_label]" src="${row}[type]" align="center" no_lang="1"/> <image label="$row_cont[type_label]" src="${row}[type]" align="center" no_lang="1"/>
<int id="${row}[org_count]" readonly="true" align="center"/> <int id="${row}[org_count]" readonly="true" align="center"/>
<vbox> <vbox>