fix filters not persisted after activating details pane

pull/2044/head
Mihail Maxacov 10 years ago
parent 3aa97b1982
commit 6257be119d
  1. 2
      app/assets/javascripts/angular/routing.js
  2. 10
      app/assets/javascripts/angular/services/work-packages-table-service.js
  3. 25
      app/assets/javascripts/angular/work_packages/controllers/work-packages-list-controller.js
  4. 11
      karma/tests/controllers/work-packages-list-controller-test.js
  5. 2
      public/templates/components/selectable_title.html
  6. 4
      public/templates/work_packages.list.html

@ -60,7 +60,7 @@ angular.module('openproject')
templateUrl: "/templates/work_packages.list.html"
})
.state('work-packages.list.details', {
url: "/{workPackageId:[0-9]+}",
url: "/{workPackageId:[0-9]+}?query_props",
templateUrl: "/templates/work_packages.list.details.html",
controller: 'WorkPackageDetailsController',
resolve: {

@ -34,7 +34,8 @@ angular.module('openproject.workPackages.services')
'WorkPackagesTableHelper',
function($filter, QueryService, WorkPackagesTableHelper) {
var workPackagesTableData = {
allRowsChecked: false
allRowsChecked: false,
showFiltersOptions: false
};
var bulkLinks = {};
@ -167,6 +168,13 @@ angular.module('openproject.workPackages.services')
}
return activeSelectionBorderIndex;
},
getShowFilterOptions: function() {
return workPackagesTableData.showFiltersOptions;
},
toggleShowFilterOptions: function() {
workPackagesTableData.showFiltersOptions = !workPackagesTableData.showFiltersOptions;
}
};

@ -54,7 +54,11 @@ angular.module('openproject.workPackages.controllers')
$scope.operatorsAndLabelsByFilterType = OPERATORS_AND_LABELS_BY_FILTER_TYPE;
$scope.disableFilters = false;
$scope.disableNewWorkPackage = true;
$scope.showFiltersOptions = false;
setupFiltersVisibility();
$scope.toggleShowFilterOptions = function() {
WorkPackagesTableService.toggleShowFilterOptions();
setupFiltersVisibility();
};
var queryParams = $location.search().query_props;
@ -151,7 +155,7 @@ angular.module('openproject.workPackages.controllers')
}
function afterQuerySetupCallback(query) {
$scope.showFiltersOptions = false;
setupFiltersVisibility();
}
function setupWorkPackagesTable(json) {
@ -188,6 +192,10 @@ angular.module('openproject.workPackages.controllers')
AuthorisationService.initModelAuth("query", meta.query._links);
}
function setupFiltersVisibility() {
$scope.showFiltersOptions = WorkPackagesTableService.getShowFilterOptions();
}
function fetchAvailableColumns() {
return QueryService.loadAvailableUnusedColumns($scope.projectIdentifier)
.then(function(data){
@ -277,12 +285,21 @@ angular.module('openproject.workPackages.controllers')
});
$scope.openLatestTab = function() {
$state.go(latestTab.getStateName(), { workPackageId: $scope.preselectedWorkPackageId });
$state.go(latestTab.getStateName(), { workPackageId: $scope.preselectedWorkPackageId, query_props: $location.search().query_props });
};
$scope.closeDetailsView = function() {
// can't use query_props in $state.go since it's not specified
// in the config. if I put it into config, a reload will be triggered
// on each filter change
var path = $state.href("work-packages.list"),
query_props = $location.search().query_props;
$location.url(path).search('query_props', query_props);
}
$scope.showWorkPackageDetails = function(id, force) {
if (force || $state.current.url != "") {
$state.go(latestTab.getStateName(), { workPackageId: id });
$state.go(latestTab.getStateName(), { workPackageId: id, query_props: $location.search().query_props });
}
};
}]);

@ -218,6 +218,17 @@ describe('WorkPackagesListController', function() {
expect(scope.query.id).to.eq(testQueries['1'].id);
expect(scope.showFiltersOptions).to.eq(false);
});
context('second initialisation', function() {
beforeEach(function() {
scope.toggleShowFilterOptions();
buildController(testParams, testState, testLocation);
});
it('should persist the showFiltersOptions value', function() {
expect(scope.showFiltersOptions).to.eq(true);
});
});
});
describe('initialisation of query by id', function() {

@ -25,7 +25,7 @@
<div class="title-group-header">{{ group.name }}</div>
<li ng-repeat="model in group.models" ng-class="{'first': model.highlighted }">
<a href
ui-sref="work-packages.list({ query_id: model.id, query: undefined })"
ui-sref="work-packages.list({ query_id: model.id, query_props: undefined })"
title="{{ model.label }}"
ng-bind-html="model.labelHtml"></a>
</li>

@ -24,7 +24,7 @@
<button id="work-packages-filter-toggle-button"
class="button"
title="{{ getToggleActionLabel(showFiltersOptions) + ' ' + I18n.t('js.button_filter') }}"
ng-click="showFiltersOptions = !showFiltersOptions"
ng-click="toggleShowFilterOptions()"
ng-class="{active: showFiltersOptions}">
<i class="icon-filter-big icon-buttons"></i>{{ I18n.t('js.toolbar.filter') }}
</button>
@ -38,7 +38,7 @@
<button id="work-packages-list-view-button"
class="button"
title="{{ getActivationActionLabel(isDetailsViewActive()) + ' ' + I18n.t('js.button_list_view') }}"
ui-sref="work-packages.list"
ng-click="closeDetailsView()"
ng-class="{ active: !isDetailsViewActive() }">
<i class="icon-table-view icon-buttons"></i>
</button>

Loading…
Cancel
Save