Memoize availableUnusedColumn in angular query service

pull/1309/head
Till Breuer 11 years ago
parent 558a60dadf
commit bf273a8b9d
  1. 8
      app/assets/javascripts/angular/services/query-service.js

@ -99,6 +99,10 @@ angular.module('openproject.services')
return totalEntries; return totalEntries;
}, },
getAvailableUnusedColumns: function() {
return availableUnusedColumns;
},
hideColumns: function(columnNames) { hideColumns: function(columnNames) {
WorkPackagesTableHelper.moveColumns(columnNames, this.getSelectedColumns(), availableColumns); WorkPackagesTableHelper.moveColumns(columnNames, this.getSelectedColumns(), availableColumns);
}, },
@ -116,6 +120,10 @@ angular.module('openproject.services')
}, },
loadAvailableUnusedColumns: function(projectIdentifier) { loadAvailableUnusedColumns: function(projectIdentifier) {
if(availableUnusedColumns.length) {
return $q.when(availableUnusedColumns);
}
return QueryService.loadAvailableColumns(projectIdentifier) return QueryService.loadAvailableColumns(projectIdentifier)
.then(function(available_columns) { .then(function(available_columns) {
availableUnusedColumns = WorkPackagesTableHelper.getColumnDifference(available_columns, QueryService.getSelectedColumns()); availableUnusedColumns = WorkPackagesTableHelper.getColumnDifference(available_columns, QueryService.getSelectedColumns());

Loading…
Cancel
Save