From 21d5ed51a2ed5ed341adeee8b2877efb1d51531a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 17 Mar 2014 12:46:02 -0400 Subject: [PATCH] Remove activityChangeStatus.js --- CRM/Case/Form/CaseView.php | 3 - CRM/Case/Form/Search.php | 3 - CRM/Case/Page/DashBoard.php | 3 - CRM/Contact/Page/DashBoard.php | 8 -- .../CRM/Case/Form/ActivityChangeStatus.js | 65 ------------- .../CRM/Case/Form/ActivityChangeStatusJs.tpl | 96 +++++++++++++++++++ templates/CRM/Case/Form/CaseView.tpl | 2 + templates/CRM/Case/Form/Search.tpl | 2 + templates/CRM/Case/Page/DashBoard.tpl | 2 + templates/CRM/Case/Page/DashboardSelector.tpl | 2 + 10 files changed, 104 insertions(+), 82 deletions(-) delete mode 100644 templates/CRM/Case/Form/ActivityChangeStatus.js create mode 100644 templates/CRM/Case/Form/ActivityChangeStatusJs.tpl diff --git a/CRM/Case/Form/CaseView.php b/CRM/Case/Form/CaseView.php index 4e5234cc65..7302e9a3fd 100644 --- a/CRM/Case/Form/CaseView.php +++ b/CRM/Case/Form/CaseView.php @@ -51,9 +51,6 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { * @access public */ public function preProcess() { - // js for changing activity status - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Case/Form/ActivityChangeStatus.js'); - $this->_showRelatedCases = CRM_Utils_Array::value('relatedCases', $_GET); $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process(); diff --git a/CRM/Case/Form/Search.php b/CRM/Case/Form/Search.php index 73f15a8d7c..bdec2c5f32 100644 --- a/CRM/Case/Form/Search.php +++ b/CRM/Case/Form/Search.php @@ -127,9 +127,6 @@ class CRM_Case_Form_Search extends CRM_Core_Form { function preProcess() { $this->set('searchFormName', 'Search'); - // js for changing activity status - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Case/Form/ActivityChangeStatus.js'); - //check for civicase access. if (!CRM_Case_BAO_Case::accessCiviCase()) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); diff --git a/CRM/Case/Page/DashBoard.php b/CRM/Case/Page/DashBoard.php index 18ddc2ec7b..5ce46ede0f 100644 --- a/CRM/Case/Page/DashBoard.php +++ b/CRM/Case/Page/DashBoard.php @@ -47,9 +47,6 @@ class CRM_Case_Page_DashBoard extends CRM_Core_Page { * */ function preProcess() { - // js for changing activity status - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Case/Form/ActivityChangeStatus.js'); - //check for civicase access. if (!CRM_Case_BAO_Case::accessCiviCase()) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); diff --git a/CRM/Contact/Page/DashBoard.php b/CRM/Contact/Page/DashBoard.php index 2d51109b34..f47ea736a7 100644 --- a/CRM/Contact/Page/DashBoard.php +++ b/CRM/Contact/Page/DashBoard.php @@ -53,14 +53,6 @@ class CRM_Contact_Page_DashBoard extends CRM_Core_Page { $config = CRM_Core_Config::singleton(); - // Add dashlet-specific js files - // TODO: Need a much better way of managing on-the-fly js requirements. Require.js perhaps? - // Checking if a specific dashlet is enabled is a pain and including the js here sucks anyway - // So here's a compromise: - if (in_array('CiviCase', $config->enableComponents)) { - $resources->addScriptFile('civicrm', 'templates/CRM/Case/Form/ActivityChangeStatus.js'); - } - $resetCache = CRM_Utils_Request::retrieve('resetCache', 'Positive', CRM_Core_DAO::$_nullObject); CRM_Utils_System::setTitle(ts('CiviCRM Home')); diff --git a/templates/CRM/Case/Form/ActivityChangeStatus.js b/templates/CRM/Case/Form/ActivityChangeStatus.js deleted file mode 100644 index 650661bbb3..0000000000 --- a/templates/CRM/Case/Form/ActivityChangeStatus.js +++ /dev/null @@ -1,65 +0,0 @@ -// http://civicrm.org/licensing -cj(function($) { - // Elements are sometimes in a jQuery dialog box which is outside crm-container, - // So gotta attach this handler to the whole body - sorry. - $('body').on('click', 'a.crm-activity-change-status', function() { - var link = $(this), - activityId = $(this).attr('activity_id'), - current_status_id = $(this).attr('current_status'), - caseId = $(this).attr('case_id'), - data = 'snippet=1&reset=1', - o = $('
'); - o.block({theme:true}); - - o.load(CRM.url('civicrm/case/changeactivitystatus'), data, function() { - o.unblock(); - cj("#activity_change_status").val(current_status_id); - }); - - CRM.confirm(function() { - // update the status - var status_id = $("#activity_change_status").val( ); - if (status_id === current_status_id) { - return false; - } - - var dataUrl = CRM.url('civicrm/ajax/rest'); - var data = 'json=1&version=3&entity=Activity&action=update&id=' + activityId + '&status_id=' + status_id - + '&case_id=' + caseId; - $.ajax({ - type : 'POST', - dataType : 'json', - url : dataUrl, - data : data, - success : function(values) { - if (values.is_error) { - CRM.alert(values.error_message, ts('Unable to change status'), 'error'); - return false; - } - else { - // reload the table on success - if (window.buildCaseActivities) { - // If we are using a datatable - buildCaseActivities(true); - } - else { - // Legacy refresh for non-datatable screens - var table = link.closest('table.nestedActivitySelector'); - table.parent().load(CRM.url('civicrm/case/details', table.data('params'))); - } - } - }, - error : function(jqXHR) { - CRM.alert(jqXHR.responseText, jqXHR.statusText, 'error'); - return false; - } - }); - } - ,{ - title: ts('Change Activity Status'), - message: o - } - ); - return false; - }); -}); \ No newline at end of file diff --git a/templates/CRM/Case/Form/ActivityChangeStatusJs.tpl b/templates/CRM/Case/Form/ActivityChangeStatusJs.tpl new file mode 100644 index 0000000000..f6bbf8fc46 --- /dev/null +++ b/templates/CRM/Case/Form/ActivityChangeStatusJs.tpl @@ -0,0 +1,96 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.4 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2013 | + +--------------------------------------------------------------------+ + | This file is a part of CiviCRM. | + | | + | CiviCRM is free software; you can copy, modify, and distribute it | + | under the terms of the GNU Affero General Public License | + | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | + | | + | CiviCRM is distributed in the hope that it will be useful, but | + | WITHOUT ANY WARRANTY; without even the implied warranty of | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | + | See the GNU Affero General Public License for more details. | + | | + | You should have received a copy of the GNU Affero General Public | + | License and the CiviCRM Licensing Exception along | + | with this program; if not, contact CiviCRM LLC | + | at info[AT]civicrm[DOT]org. If you have questions about the | + | GNU Affero General Public License or the licensing of CiviCRM, | + | see the CiviCRM license FAQ at http://civicrm.org/licensing | + +--------------------------------------------------------------------+ +*} +{* CiviCase - change activity status inline *} +{literal} + +{/literal} diff --git a/templates/CRM/Case/Form/CaseView.tpl b/templates/CRM/Case/Form/CaseView.tpl index 94892a5ba4..098d4f1fbc 100644 --- a/templates/CRM/Case/Form/CaseView.tpl +++ b/templates/CRM/Case/Form/CaseView.tpl @@ -1105,3 +1105,5 @@ function printCaseReport( ) { {/if} {* view related cases if end *} + +{include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"} diff --git a/templates/CRM/Case/Form/Search.tpl b/templates/CRM/Case/Form/Search.tpl index 71b02cf926..1e1aff4086 100644 --- a/templates/CRM/Case/Form/Search.tpl +++ b/templates/CRM/Case/Form/Search.tpl @@ -87,3 +87,5 @@ cj(function() { {/literal} {/if} + +{include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"} diff --git a/templates/CRM/Case/Page/DashBoard.tpl b/templates/CRM/Case/Page/DashBoard.tpl index cded426b76..22b7af6169 100644 --- a/templates/CRM/Case/Page/DashBoard.tpl +++ b/templates/CRM/Case/Page/DashBoard.tpl @@ -110,3 +110,5 @@ {/if} {/if} + +{include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"} diff --git a/templates/CRM/Case/Page/DashboardSelector.tpl b/templates/CRM/Case/Page/DashboardSelector.tpl index c303690be6..9991549c0f 100644 --- a/templates/CRM/Case/Page/DashboardSelector.tpl +++ b/templates/CRM/Case/Page/DashboardSelector.tpl @@ -151,3 +151,5 @@ function hideCaseActivities( caseId , type, context ) { {/literal} + +{include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"} -- 2.25.1