From 6ce089144e27c63f29f1ffb3279a30cc95a561db Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 18 Mar 2014 17:10:55 -0400 Subject: [PATCH] CRM-10693 HR-310 - Case ajax fixes --- CRM/Activity/Page/AJAX.php | 2 +- CRM/Case/BAO/Case.php | 4 +- CRM/Case/Form/Activity.php | 4 - CRM/Contact/Form/Task/PDFLetterCommon.php | 3 +- js/crm.livePage.js | 5 +- templates/CRM/Activity/Form/Activity.tpl | 4 - templates/CRM/Case/Form/Activity.tpl | 6 -- templates/CRM/Case/Form/CaseView.js | 82 ++++++++++++++++-- templates/CRM/Case/Form/CaseView.tpl | 101 ++++------------------ templates/CRM/Contact/Form/Task/PDF.tpl | 1 - 10 files changed, 103 insertions(+), 109 deletions(-) diff --git a/CRM/Activity/Page/AJAX.php b/CRM/Activity/Page/AJAX.php index 18d35d69a5..b3b8845324 100644 --- a/CRM/Activity/Page/AJAX.php +++ b/CRM/Activity/Page/AJAX.php @@ -256,7 +256,7 @@ class CRM_Activity_Page_AJAX { } // email column links/icon if ($caseRelationships[$key]['email']) { - $caseRelationships[$key]['email'] = ' + $caseRelationships[$key]['email'] = ' '; } // edit links diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index eaa365f106..1a8f36335f 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -1274,7 +1274,7 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type } } if ($allowDelete) { - $url .= ' ' . ts('Delete') . ''; + $url .= ' ' . ts('Delete') . ''; } } elseif (!$caseDeleted) { @@ -2231,7 +2231,7 @@ INNER JOIN civicrm_case_contact ON ( civicrm_case.id = civicrm_case_contact.cas if (!$doFilterCases || array_key_exists($dao->id, $filterCases)) { $caseViewStr = "reset=1&id={$dao->id}&cid={$dao->client_id}&action=view&context=case&selectedChild=case"; $caseViewUrl = CRM_Utils_System::url("civicrm/contact/view/case", $caseViewStr); - $caseView = "" . ts('View Case') . ""; + $caseView = "" . ts('View Case') . ""; } $clientView = $dao->client_name; if ($hasViewContact) { diff --git a/CRM/Case/Form/Activity.php b/CRM/Case/Form/Activity.php index a6f2f9f04d..c3acfbfddb 100644 --- a/CRM/Case/Form/Activity.php +++ b/CRM/Case/Form/Activity.php @@ -203,10 +203,6 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { } } - if ($this->_currentlyViewedContactId) { - CRM_Contact_Page_View::setTitle($this->_currentlyViewedContactId); - } - $session = CRM_Core_Session::singleton(); $session->pushUserContext($url); } diff --git a/CRM/Contact/Form/Task/PDFLetterCommon.php b/CRM/Contact/Form/Task/PDFLetterCommon.php index 4fe0cfb8c3..6ce25e19f7 100644 --- a/CRM/Contact/Form/Task/PDFLetterCommon.php +++ b/CRM/Contact/Form/Task/PDFLetterCommon.php @@ -58,12 +58,13 @@ class CRM_Contact_Form_Task_PDFLetterCommon { $form->assign('message', $messageText); $form->assign('messageSubject', $messageSubject); + CRM_Utils_System::setTitle('Create Printable Letters (PDF)'); } static function preProcessSingle(&$form, $cid) { $form->_contactIds = array($cid); // put contact display name in title for single contact mode - CRM_Contact_Page_View::setTitle($cid); + CRM_Utils_System::setTitle(ts('Create Printable Letter (PDF) for %1', array(1 => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name')))); } /** diff --git a/js/crm.livePage.js b/js/crm.livePage.js index ca31558509..48a327c479 100644 --- a/js/crm.livePage.js +++ b/js/crm.livePage.js @@ -1,13 +1,14 @@ // http://civicrm.org/licensing // Adds ajaxy behavior to a simple CiviCRM page cj(function($) { + var active = 'a.button, a.action-item, a.crm-popup'; $('#crm-main-content-wrapper') // Widgetize the content area .crmSnippet() // Open action links in a popup .off('.crmLivePage') - .on('click.crmLivePage', 'a.button, a.action-item', CRM.popup) - .on('crmPopupFormSuccess.crmLivePage', 'a.button, a.action-item', function() { + .on('click.crmLivePage', active, CRM.popup) + .on('crmPopupFormSuccess.crmLivePage', active, function() { // Refresh page when form completes $('#crm-main-content-wrapper').crmSnippet('refresh'); }); diff --git a/templates/CRM/Activity/Form/Activity.tpl b/templates/CRM/Activity/Form/Activity.tpl index 3e5233db4f..cef185d8a0 100644 --- a/templates/CRM/Activity/Form/Activity.tpl +++ b/templates/CRM/Activity/Form/Activity.tpl @@ -30,9 +30,6 @@ {if $action eq 4}
{else} - {if $context NEQ 'standalone'} -

