additional fixes for CRM-16310
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Fri, 12 Jun 2015 12:40:03 +0000 (18:10 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Fri, 12 Jun 2015 12:40:32 +0000 (18:10 +0530)
CRM/Core/BAO/CustomOption.php
CRM/Custom/Page/AJAX.php
templates/CRM/Custom/Page/Option.tpl

index 5e0608edc1ed4dd8025c49edc201b8fabdcf6ab5..48d86991ab86d416afdca75d2cb73d267a3a12ea 100644 (file)
@@ -137,7 +137,6 @@ class CRM_Core_BAO_CustomOption {
     // format the params
     $params['offset'] = ($params['page'] - 1) * $params['rp'];
     $params['rowCount'] = $params['rp'];
-    $params['sort'] = CRM_Utils_Array::value('sortBy', $params);
 
     $field = CRM_Core_BAO_CustomField::getFieldObject($params['fid']);
 
@@ -151,11 +150,7 @@ class CRM_Core_BAO_CustomOption {
     $params['total'] = CRM_Core_DAO::singleValueQuery($total, $queryParams);
 
     $limit = " LIMIT {$params['offset']}, {$params['rowCount']} ";
-
     $orderBy = ' ORDER BY options.weight asc';
-    if (!empty($params['sort'])) {
-      $orderBy = ' ORDER BY ' . CRM_Utils_Type::escape($params['sort'], 'String');
-    }
 
     $query = "SELECT * FROM civicrm_option_value as options WHERE option_group_id = %1 {$orderBy} {$limit}";
     $dao = CRM_Core_DAO::executeQuery($query, $queryParams);
index 69f8fd4cdd13d9491d7a0e4c8a8a56860817fad8..b4bc680cb04dab4ed46c3ad98a640e70a509c134 100644 (file)
@@ -43,23 +43,9 @@ class CRM_Custom_Page_AJAX {
   public static function getOptionList() {
     $params = $_REQUEST;
 
-    $sortMapper = array(
-      0 => 'options.label',
-      1 => 'options.value',
-      2 => '',
-      3 => '',
-      4 => '',
-    );
-
     $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
     $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
     $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
-    $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
-    $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
-
-    if ($sort && $sortOrder) {
-      $params['sortBy'] = $sort . ' ' . $sortOrder;
-    }
 
     $params['page'] = ($offset / $rowCount) + 1;
     $params['rp'] = $rowCount;
@@ -116,6 +102,7 @@ class CRM_Custom_Page_AJAX {
                   OR id = $endid";
     }
     CRM_Core_DAO::executeQuery($updateRows, $queryParams);
+    CRM_Utils_JSON::output(TRUE);
   }
 
 }
index 8c1e91dca8cf014a2efe86626f368ff7753d6831..32a31ff1d7937184163f99ccd494685f170f81e6 100644 (file)
@@ -43,7 +43,7 @@
             <th class='crm-custom_option-label'>{ts}Label{/ts}</th>
             <th class='crm-custom_option-value'>{ts}Value{/ts}</th>
             <th class='crm-custom_option-default_value'>{ts}Default{/ts}</th>
-            <th class='crm-custom_option-is_active  nosort'>{ts}Enabled?{/ts}</th>
+            <th class='crm-custom_option-is_active'>{ts}Enabled?{/ts}</th>
             <th class='crm-custom_option-links'>&nbsp;</th>
             <th class='hiddenElement'>&nbsp;</th>
           </tr>
               "aoColumns"  : [
                               {sClass:'crm-custom_option-label'},
                               {sClass:'crm-custom_option-value'},
-                              {sClass:'crm-custom_option-default_value', bSortable:false},
-                              {sClass:'crm-custom_option-is_active', bSortable:false},
-                              {sClass:'crm-custom_option-links', bSortable:false},
-                              {sClass:'hiddenElement', bSortable:false}
+                              {sClass:'crm-custom_option-default_value'},
+                              {sClass:'crm-custom_option-is_active'},
+                              {sClass:'crm-custom_option-links'},
+                              {sClass:'hiddenElement'}
                              ],
               "bProcessing": true,
               "asStripClasses" : [ "odd-row", "even-row" ],
@@ -80,6 +80,7 @@
               "sDom"       : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
               "bServerSide": true,
               "bJQueryUI": true,
+              "bSort" : false,
               "sAjaxSource": sourceUrl,
               "iDisplayLength": 10,
               "oLanguage": {
@@ -98,7 +99,8 @@
                 var id = $('td:last', nRow).text().split(',')[0];
                 var cl = $('td:last', nRow).text().split(',')[1];
                 $(nRow).addClass(cl).attr({id: 'OptionValue-' + id});
-                $('td:eq(0)', nRow).wrapInner('<span class="crm-editable crmf-label" />');
+                $('td:eq(0)', nRow).wrapInner('<div class="crm-editable crmf-label" />');
+                $('td:eq(0)', nRow).prepend('<div style="cursor:move" class="icon ui-icon-grip-dotted-vertical">');
                 $('td:eq(2)', nRow).addClass('crmf-default_value');
                 return nRow;
               },
           });
         }
 
+
         var startPosition;
         var endPosition;
         var gid = {/literal}'{$optionGroupID}'{literal};
 
         $("table.crm-option-selector tbody").sortable({
+          handle: ".ui-icon-grip-dotted-vertical",
           cursor: "move",
           start:function(event, ui) {
             var oSettings = $('table.crm-option-selector').dataTable().fnSettings();
               end: endPosition,
               gid: gid
             })
+            .success(function() {
+              oSettings.oApi._fnDraw(oSettings);
+              CRM.status(ts('Saved'));
+            });
           }
         });
       });