Removing currently selected sortable columns from lists in sorting modal.

pull/1468/head^2
Richard 11 years ago
parent bb797174b1
commit 3f1989c6ad
  1. 15
      app/assets/javascripts/angular/controllers/dialogs/sorting.js
  2. 4
      public/templates/work_packages/modals/sorting.html

@ -45,8 +45,6 @@ angular.module('openproject.workPackages.controllers')
this.name = 'Sorting';
this.closeMe = sortingModal.deactivate;
$scope.sortByOptions = {};
$scope.initSortation = function(){
var currentSortation = QueryService.getSortation();
@ -61,7 +59,13 @@ angular.module('openproject.workPackages.controllers')
};
$scope.getAvailableColumnsData = function(term, result) {
result($filter('filter')($scope.availableColumnsData, { label: term }));
var unselectedColumns = $scope.availableColumnsData
.filter(function(col){
return $scope.sortElements.filter(function(el){ return el.length;})
.map(function(el){ return el[0].id; })
.indexOf(col.id) < 0;
});
result($filter('filter')(unselectedColumns, { label: term }));
};
$scope.getDirectionsData = function(term, result) {
@ -80,17 +84,18 @@ angular.module('openproject.workPackages.controllers')
sortingModal.deactivate();
};
// var blank = { name: null, title: null, sortable: true };
QueryService.loadAvailableColumns()
.then(function(available_columns){
$scope.availableColumns = available_columns;
// available_columns.unshift(blank)
$scope.availableColumnsData = available_columns
.filter(function(column){
return !!column.sortable;
})
.map(function(column){
return { id: column.name, label: column.title, other: column.title };
});
})
$scope.initSortation();
});

@ -8,11 +8,11 @@
<div id="modal-sorting" class="modal-content-container">
<div ng-repeat="element in sortElements">
<input type="hidden"
ui-select2-sortable="sortByOptions"
ui-select2-sortable
simple-query="getAvailableColumnsData"
ng-model="element[0]"></input>
<input type="hidden"
ui-select2-sortable="sortDirectionOptions"
ui-select2-sortable
simple-query="getDirectionsData"
ng-model="element[1]"
ng-required="element[0]"

Loading…
Cancel
Save