{if $action eq 1 or $action eq 1024}{ts 1=$activityTypeName}New activity: %1{/ts}{elseif $action eq 8}{ts 1=$activityTypeName}Delete %1{/ts}{else}{ts 1=$activityTypeName}Edit %1{/ts}{/if}

- {/if} {if $activityTypeDescription }
{$activityTypeDescription}
{/if} @@ -56,7 +53,6 @@ {if $action eq 4} -

{$activityTypeName}

{if $activityTypeDescription }
{$activityTypeDescription}
{/if} diff --git a/templates/CRM/Case/Form/Activity.tpl b/templates/CRM/Case/Form/Activity.tpl index e9420d4eb0..c5c38bbebe 100644 --- a/templates/CRM/Case/Form/Activity.tpl +++ b/templates/CRM/Case/Form/Activity.tpl @@ -28,12 +28,6 @@ {if $cdType } {include file="CRM/Custom/Form/CustomData.tpl"} {else} -

{if $action eq 1 or $action eq 1024} - {ts 1=$activityTypeName}New activity: %1{/ts} - {elseif $action eq 8}{ts 1=$activityTypeName}Delete %1{/ts} - {elseif $action eq 32768}{ts 1=$activityTypeName}Restore %1{/ts} - {else}{ts 1=$activityTypeName}Edit %1{/ts}{/if} -

{if $action neq 8 and $action neq 32768 } diff --git a/templates/CRM/Case/Form/CaseView.js b/templates/CRM/Case/Form/CaseView.js index 404c3c04fe..751e6ea7ee 100644 --- a/templates/CRM/Case/Form/CaseView.js +++ b/templates/CRM/Case/Form/CaseView.js @@ -1,5 +1,5 @@ // https://civicrm.org/licensing -cj(function($) { +(function($, CRM) { function refresh() { $('#crm-main-content-wrapper').crmSnippet('refresh'); @@ -14,9 +14,79 @@ cj(function($) { } } - $('#crm-container') - .on('change', 'select[name=add_activity_type_id]', function() { - open($(this).val()); - $(this).select2('val', ''); + function caseId() { + return $('.crm-entity[data-entity=case]').data('id'); + } + + function contactId() { + return $('.crm-entity[data-entity=case]').data('cid'); + } + + /** + * The CaseView form includes some extra fields which are meant to open in a dialog. + * We stash them initially and pop them up as needed + * TODO: Creating a separate form class for each of these and opening them as standard popup links would be simpler and more reusable + * @type {*} + */ + var detached = {}, + miniForms = { + '#manageTags': function() { + console.log(this); + var tagsChecked = $("#manageTags #tags").select2('val').join(','), + tagList = {}, + url = CRM.url('civicrm/case/ajax/processtags'); + $("#manageTags input[name^=case_taglist]").each(function() { + var tsId = $(this).attr('id').split('_'); + tagList[tsId[2]] = $(this).val(); + }); + var data = { + case_id: caseId(), + tag: tagsChecked, + taglist: tagList, + key: $(this).data('qfkey') + }; + + return $.post(url, data); + } + }; + + function detachMiniForms() { + detached = {}; + $.each(miniForms, function(selector) { + detached[selector] = $(selector).detach(); }); -}); + } + + $('#crm-container').on('crmLoad', '#crm-main-content-wrapper', detachMiniForms); + + $(document).ready(function() { + detachMiniForms(); + $('#crm-container') + .on('change', 'select[name=add_activity_type_id]', function() { + open($(this).val()); + $(this).select2('val', ''); + }) + .on('click', 'a.case-miniform', function() { + var dialog, + $el = $(this), + target = $el.attr('href'); + function submit() { + dialog.parent().block(); + miniForms[target].call($el[0]).done(function() { + dialog.dialog('close'); + refresh(); + }); + return false; + } + dialog = CRM.confirm(submit, { + title: $(this).text(), + message: detached[target], + close: function() { + detached[target] = $(target, dialog).detach(); + $(dialog).dialog('destroy').remove(); + } + }); + return false; + }); + }); +}(cj, CRM)) diff --git a/templates/CRM/Case/Form/CaseView.tpl b/templates/CRM/Case/Form/CaseView.tpl index f24b401f3d..2b51c4b818 100644 --- a/templates/CRM/Case/Form/CaseView.tpl +++ b/templates/CRM/Case/Form/CaseView.tpl @@ -35,7 +35,7 @@ {else}

