Include blank option in sorting dialog

pull/1473/head
Till Breuer 11 years ago
parent 9c0796b981
commit 44d841f204
  1. 9
      app/assets/javascripts/angular/controllers/dialogs/sorting.js
  2. 17
      karma/tests/dialogs/sorting-modal-test.js

@ -98,22 +98,25 @@ angular.module('openproject.workPackages.controllers')
sortingModal.deactivate();
};
// var blank = { name: null, title: null, sortable: true };
// setup
$scope.availableDirectionsData = [{ id: 'desc', label: I18n.t('js.label_descending')}, { id: 'asc', label: I18n.t('js.label_ascending')}];
var blankOption = { id: null, label: ' ', other: null };
QueryService.loadAvailableColumns()
.then(function(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.availableColumnsData.unshift(blankOption);
$scope.initSortation();
});

@ -83,11 +83,14 @@ describe('sortingModal', function() {
});
it('formats the columns for select2', function() {
expect(scope.availableColumnsData).to.deep.equal([
{id: 'parent', label: 'Parent', other: 'Parent'},
{id: 'cheese', label: 'Cheesy column', other: 'Cheesy column'},
{id: 'cake', label: 'Cake', other: 'Cake'}
]);
var columnData = scope.availableColumnsData[1];
expect(columnData).to.have.property('id', 'parent');
expect(columnData).to.have.property('label', 'Parent');
});
it('includes a blank option as the first option', function() {
expect(scope.availableColumnsData[0]).to.deep.equal({ id: null, label: ' ', other: null });
});
});
@ -121,8 +124,8 @@ describe('sortingModal', function() {
});
it('subtracts the sort elements from the selectable sort options', function() {
expect(selectableColumns).to.have.length(2);
expect(selectableColumns).to.not.contain(scope.availableColumnsData[0]);
expect(selectableColumns).to.have.length(3);
expect(selectableColumns).to.not.contain(scope.availableColumnsData[1]);
});
});

Loading…
Cancel
Save