From 3f1989c6ad824ee31f4d39ce7699d76534fe4268 Mon Sep 17 00:00:00 2001 From: Richard Date: Fri, 13 Jun 2014 15:02:41 +0100 Subject: [PATCH] Removing currently selected sortable columns from lists in sorting modal. --- .../angular/controllers/dialogs/sorting.js | 15 ++++++++++----- .../templates/work_packages/modals/sorting.html | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/angular/controllers/dialogs/sorting.js b/app/assets/javascripts/angular/controllers/dialogs/sorting.js index 4eb06e8094..31a7812d86 100644 --- a/app/assets/javascripts/angular/controllers/dialogs/sorting.js +++ b/app/assets/javascripts/angular/controllers/dialogs/sorting.js @@ -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(); }); diff --git a/public/templates/work_packages/modals/sorting.html b/public/templates/work_packages/modals/sorting.html index 7bc376356b..b85cf7c336 100644 --- a/public/templates/work_packages/modals/sorting.html +++ b/public/templates/work_packages/modals/sorting.html @@ -8,11 +8,11 @@