{ts}Summary{/ts}

-
+
{if $multiClient} @@ -73,7 +73,7 @@ {/foreach}
@@ -47,7 +47,7 @@ {if $hasRelatedCases} - + {/if}
{if $hasRelatedCases} - + {/if} {/if} @@ -81,13 +81,13 @@ {ts}Subject{/ts}: {$caseDetails.case_subject} - {ts}Type{/ts}: {$caseDetails.case_type}  + {ts}Type{/ts}: {$caseDetails.case_type}  - {ts}Status{/ts}: {$caseDetails.case_status}  + {ts}Status{/ts}: {$caseDetails.case_status}  - {ts}Open Date{/ts}: {$caseDetails.case_start_date|crmDate}  + {ts}Open Date{/ts}: {$caseDetails.case_start_date|crmDate}  {ts}ID{/ts}: {$caseID} @@ -276,8 +276,10 @@ cj("#dialog").dialog({ title: "{/literal}{ts escape="js"}Add Client to the Case{/ts}{literal}", modal: true, - bgiframe: true, - close : function(event, ui) { cj("#rel_contact").unautocomplete( ); }, + close : function(event, ui) { + cj("#rel_contact").unautocomplete( ); + cj("#dialog").hide( ); + }, overlay: { opacity: 0.5, background: "black" }, open:function() { @@ -295,7 +297,7 @@ }, buttons: { - "Done": function() { + "{/literal}{ts escape='js'}Done{/ts}{literal}": function() { var postUrl = {/literal}"{crmURL p='civicrm/case/ajax/addclient' h=0 }"{literal}; var caseID = {/literal}"{$caseID}"{literal}; var contactID = cj("#rel_contact_id").val( ); @@ -314,7 +316,7 @@ ); }, - "Cancel": function() { + "{/literal}{ts escape='js'}Cancel{/ts}{literal}": function() { cj(this).dialog("close"); cj(this).dialog("destroy"); } @@ -360,7 +362,7 @@ }, buttons: { - "Ok": function() { + "{/literal}{ts escape='js'}Ok{/ts}{literal}": function() { var sourceContact = {/literal}"{$contactID}"{literal}; var caseID = {/literal}"{$caseID}"{literal}; @@ -399,7 +401,7 @@ cj(this).dialog("destroy"); }, - "Cancel": function() { + "{/literal}{ts escape='js'}Cancel{/ts}{literal}": function() { cj(this).dialog("close"); cj(this).dialog("destroy"); } @@ -635,7 +637,7 @@ function addRole() { }, buttons: { - "Ok": function() { + "{/literal}{ts escape='js'}Ok{/ts}{literal}": function() { var sourceContact = {/literal}"{$contactID}"{literal}; var caseID = {/literal}"{$caseID}"{literal}; var relID = null; @@ -683,7 +685,7 @@ function addRole() { cj(this).dialog("destroy"); }, - "Cancel": function() { + "{/literal}{ts escape='js'}Cancel{/ts}{literal}": function() { cj(this).dialog("close"); cj(this).dialog("destroy"); } @@ -727,7 +729,9 @@ function addRole() {
{/if} -
+
+ {if $tagExits}{ts}Edit Tags{/ts}{else}{ts}Add Tags{/ts}{/if} +
@@ -742,73 +746,6 @@ function addRole() { -{literal} - -{/literal} - {/if} {* end of tag block*}
diff --git a/templates/CRM/Contact/Form/Task/PDF.tpl b/templates/CRM/Contact/Form/Task/PDF.tpl index c645438b98..8da76ad850 100644 --- a/templates/CRM/Contact/Form/Task/PDF.tpl +++ b/templates/CRM/Contact/Form/Task/PDF.tpl @@ -24,7 +24,6 @@ +--------------------------------------------------------------------+ *}
-

{ts}Create Printable Letters (PDF){/ts}

{if $single eq false}
{include file="CRM/Contact/Form/Task.tpl"}
{/if} -- 2.25.1