Initialize columns on start up, fix js startup errors

pull/1065/head
Till Breuer 11 years ago
parent ebf5bafbbc
commit e770940468
  1. 17
      app/assets/javascripts/angular/controllers/work-packages-controller.js
  2. 4
      app/assets/javascripts/angular/directives/work_packages/work-packages-options-directive.js

@ -10,15 +10,20 @@ angular.module('openproject.workPackages.controllers')
$scope.disableFilters = false;
setupColumns();
};
}
function setupColumns(){
$scope.columns = [];
QueryService.getAvailableColumns($scope.projectIdentifier).then(function(data){
$scope.columns = WorkPackagesTableHelper.getColumnUnionByName(data.available_columns, INITIALLY_SELECTED_COLUMNS);
$scope.availableColumns = WorkPackagesTableHelper.getColumnDifference(data.available_columns, $scope.columns);
return $scope.availableColumns;
}).then(setupQuery).then(setupPagination).then($scope.updateResults)
};
})
.then(setupQuery)
.then(setupPagination)
.then($scope.updateResults);
}
function setupQuery() {
$scope.query = new Query(DEFAULT_QUERY, { available_work_package_filters: AVAILABLE_WORK_PACKAGE_FILTERS});
@ -29,7 +34,7 @@ angular.module('openproject.workPackages.controllers')
angular.extend($scope.query, {
selectedColumns: $scope.columns
});
};
}
function setupPagination(json) {
meta = json || PAGINATION_OPTIONS;
@ -38,7 +43,7 @@ angular.module('openproject.workPackages.controllers')
perPage: meta.per_page
};
$scope.perPageOptions = meta.per_page_options;
};
}
$scope.submitQueryForm = function(){
jQuery("#selected_columns option").attr('selected',true);
@ -65,7 +70,7 @@ angular.module('openproject.workPackages.controllers')
function serviceErrorHandler(data) {
// TODO RS: This is where we'd want to put an error message on the dom
$scope.loading = false;
};
}
/**
* @name withLoading

@ -5,10 +5,10 @@ angular.module('openproject.workPackages.directives')
restrict: 'E',
templateUrl: '/templates/work_packages/work_packages_options.html',
link: function(scope, element, attributes) {
scope.$watch('query.group_by', function() {
scope.$watch('query.group_by', function(groupBy) {
var groupByColumnIndex = scope.columns.map(function(column){
return column.name;
}).indexOf(scope.query.group_by);
}).indexOf(groupBy);
scope.groupByColumn = scope.columns[groupByColumnIndex];
});

Loading…
Cancel
Save