Remove activityChangeStatus.js
authorColeman Watts <coleman@civicrm.org>
Mon, 17 Mar 2014 16:46:02 +0000 (12:46 -0400)
committerColeman Watts <coleman@civicrm.org>
Mon, 17 Mar 2014 16:49:54 +0000 (12:49 -0400)
CRM/Case/Form/CaseView.php
CRM/Case/Form/Search.php
CRM/Case/Page/DashBoard.php
CRM/Contact/Page/DashBoard.php
templates/CRM/Case/Form/ActivityChangeStatus.js [deleted file]
templates/CRM/Case/Form/ActivityChangeStatusJs.tpl [new file with mode: 0644]
templates/CRM/Case/Form/CaseView.tpl
templates/CRM/Case/Form/Search.tpl
templates/CRM/Case/Page/DashBoard.tpl
templates/CRM/Case/Page/DashboardSelector.tpl

index 4e5234cc656af908a33721572e868c545ac8fc71..7302e9a3fd7d9de0c5b2250a6d90f22422d7c355 100644 (file)
@@ -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();
index 73f15a8d7c50085defd1014662f290e4a26665ae..bdec2c5f321a945816c5b59df4d90cc58c6a590f 100644 (file)
@@ -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.'));
index 18ddc2ec7bb9abedf97f719f19c1dd65bd28b6b2..5ce46ede0f74c23bec7a4a79b80c2428c403c2c4 100644 (file)
@@ -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.'));
index 2d51109b34ac348d3a72457aa2e8e11c2e98de71..f47ea736a716531dee4f632e41c4d3a5a84e1b58 100644 (file)
@@ -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 (file)
index 650661b..0000000
+++ /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 = $('<div class="crm-container crm-activity_change_status"></div>');
-      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 (file)
index 0000000..f6bbf8f
--- /dev/null
@@ -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}
+  <script type="text/javascript">
+    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').off('click.changeActivityStatus');
+      $('body').on('click.changeActivityStatus', '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',
+          $el = $('<div class="crm-container crm-activity_change_status"></div>');
+        $el.block({theme:true});
+
+        $el.load(CRM.url('civicrm/case/changeactivitystatus'), data, function() {
+          $el.unblock().trigger('crmLoad');
+          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;
+            var request = $.ajax({
+              type     : 'POST',
+              dataType : 'json',
+              url      : dataUrl,
+              data     : data,
+              success  : function(values) {
+                if (values.is_error) {
+                  CRM.alert(values.error_message, {/literal}'{ts escape='js'}Unable to change status{/ts}'{literal}, '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().crmSnippet({url: CRM.url('civicrm/case/details', table.data('params'))}).crmSnippet('refresh');
+                  }
+                }
+              },
+              error : function(jqXHR) {
+                CRM.alert(jqXHR.responseText, jqXHR.statusText, 'error');
+                return false;
+              }
+            });
+            CRM.status({}, request);
+          }
+          ,{
+            title: {/literal}'{ts escape='js'}Change Activity Status{/ts}'{literal},
+            message: $el
+          }
+        );
+        return false;
+      });
+    });
+  </script>
+{/literal}
index 94892a5ba4bcea5278931d67a74de1599069953f..098d4f1fbc811da9086749aad31ac9cb91ef5bb9 100644 (file)
@@ -1105,3 +1105,5 @@ function printCaseReport( ) {
 
 {/if} {* view related cases if end *}
 </div>
+
+{include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"}
index 71b02cf9263ec9838edbd3cb447d8bb06f083e48..1e1aff408613207facb902bd6c39b58d4752b891 100644 (file)
@@ -87,3 +87,5 @@ cj(function() {
 </script>
 {/literal}
 {/if}
+
+{include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"}
index cded426b762b2e55c5096d8b04d5a650da383af8..22b7af6169627d8006ca14da4cfa6cff113355b4 100644 (file)
     {/if}
 {/if}
 </div>
+
+{include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"}
index c303690be635a2cf2393ea2fed046478b434de7c..9991549c0faf32753f0500894fa0ea731e7f4500 100644 (file)
@@ -151,3 +151,5 @@ function hideCaseActivities( caseId , type, context ) {
 
 </script>
 {/literal}
+
+{include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"}