if (defaults.label === true) {
values.label = getDefaultLabel(fieldExpr);
}
+ if (defaults.sortable) {
+ values.sortable = (info.field.type === 'Field');
+ }
return values;
}
return {
}
// Displays created prior to 5.43 may not have this property
ctrl.display.settings.classes = ctrl.display.settings.classes || [];
- ctrl.parent.initColumns({label: true});
+ ctrl.parent.initColumns({label: true, sortable: true});
};
}
classes: ['table', 'table-striped'],
button: ts('Search'),
columns: _.transform(ctrl.search.api_params.select, function(columns, fieldExpr) {
- var column = {label: true},
+ var column = {label: true, sortable: true},
link = getViewLink(fieldExpr, links);
if (link) {
column.title = link.title;
<input type="checkbox" ng-disabled="$ctrl.loading || !$ctrl.results.length" ng-checked="$ctrl.allRowsSelected" ng-click="$ctrl.selectAllRows()" >
</th>
<th ng-repeat="item in $ctrl.search.api_params.select" ng-click="$ctrl.setSort($ctrl.settings.columns[$index], $event)" title="{{$index || !$ctrl.crmSearchAdmin.groupExists ? ts('Drag to reorder columns, click to sort results (shift-click to sort by multiple).') : ts('Column reserved for smart group.')}}">
- <i class="crm-i {{ $ctrl.getSort($ctrl.settings.columns[$index]) }}"></i>
+ <i ng-if=":: $ctrl.isSortable($ctrl.settings.columns[$index])" class="crm-i {{ $ctrl.getSort($ctrl.settings.columns[$index]) }}"></i>
<span ng-class="{'crm-draggable': $index || !$ctrl.crmSearchAdmin.groupExists}">{{ $ctrl.settings.columns[$index].label }}</span>
<span ng-switch="$index || !$ctrl.crmSearchAdmin.groupExists ? 'sortable' : 'locked'">
<i ng-switch-when="locked" class="crm-i fa-lock" aria-hidden="true"></i>
sort: [],
+ isSortable: function(col) {
+ return col.type === 'field' && col.sortable !== false;
+ },
+
getSort: function(col) {
var dir = _.reduce(this.sort, function(dir, item) {
return item[0] === col.key ? item[1] : dir;
},
setSort: function(col, $event) {
- if (col.type !== 'field') {
+ if (!this.isSortable(col)) {
return;
}
var dir = this.getSort(col) === 'fa-sort-asc' ? 'DESC' : 'ASC';
<th class="crm-search-result-select" ng-if=":: $ctrl.settings.actions">
<input type="checkbox" ng-disabled="$ctrl.loading || !$ctrl.results.length" ng-checked="$ctrl.allRowsSelected" ng-click="$ctrl.selectAllRows()" >
</th>
- <th ng-repeat="col in $ctrl.settings.columns" ng-click="$ctrl.setSort(col, $event)" title="{{:: col.type === 'field' ? ts('Click to sort results (shift-click to sort by multiple).') : '' }}">
- <i ng-if=":: col.type === 'field'" class="crm-i {{ $ctrl.getSort(col) }}"></i>
+ <th ng-repeat="col in $ctrl.settings.columns" ng-click="$ctrl.setSort(col, $event)" title="{{:: $ctrl.isSortable(col) ? ts('Click to sort results (shift-click to sort by multiple).') : '' }}">
+ <i ng-if=":: $ctrl.isSortable(col)" class="crm-i {{ $ctrl.getSort(col) }}"></i>
<span>{{:: col.label }}</span>
</th>
</tr>