Introduced caching of available columns in query service.

Solves problem of select2 not having available values when loading the columns modal.
pull/1283/head
Richard 11 years ago committed by Till Breuer
parent 750a3ca8aa
commit e820459a0f
  1. 6
      app/assets/javascripts/angular/controllers/dialogs/columns.js
  2. 18
      app/assets/javascripts/angular/services/query-service.js

@ -63,9 +63,9 @@ angular.module('openproject.workPackages.controllers')
// Available Columns
QueryService.getAvailableColumns()
.then(function(data){
$scope.availableColumns = data.available_columns
$scope.availableColumnsData = data.available_columns.map(function(column){
.then(function(available_columns){
$scope.availableColumns = available_columns
$scope.availableColumnsData = available_columns.map(function(column){
return { id: column.name, label: column.title, other: column.title };
});
});

@ -89,15 +89,23 @@ angular.module('openproject.services')
getAvailableUnusedColumns: function(projectIdentifier) {
return QueryService.getAvailableColumns(projectIdentifier)
.then(function(data){
return QueriesHelper.getAvailableColumns(data.available_columns, QueryService.getSelectedColumns());
.then(function(available_columns){
return QueriesHelper.getAvailableColumns(available_columns, QueryService.getSelectedColumns());
});
},
getAvailableColumns: function(projectIdentifier) {
// TODO: Once we have a single page app we need to differentiate between different project columns
if(availableColumns.length) {
return $q.when(availableColumns);
}
var url = projectIdentifier ? PathHelper.apiProjectAvailableColumnsPath(projectIdentifier) : PathHelper.apiAvailableColumnsPath();
return QueryService.doQuery(url)
return QueryService.doGet(url, function(response){
availableColumns = response.data.available_columns;
return availableColumns;
})
},
getSelectedColumns: function() {
@ -228,6 +236,10 @@ angular.module('openproject.services')
});
},
doGet: function(url, success, failure) {
return QueryService.doQuery(url, null, 'GET', success, failure);
},
doQuery: function(url, params, method, success, failure) {
method = method || 'GET';
success = success || function(response){

Loading…
Cancel
Save