*/
static function contextMenu($contactId = NULL) {
$menu = array(
- 'view' => array('title' => ts('View Contact'),
+ 'view' => array(
+ 'title' => ts('View Contact'),
'weight' => 0,
'ref' => 'view-contact',
+ 'class' => 'no-popup',
'key' => 'view',
'permissions' => array('view all contacts'),
),
- 'add' => array('title' => ts('Edit Contact'),
+ 'add' => array(
+ 'title' => ts('Edit Contact'),
'weight' => 0,
'ref' => 'edit-contact',
+ 'class' => 'no-popup',
'key' => 'add',
'permissions' => array('edit all contacts'),
),
- 'delete' => array('title' => ts('Delete Contact'),
+ 'delete' => array(
+ 'title' => ts('Delete Contact'),
'weight' => 0,
'ref' => 'delete-contact',
'key' => 'delete',
'permissions' => array('access deleted contacts', 'delete contacts'),
),
- 'contribute' => array('title' => ts('Add Contribution'),
+ 'contribution' => array(
+ 'title' => ts('Add Contribution'),
'weight' => 5,
'ref' => 'new-contribution',
- 'key' => 'contribute',
+ 'key' => 'contribution',
+ 'tab' => 'contribute',
'component' => 'CiviContribute',
'href' => CRM_Utils_System::url('civicrm/contact/view/contribution',
'reset=1&action=add&context=contribution'
'edit contributions',
),
),
- 'participant' => array('title' => ts('Register for Event'),
+ 'participant' => array(
+ 'title' => ts('Register for Event'),
'weight' => 10,
'ref' => 'new-participant',
'key' => 'participant',
+ 'tab' => 'participant',
'component' => 'CiviEvent',
'href' => CRM_Utils_System::url('civicrm/contact/view/participant', 'reset=1&action=add&context=participant'),
'permissions' => array(
'edit event participants',
),
),
- 'activity' => array('title' => ts('Record Activity'),
+ 'activity' => array(
+ 'title' => ts('Record Activity'),
'weight' => 35,
'ref' => 'new-activity',
'key' => 'activity',
+ 'tab' => 'activity',
'permissions' => array('edit all contacts'),
),
- 'pledge' => array('title' => ts('Add Pledge'),
+ 'pledge' => array(
+ 'title' => ts('Add Pledge'),
'weight' => 15,
'ref' => 'new-pledge',
'key' => 'pledge',
+ 'tab' => 'pledge',
'href' => CRM_Utils_System::url('civicrm/contact/view/pledge',
'reset=1&action=add&context=pledge'
),
'edit pledges',
),
),
- 'member' => array('title' => ts('Add Membership'),
+ 'membership' => array(
+ 'title' => ts('Add Membership'),
'weight' => 20,
'ref' => 'new-membership',
- 'key' => 'member',
+ 'key' => 'membership',
+ 'tab' => 'member',
'component' => 'CiviMember',
'href' => CRM_Utils_System::url('civicrm/contact/view/membership',
'reset=1&action=add&context=membership'
'edit memberships',
),
),
- 'case' => array('title' => ts('Add Case'),
+ 'case' => array(
+ 'title' => ts('Add Case'),
'weight' => 25,
'ref' => 'new-case',
'key' => 'case',
+ 'tab' => 'case',
'component' => 'CiviCase',
'href' => CRM_Utils_System::url('civicrm/case/add', 'reset=1&action=add&context=case'),
'permissions' => array('add cases'),
),
- 'grant' => array('title' => ts('Add Grant'),
+ 'grant' => array(
+ 'title' => ts('Add Grant'),
'weight' => 26,
'ref' => 'new-grant',
'key' => 'grant',
+ 'tab' => 'grant',
'component' => 'CiviGrant',
'href' => CRM_Utils_System::url('civicrm/contact/view/grant',
'reset=1&action=add&context=grant'
),
'permissions' => array('edit grants'),
),
- 'rel' => array('title' => ts('Add Relationship'),
+ 'rel' => array(
+ 'title' => ts('Add Relationship'),
'weight' => 30,
'ref' => 'new-relationship',
'key' => 'rel',
+ 'tab' => 'rel',
'href' => CRM_Utils_System::url('civicrm/contact/view/rel',
'reset=1&action=add'
),
'permissions' => array('edit all contacts'),
),
- 'note' => array('title' => ts('Add Note'),
+ 'note' => array(
+ 'title' => ts('Add Note'),
'weight' => 40,
'ref' => 'new-note',
'key' => 'note',
+ 'tab' => 'note',
'href' => CRM_Utils_System::url('civicrm/contact/view/note',
'reset=1&action=add'
),
'permissions' => array('edit all contacts'),
),
- 'email' => array('title' => ts('Send an Email'),
+ 'email' => array(
+ 'title' => ts('Send an Email'),
'weight' => 45,
'ref' => 'new-email',
'key' => 'email',
'permissions' => array('view all contacts'),
),
- 'group' => array('title' => ts('Add to Group'),
+ 'group' => array(
+ 'title' => ts('Add to Group'),
'weight' => 50,
'ref' => 'group-add-contact',
'key' => 'group',
+ 'tab' => 'group',
'permissions' => array('edit groups'),
),
- 'tag' => array('title' => ts('Tag'),
+ 'tag' => array(
+ 'title' => ts('Tag Contact'),
'weight' => 55,
'ref' => 'tag-contact',
'key' => 'tag',
+ 'tab' => 'tag',
'permissions' => array('edit all contacts'),
),
);
$contextMenu['primaryActions'][$key] = array(
'title' => $values['title'],
'ref' => $values['ref'],
+ 'class' => CRM_Utils_Array::value('class', $values),
'key' => $values['key'],
);
continue;
'title' => $values['title'],
'ref' => $values['ref'],
'href' => CRM_Utils_Array::value('href', $values),
+ 'tab' => CRM_Utils_Array::value('tab', $values),
+ 'class' => CRM_Utils_Array::value('class', $values),
'key' => $values['key'],
);
}
* @return void
*/
function buildQuickForm() {
- CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
+ CRM_Core_Resources::singleton()
+ ->addScriptFile('civicrm', 'js/crm.livePage.js')
+ // jsTree is needed for tags popup
+ ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
+ ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
$permission = CRM_Core_Permission::getPermission();
// some tasks.. what do we want to do with the selected contacts ?
$tasks = array('' => ts('- actions -'));
CRM_Core_Action::VIEW => array(
'name' => ts('View'),
'url' => 'civicrm/contact/view',
+ 'class' => 'no-popup',
'qs' => "reset=1&cid=%%id%%{$searchContext}{$extraParams}",
'title' => ts('View Contact Details'),
'ref' => 'view-contact',
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/contact/add',
+ 'class' => 'no-popup',
'qs' => "reset=1&action=update&cid=%%id%%{$searchContext}{$extraParams}",
'title' => ts('Edit Contact Details'),
'ref' => 'edit-contact',
if ($value['key'] == 'delete') {
$contextVal = $searchContext;
}
-
$url = "civicrm/contact/view/{$value['key']}";
$qs = "reset=1&action=add&cid=%%id%%{$contextVal}{$extraParams}";
if ($value['key'] == 'activity') {
'qs' => $qs,
'title' => $value['title'],
'ref' => $value['ref'],
+ 'class' => CRM_Utils_Array::value('class', $value),
);
}
}
'name' => ts('View'),
'url' => 'civicrm/contact/view',
'qs' => 'reset=1&cid=%%id%%',
+ 'class' => 'no-popup',
'title' => ts('View Contact Details'),
),
array(
// Open action links in a popup
.off('click.crmLivePage')
.on('click.crmLivePage', 'a.button, a.action-item', function() {
+ var
+ dialogSettings = {},
+ url = $(this).attr('href');
// only follow real links not javascript buttons
- if ($(this).attr('href') === '#' || $(this).attr('onclick') || $(this).hasClass('no-popup')) {
+ if (url === '#' || $(this).attr('onclick') || $(this).hasClass('no-popup')) {
return;
}
- CRM.loadForm($(this).attr('href'), {
- openInline: 'a:not("[href=#], .no-popup")'
+ // Hack to make delete dialogs smaller
+ if (url.indexOf('/delete') > 0 || url.indexOf('action=delete') > 0) {
+ dialogSettings.width = 400;
+ dialogSettings.height = 300;
+ }
+ CRM.loadForm(url, {
+ openInline: 'a:not("[href=#], .no-popup")',
+ dialog: dialogSettings
}).on('crmFormSuccess', function(e, data) {
// Refresh page when form completes
$('#crm-main-content-wrapper').crmSnippet('refresh');
{else}
<ul>
{foreach from=$activityTypes key=k item=link}
-<li class="crm-activity-type_{$k}"><a href="{$urls.$k}">{$link}</a></li>
+<li class="crm-activity-type_{$k}"><a href="{$urls.$k}" data-tab="activity">{$link}</a></li>
{/foreach}
{* add hook links if any *}
{if $hookLinks}
{foreach from=$hookLinks item=link}
<li>
- <a href="{$link.url}"{if $link.title} title="{$link.title}"{/if}>
+ <a href="{$link.url}" data-tab="activity"{if !empty($link.title)} title="{$link.title}"{/if}>
{if $link.img}
<img src="{$link.img}" alt="{$link.title}" />
{/if}
<div class="crm-contact_actions-list">
<ul class="contact-actions">
{foreach from=$actionsMenuList.moreActions item='row'}
- {if $row.href}
+ {if !empty($row.href) or !empty($row.tab)}
<li class="crm-action-{$row.ref}">
- <a href="{$row.href}&cid={$contactId}" title="{$row.title}" data-tab="{$row.key}">{$row.title}</a>
+ <a href="{if !empty($row.href)}{$row.href}&cid={$contactId}{else}#{/if}" title="{$row.title}" data-tab="{$row.tab}">{$row.title}</a>
</li>
{/if}
{/foreach}
CRM.tabHeader.updateCount('#tab_log', response.changeLog.count);
}
$("#crm-record-log").replaceWith(response.changeLog.markup);
- // Refresh tab contents - Simple
+ // Refresh tab contents - Simple logging
if (!CRM.reloadChangeLogTab && $('#changeLog').closest('.ui-tabs-panel').data('civiCrmSnippet')) {
$('#changeLog').closest('.ui-tabs-panel').crmSnippet('destroy');
}
})
// Handle action links in popup
.on('click', '.crm-contact_actions-list a, .crm-contact_activities-list a', function() {
- var tabName = $(this).data('tab') || 'activity';
+ var tabName = $(this).data('tab') || 'summary';
var $tab = $('#tab_' + tabName);
var $panel = $('#' + $tab.attr('aria-controls'));
- CRM.loadForm($(this).attr('href'))
- .on('crmFormSuccess', function() {
- if ($panel.data('civiCrmSnippet')) {
- $panel.crmSnippet('refresh');
- }
- $('#mainTabContainer').tabs('option', 'active', $tab.prevAll().length);
- });
+ var url = $(this).attr('href');
+ if (url !== '#') {
+ CRM.loadForm(url)
+ .on('crmFormSuccess', function() {
+ if ($panel.data('civiCrmSnippet')) {
+ $panel.crmSnippet('refresh');
+ }
+ $('#mainTabContainer').tabs('option', 'active', $tab.prevAll().length);
+ });
+ } else {
+ $('#mainTabContainer').tabs('option', 'active', $tab.prevAll().length);
+ }
+ $('#crm-contact-actions-list').hide();
return false;
});
$(document)
}
$('#crm-contact-actions-list').hide();
})
+ // Reload changelog whenever an inline or popup form submits
.on('crmFormSuccess', function(e) {
CRM.reloadChangeLogTab && CRM.reloadChangeLogTab();
});
$('.tag-section .token-input-token-facebook p, #tagtree input:checkbox:checked+label').each(function() {
tags.push($(this).text());
});
- // showing count of tags in summary tab
- CRM.tabHeader && CRM.tabHeader.updateCount('#tab_tag', tags.length);
- CRM.reloadChangeLogTab && CRM.reloadChangeLogTab();
+ // contact summary tabs and search forms both listen for this event
+ $('#Tag').closest('.crm-ajax-container').trigger('crmFormSuccess', {tabCount: tags.length});
// update summary tab
- $("#tags").html(tags.join(', '));
+ $("#contact-summary #tags").html(tags.join(', '));
};
})(cj);
{/literal}
ui.panel
.off('click.crmLivePage')
.on('click.crmLivePage', 'a.button, a.action-item', function() {
+ var
+ dialogSettings = {},
+ url = $(this).attr('href');
// only follow real links not javascript buttons
- if ($(this).attr('href') === '#' || $(this).attr('onclick') || $(this).hasClass('no-popup')) {
+ if (url === '#' || $(this).attr('onclick') || $(this).hasClass('no-popup')) {
return;
}
- CRM.loadForm($(this).attr('href'), {
- openInline: 'a:not("[href=#], .no-popup")'
+ // Hack to make delete dialogs smaller
+ if (url.indexOf('/delete') > 0 || url.indexOf('action=delete') > 0) {
+ dialogSettings.width = 400;
+ dialogSettings.height = 300;
+ }
+ CRM.loadForm(url, {
+ openInline: 'a:not("[href=#], .no-popup")',
+ dialog: dialogSettings
}).on('crmFormSuccess', function(e, data) {
// Refresh when form completes
ui.panel.crmSnippet('refresh');