From: jitendrapurohit Date: Fri, 12 Jun 2015 12:40:03 +0000 (+0530) Subject: additional fixes for CRM-16310 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c1cd77e2a0412beaf04b56a2aaee7398bbbad055;p=civicrm-core.git additional fixes for CRM-16310 --- diff --git a/CRM/Core/BAO/CustomOption.php b/CRM/Core/BAO/CustomOption.php index 5e0608edc1..48d86991ab 100644 --- a/CRM/Core/BAO/CustomOption.php +++ b/CRM/Core/BAO/CustomOption.php @@ -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); diff --git a/CRM/Custom/Page/AJAX.php b/CRM/Custom/Page/AJAX.php index 69f8fd4cdd..b4bc680cb0 100644 --- a/CRM/Custom/Page/AJAX.php +++ b/CRM/Custom/Page/AJAX.php @@ -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); } } diff --git a/templates/CRM/Custom/Page/Option.tpl b/templates/CRM/Custom/Page/Option.tpl index 8c1e91dca8..32a31ff1d7 100644 --- a/templates/CRM/Custom/Page/Option.tpl +++ b/templates/CRM/Custom/Page/Option.tpl @@ -43,7 +43,7 @@ {ts}Label{/ts} {ts}Value{/ts} {ts}Default{/ts} - {ts}Enabled?{/ts} + {ts}Enabled?{/ts}     @@ -69,10 +69,10 @@ "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(''); + $('td:eq(0)', nRow).wrapInner('
'); + $('td:eq(0)', nRow).prepend('
'); $('td:eq(2)', nRow).addClass('crmf-default_value'); return nRow; }, @@ -119,11 +121,13 @@ }); } + 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(); @@ -141,6 +145,10 @@ end: endPosition, gid: gid }) + .success(function() { + oSettings.oApi._fnDraw(oSettings); + CRM.status(ts('Saved')); + }); } }); });