From: Coleman Watts Date: Thu, 9 Jan 2014 02:16:42 +0000 (-0800) Subject: CRM-12872 - Fine-tune popup links on search forms X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8e4ec1f531bf4f00d4563f705d91eab7c61a5022;p=civicrm-core.git CRM-12872 - Fine-tune popup links on search forms --- diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 18f240f80f..f34b6e378d 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -2707,28 +2707,35 @@ AND civicrm_openid.is_primary = 1"; */ 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' @@ -2738,10 +2745,12 @@ AND civicrm_openid.is_primary = 1"; '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( @@ -2749,16 +2758,20 @@ AND civicrm_openid.is_primary = 1"; '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' ), @@ -2768,10 +2781,12 @@ AND civicrm_openid.is_primary = 1"; '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' @@ -2781,58 +2796,71 @@ AND civicrm_openid.is_primary = 1"; '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'), ), ); @@ -2907,6 +2935,7 @@ AND civicrm_openid.is_primary = 1"; $contextMenu['primaryActions'][$key] = array( 'title' => $values['title'], 'ref' => $values['ref'], + 'class' => CRM_Utils_Array::value('class', $values), 'key' => $values['key'], ); continue; @@ -2917,6 +2946,8 @@ AND civicrm_openid.is_primary = 1"; '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'], ); } diff --git a/CRM/Contact/Form/Search.php b/CRM/Contact/Form/Search.php index 43d2de41a4..c0f2839b31 100644 --- a/CRM/Contact/Form/Search.php +++ b/CRM/Contact/Form/Search.php @@ -379,7 +379,11 @@ class CRM_Contact_Form_Search extends CRM_Core_Form { * @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 -')); diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index f3523ffe92..af660d03a5 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -236,6 +236,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se 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', @@ -243,6 +244,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se 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', @@ -267,7 +269,6 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se 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') { @@ -284,6 +285,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se 'qs' => $qs, 'title' => $value['title'], 'ref' => $value['ref'], + 'class' => CRM_Utils_Array::value('class', $value), ); } } @@ -714,6 +716,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se 'name' => ts('View'), 'url' => 'civicrm/contact/view', 'qs' => 'reset=1&cid=%%id%%', + 'class' => 'no-popup', 'title' => ts('View Contact Details'), ), array( diff --git a/js/crm.livePage.js b/js/crm.livePage.js index 4d241ef88e..9ee6d03c4c 100644 --- a/js/crm.livePage.js +++ b/js/crm.livePage.js @@ -7,12 +7,21 @@ cj(function($) { // 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'); diff --git a/templates/CRM/Activity/Form/ActivityLinks.tpl b/templates/CRM/Activity/Form/ActivityLinks.tpl index d416981496..f48e17b61b 100644 --- a/templates/CRM/Activity/Form/ActivityLinks.tpl +++ b/templates/CRM/Activity/Form/ActivityLinks.tpl @@ -56,14 +56,14 @@ {else}