From 2a06342cebcb3263833256f521538ef4a90f94aa Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 20 Mar 2014 23:26:59 -0400 Subject: [PATCH] Case ui enhancements & code cleanup --- CRM/Activity/Page/AJAX.php | 3 +- CRM/Case/Form/CaseView.php | 30 ++-- CRM/Case/Form/Report.php | 3 +- CRM/Contact/Page/AJAX.php | 1 - .../plugins/modifier.crmBtnValidate.php | 2 +- css/civicrm.css | 2 +- js/Common.js | 8 +- templates/CRM/Case/Form/CaseView.js | 64 ++++++-- templates/CRM/Case/Form/CaseView.tpl | 137 +++++------------- 9 files changed, 110 insertions(+), 140 deletions(-) diff --git a/CRM/Activity/Page/AJAX.php b/CRM/Activity/Page/AJAX.php index b3b8845324..6210224d38 100644 --- a/CRM/Activity/Page/AJAX.php +++ b/CRM/Activity/Page/AJAX.php @@ -264,7 +264,8 @@ class CRM_Activity_Page_AJAX { switch($caseRelationships[$key]['source']){ case 'caseRel': $caseRelationships[$key]['actions'] = - ' '; + ' + '; break; case 'caseRoles': diff --git a/CRM/Case/Form/CaseView.php b/CRM/Case/Form/CaseView.php index 9e2dd86768..afee03c000 100644 --- a/CRM/Case/Form/CaseView.php +++ b/CRM/Case/Form/CaseView.php @@ -276,23 +276,20 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { $activityLinks[$url] = $label; } - $this->add('select', 'add_activity_type_id', '', $activityLinks, FALSE, array('class' => 'crm-select2 crm-action-menu')); + $this->add('select', 'add_activity_type_id', '', $activityLinks, FALSE, array('class' => 'crm-select2 crm-action-menu twenty')); if ($this->_hasAccessToAllCases) { - $this->add('select', 'report_id', ts('Run QA Audit / Redact'), - array( - '' => ts('- select activity set -')) + $reports + $this->add('select', 'report_id', '', + array('' => ts('Run QA Audit / Redact')) + $reports, + FALSE, + array('class' => 'crm-select2 crm-action-menu') ); - $this->add('select', 'timeline_id', ts('Add Timeline'), - array( - '' => ts('- select activity set -')) + $reports + $this->add('select', 'timeline_id', '', + array('' => ts('Add Timeline')) + $reports, + FALSE, + array('class' => 'crm-select2 crm-action-menu') ); } - $this->addElement('submit', $this->getButtonName('next'), ts('Go'), - array( - 'class' => 'form-submit-inline', - 'onclick' => "return checkSelection( this );", - ) - ); + $this->addElement('submit', $this->getButtonName('next'), ' ', array('class' => 'hiddenElement')); if ($this->_mergeCases) { $allCases = CRM_Case_BAO_Case::getContactCases($this->_contactID); @@ -317,14 +314,15 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { $this->add('select', 'merge_case_id', ts('Select Case for Merge'), array( - '' => ts('- select case -')) + $otherCases + '' => ts('- select case -')) + $otherCases, + FALSE, + array('class' => 'crm-select2 huge') ); $this->addElement('submit', $this->getButtonName('next', 'merge_case'), ts('Merge'), array( - 'class' => 'form-submit-inline', - 'onclick' => "return checkSelection( this );", + 'class' => 'form-submit-inline hiddenElement', ) ); } diff --git a/CRM/Case/Form/Report.php b/CRM/Case/Form/Report.php index 92ed7d67cc..3396223a55 100644 --- a/CRM/Case/Form/Report.php +++ b/CRM/Case/Form/Report.php @@ -105,7 +105,6 @@ class CRM_Case_Form_Report extends CRM_Core_Form { array( 'type' => 'refresh', 'name' => ts('Generate Report'), - 'spacing' => '         ', 'isDefault' => TRUE, ), array( @@ -114,6 +113,8 @@ class CRM_Case_Form_Report extends CRM_Core_Form { ), ) ); + // We want this form to redirect to a full page + $this->preventAjaxSubmit(); } /** diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index a45ef61f22..1ea4489e60 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -244,7 +244,6 @@ class CRM_Contact_Page_AJAX { static function relationship() { $relType = CRM_Utils_Array::value('rel_type', $_REQUEST); $relContactID = CRM_Utils_Array::value('rel_contact', $_REQUEST); - $sourceContactID = CRM_Utils_Array::value('contact_id', $_REQUEST); // we no longer need this. $relationshipID = CRM_Utils_Array::value('rel_id', $_REQUEST); // this used only to determine add or update mode $caseID = CRM_Utils_Array::value('case_id', $_REQUEST); diff --git a/CRM/Core/Smarty/plugins/modifier.crmBtnValidate.php b/CRM/Core/Smarty/plugins/modifier.crmBtnValidate.php index 4644e27ad8..32d01ba0ed 100644 --- a/CRM/Core/Smarty/plugins/modifier.crmBtnValidate.php +++ b/CRM/Core/Smarty/plugins/modifier.crmBtnValidate.php @@ -50,7 +50,7 @@ function smarty_modifier_crmBtnValidate($btnName) { // note the first _ $substr = CRM_Utils_System::explode('_', $btnName, 5); - if (in_array($substr[3], array('upload', 'next', 'submit', 'done', 'process'))) { + if (in_array($substr[3], array('upload', 'next', 'submit', 'done', 'process', 'refresh'))) { return 'validate'; } return 'cancel'; diff --git a/css/civicrm.css b/css/civicrm.css index 567c5c43cb..1bd09ba7e4 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -2487,7 +2487,7 @@ div.grippie { .crm-container .icon { height: 16px; width: 16px; - background: transparent url("../i/icons/jquery-ui-52534D.png") no-repeat top right; + background-image: url("../i/icons/jquery-ui-52534D.png"); float: left; text-indent: -10000px; } diff --git a/js/Common.js b/js/Common.js index dce5b31b2b..5b0f4c7692 100644 --- a/js/Common.js +++ b/js/Common.js @@ -654,18 +654,22 @@ CRM.validate = CRM.validate || { }; settings.buttons[cancelLabel] = function () { - dialog.dialog('close'); + dialog.trigger('crmConfirmNo').dialog('close'); }; options = options || {}; $.extend(settings, options); - if (typeof(buttons) === 'function') { + if ($.isFunction(buttons)) { callbacks[ts('Continue')] = buttons; } + else if (_.isString(buttons) || !buttons) { + callbacks[buttons || ts('Continue')] = function() {}; + } else { callbacks = buttons; } $.each(callbacks, function (label, callback) { settings.buttons[label] = function () { + dialog.trigger('crmConfirmYes'); if (callback.call(dialog) !== false) { dialog.dialog('close'); } diff --git a/templates/CRM/Case/Form/CaseView.js b/templates/CRM/Case/Form/CaseView.js index d4cb479233..1eb7e27b9d 100644 --- a/templates/CRM/Case/Form/CaseView.js +++ b/templates/CRM/Case/Form/CaseView.js @@ -5,9 +5,9 @@ $('#crm-main-content-wrapper').crmSnippet('refresh'); } - function open(url) { + function open(url, options) { if (CRM.config.ajaxPopupsEnabled) { - CRM.loadForm(url).on('crmFormSuccess', refresh); + CRM.loadForm(url, options).on('crmFormSuccess', refresh); } else { window.location.href = url; @@ -31,7 +31,6 @@ var detached = {}, miniForms = { '#manageTags': function() { - console.log(this); var tagsChecked = $("#manageTags #tags").select2('val').join(','), tagList = {}, url = CRM.url('civicrm/case/ajax/processtags'); @@ -43,17 +42,26 @@ case_id: caseId(), tag: tagsChecked, taglist: tagList, - key: $(this).data('qfkey') + key: $(this).data('key') }; - return $.post(url, data); + }, + '#merge_cases': function() { + if ($('select#merge_case_id').val()) { + $('select#merge_case_id').appendTo('form#CaseView'); + $('[name="_qf_CaseView_next_merge_case"]').click(); + } + }, + '#deleteCaseRole': function() { + var params = $.extend({case_id: caseId()}, $(this).data()); + return $.post(CRM.url('civicrm/ajax/delcaserole'), params); } }; function detachMiniForms() { detached = {}; $.each(miniForms, function(selector) { - detached[selector] = $(selector).detach(); + detached[selector] = $(selector).detach().removeClass('hiddenElement'); }); } @@ -66,20 +74,49 @@ open($(this).val()); $(this).select2('val', ''); }) + .on('change', 'select[name=timeline_id]', function() { + if ($(this).val()) { + CRM.confirm(ts('Add'), { + title: $('option:first', this).text(), + message: ts('Add the %1 set of scheduled activities to this case?', {1: '' + $('option:selected', this).text() + ''}) + }) + .on('crmConfirmYes', function () { + $('[name=_qf_CaseView_next]').click(); + }) + .on('crmConfirmNo', function() { + $('select[name=timeline_id]').select2('val', ''); + }); + } + }) + .on('change', 'select[name=report_id]', function() { + if ($(this).val()) { + var url = CRM.url('civicrm/case/report', { + reset: 1, + cid: contactId(), + caseid: caseId(), + asn: $(this).val() + }); + open(url, {dialog: {width: '50%', height: 'auto'}}); + $(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; + var submission = miniForms[target].call($el[0]); + if (submission) { + dialog.parent().block(); + submission.done(function() { + dialog.dialog('close'); + refresh(); + }); + return false; + } } dialog = CRM.confirm(submit, { - title: $(this).text(), + title: $(this).attr('title') || $(this).text(), message: detached[target], close: function() { detached[target] = $(target, dialog).detach(); @@ -88,5 +125,6 @@ }); return false; }); + $().crmAccordions(); }); }(cj, CRM)) diff --git a/templates/CRM/Case/Form/CaseView.tpl b/templates/CRM/Case/Form/CaseView.tpl index 6b90eaaff0..c464d990e6 100644 --- a/templates/CRM/Case/Form/CaseView.tpl +++ b/templates/CRM/Case/Form/CaseView.tpl @@ -102,40 +102,36 @@ {/if} - - - - {if $hasAccessToAllCases} - - - - - - {else} - - {/if} - +
+
+

+ {$form.add_activity_type_id.html} + {if $hasAccessToAllCases}   + {$form.timeline_id.html}{$form._qf_CaseView_next.html}   + {$form.report_id.html} + {/if} +

+
+
+

+ {if $hasAccessToAllCases} + {ts}Print Report{/ts} + {/if} - {if $mergeCases} -

- - - {/if} + {/if} - {if call_user_func(array('CRM_Core_Permission','giveMeAllACLs'))} - - - - {/if} -
{$form.add_activity_type_id.html} - {ts}Print Report{/ts} -
{$form.timeline_id.label}
{$form.timeline_id.html} {$form._qf_CaseView_next.html}
{$form.report_id.label}
{$form.report_id.html} 
{ts}Merge Case{/ts} - - {$form.merge_case_id.html} {$form._qf_CaseView_next_merge_case.html} + {if $mergeCases} + {ts}Merge Case{/ts} + {$form._qf_CaseView_next_merge_case.html} + + {$form.merge_case_id.html} -
- {ts}Assign to Another Contact{/ts} -
+ {if call_user_func(array('CRM_Core_Permission','giveMeAllACLs'))} + {ts}Assign to Another Client{/ts} + {/if} +

+ +
{include file="CRM/Case/Page/CustomDataView.tpl"} @@ -164,39 +160,18 @@ +
+ {ts}Are you sure you want to delete this case role?{/ts} +
+ {literal} @@ -718,13 +690,13 @@ function addRole() { {/if}
- {if $tagExits}{ts}Edit Tags{/ts}{else}{ts}Add Tags{/ts}{/if} + {if $tagExits}{ts}Edit Tags{/ts}{else}{ts}Add Tags{/ts}{/if}
-
+
{$form.case_tag.label}
{$form.case_tag.html}

@@ -803,41 +775,6 @@ function addRole() { -{/literal} - {include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"} {/if} {* view related cases if end *}
-- 2.25.1