From 232232133c34a4645216153db03245ea71d8e107 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 1 Jan 2014 20:06:03 -0800 Subject: [PATCH] CRM-13863 - Ajax-enable contact actions/activity list --- CRM/Contact/BAO/Contact.php | 8 +++---- CRM/Contact/Page/View/Summary.php | 10 ++++---- CRM/Tag/Form/Tag.php | 3 +++ css/civicrm.css | 6 ++--- js/Common.js | 11 +++++++-- js/crm.livePage.js | 4 ++-- templates/CRM/Activity/Form/ActivityLinks.tpl | 20 ++++++++++++++-- templates/CRM/Contact/Form/Relationship.tpl | 4 ++-- templates/CRM/Contact/Page/Inline/Actions.tpl | 17 ++----------- templates/CRM/Contact/Page/View/Summary.js | 24 ++++++++++++++++++- templates/CRM/Member/Form/Task/Label.js | 9 ++----- templates/CRM/Tag/Form/Tag.tpl | 2 +- templates/CRM/common/TabHeader.js | 6 ++--- 13 files changed, 77 insertions(+), 47 deletions(-) diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 83f791a099..18f240f80f 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -2725,10 +2725,10 @@ AND civicrm_openid.is_primary = 1"; 'key' => 'delete', 'permissions' => array('access deleted contacts', 'delete contacts'), ), - 'contribution' => array('title' => ts('Add Contribution'), + 'contribute' => array('title' => ts('Add Contribution'), 'weight' => 5, 'ref' => 'new-contribution', - 'key' => 'contribution', + 'key' => 'contribute', 'component' => 'CiviContribute', 'href' => CRM_Utils_System::url('civicrm/contact/view/contribution', 'reset=1&action=add&context=contribution' @@ -2768,10 +2768,10 @@ AND civicrm_openid.is_primary = 1"; 'edit pledges', ), ), - 'membership' => array('title' => ts('Add Membership'), + 'member' => array('title' => ts('Add Membership'), 'weight' => 20, 'ref' => 'new-membership', - 'key' => 'membership', + 'key' => 'member', 'component' => 'CiviMember', 'href' => CRM_Utils_System::url('civicrm/contact/view/membership', 'reset=1&action=add&context=membership' diff --git a/CRM/Contact/Page/View/Summary.php b/CRM/Contact/Page/View/Summary.php index f0a5f44ec2..ad287fdec1 100644 --- a/CRM/Contact/Page/View/Summary.php +++ b/CRM/Contact/Page/View/Summary.php @@ -132,7 +132,7 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { * @access public */ function view() { - // Add js for in-place editing and jstree for tags + // Add js for tabs, in-place editing, and jstree for tags CRM_Core_Resources::singleton() ->addScriptFile('civicrm', 'templates/CRM/Contact/Page/View/Summary.js') ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE) @@ -330,7 +330,8 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { 'title' => $elem['title'], 'weight' => $elem['weight'], 'count' => CRM_Contact_BAO_Contact::getCountComponent($u, $this->_contactId), - 'class' => 'livePage', + // CiviCase UI not yet compatible with livePage popups + 'class' => $u == 'case' ? '' : 'livePage', ); // make sure to get maximum weight, rest of tabs go after // FIXME: not very elegant again @@ -343,12 +344,11 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { $rest = array( 'activity' => array( 'title' => ts('Activities'), - ), - 'case' => array( - 'title' => ts('Cases'), + 'class' => 'livePage', ), 'rel' => array( 'title' => ts('Relationships'), + 'class' => 'livePage', ), 'group' => array( 'title' => ts('Groups'), diff --git a/CRM/Tag/Form/Tag.php b/CRM/Tag/Form/Tag.php index 19ce7e0a22..ecf53180fa 100644 --- a/CRM/Tag/Form/Tag.php +++ b/CRM/Tag/Form/Tag.php @@ -72,6 +72,9 @@ class CRM_Tag_Form_Tag extends CRM_Core_Form { * @access public */ public function buildQuickForm() { + CRM_Core_Resources::singleton() + ->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'); // get categories for the contact id $entityTag = CRM_Core_BAO_EntityTag::getTag($this->_entityID, $this->_entityTable); $this->assign('tagged', $entityTag); diff --git a/css/civicrm.css b/css/civicrm.css index d5ae236bf9..5408d0b449 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -2257,13 +2257,13 @@ div.grippie { /* crm button style */ -#crm-container .crm-submit-buttons, -#crm-container .action-link { +.crm-container .crm-submit-buttons, +.crm-container .action-link { height: 27px; margin: 4px 0px 4px 2px; } -#crm-container .register_link-top { +.crm-container .register_link-top { float: right; margin-left: 8px; } diff --git a/js/Common.js b/js/Common.js index 274371ccda..52f9c92faf 100644 --- a/js/Common.js +++ b/js/Common.js @@ -809,7 +809,7 @@ CRM.validate = CRM.validate || { }); } - $.widget('civicrm.crmSnippet', { + $.widget('civi.crmSnippet', { options: { url: null, block: true, @@ -941,7 +941,7 @@ CRM.validate = CRM.validate || { validate: true, refreshAction: ['next_new', 'submit_savenext'], cancelButton: '.cancel.form-submit', - openInline: 'a.button:not([href="#"])', + openInline: 'a.button:not("[href=#], .no-popup")', onCancel: function(event) {}, onError: function(data) { var $el = $(this); @@ -1008,6 +1008,13 @@ CRM.validate = CRM.validate || { settings.onError.call($el, response); } }, + beforeSerialize: function(form, options) { + if (window.CKEDITOR && window.CKEDITOR.instances) { + for (var instance in CKEDITOR.instances) { + CKEDITOR.instances[instance].updateElement(); + } + } + }, beforeSubmit: function(submission) { $el.crmSnippet('option', 'block') && $el.block(); $el.trigger('crmFormSubmit', submission); diff --git a/js/crm.livePage.js b/js/crm.livePage.js index 2d01bef689..4d241ef88e 100644 --- a/js/crm.livePage.js +++ b/js/crm.livePage.js @@ -8,11 +8,11 @@ cj(function($) { .off('click.crmLivePage') .on('click.crmLivePage', 'a.button, a.action-item', function() { // only follow real links not javascript buttons - if ($(this).attr('href') === '#' || $(this).attr('onclick')) { + if ($(this).attr('href') === '#' || $(this).attr('onclick') || $(this).hasClass('no-popup')) { return; } CRM.loadForm($(this).attr('href'), { - openInline: 'a:not([href="#"])' + openInline: 'a:not("[href=#], .no-popup")' }).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 879587ce13..d416981496 100644 --- a/templates/CRM/Activity/Form/ActivityLinks.tpl +++ b/templates/CRM/Activity/Form/ActivityLinks.tpl @@ -30,13 +30,29 @@ {/if} {if $as_select} {* on 3.2, the activities can be either a drop down select (on the activity tab) or a list (on the action menu) *} - {foreach from=$activityTypes key=k item=link} {/foreach} - +{literal} + +{/literal} {else}