From daa0f9569e226d4b4b1dcf606fdcd59ce81fd4c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 9 Apr 2019 08:06:09 +0200 Subject: [PATCH] [29905] Do not save board filters unless explicitly saved https://community.openproject.com/wp/29905 --- .../board/board-filter/board-filter.component.ts | 15 +++++++++++---- .../app/modules/boards/board/board.component.html | 3 ++- .../app/modules/boards/board/board.component.ts | 9 +++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/frontend/src/app/modules/boards/board/board-filter/board-filter.component.ts b/frontend/src/app/modules/boards/board/board-filter/board-filter.component.ts index bf365e1129..dd94eb7ea5 100644 --- a/frontend/src/app/modules/boards/board/board-filter/board-filter.component.ts +++ b/frontend/src/app/modules/boards/board/board-filter/board-filter.component.ts @@ -21,9 +21,16 @@ import {ApiV3Filter} from "core-components/api/api-v3/api-v3-filter-builder"; templateUrl: './board-filter.component.html' }) export class BoardFilterComponent implements OnInit, OnDestroy { + /** Current active */ @Input() public board:Board; - @Output() public filters = new DebouncedEventEmitter(componentDestroyed(this)); + /** Transient set of active filters + * Either from saved board (then filters === board.filters) + * or from the unsaved query props + */ + @Input() public filters:ApiV3Filter[]; + + @Output() public onFiltersChanged = new DebouncedEventEmitter(componentDestroyed(this)); constructor(private readonly currentProjectService:CurrentProjectService, private readonly querySpace:IsolatedQuerySpace, @@ -62,16 +69,16 @@ export class BoardFilterComponent implements OnInit, OnDestroy { let filterHash = this.urlParamsHelper.buildV3GetFilters(filters); let query_props = JSON.stringify(filterHash); - this.filters.emit(filterHash); + this.onFiltersChanged.emit(filterHash); - this.$state.go('.', { query_props: query_props }, {custom: {notify: false}}); + this.$state.go('.', {query_props: query_props}, {custom: {notify: false}}); }); } private loadQueryForm() { this.queryFormDm .loadWithParams( - { filters: JSON.stringify(this.board.filters) }, + {filters: JSON.stringify(this.filters)}, undefined, this.currentProjectService.id ) diff --git a/frontend/src/app/modules/boards/board/board.component.html b/frontend/src/app/modules/boards/board/board.component.html index f92fe955a7..ff735430ff 100644 --- a/frontend/src/app/modules/boards/board/board.component.html +++ b/frontend/src/app/modules/boards/board/board.component.html @@ -48,7 +48,8 @@
+ [filters]="filters" + (onFiltersChanged)="updateFilters($event)">
diff --git a/frontend/src/app/modules/boards/board/board.component.ts b/frontend/src/app/modules/boards/board/board.component.ts index 51c4a50970..641281be1d 100644 --- a/frontend/src/app/modules/boards/board/board.component.ts +++ b/frontend/src/app/modules/boards/board/board.component.ts @@ -89,7 +89,7 @@ export class BoardComponent implements OnInit, OnDestroy { .subscribe(board => { this.board = board; let queryProps = this.state.params.query_props; - this.filters = this.board.filters = queryProps ? JSON.parse(queryProps) : this.board.filters; + this.filters = queryProps ? JSON.parse(queryProps) : this.board.filters; if (!initialized) { this.dynamicCss.requireHighlighting(); @@ -105,14 +105,14 @@ export class BoardComponent implements OnInit, OnDestroy { saveWithNameAndFilters(board:Board, newName:string) { board.name = newName; board.filters = this.filters; - return this.saveBoard(board); + return this.saveBoard(board, true); } showError(text = this.text.loadingError) { this.notifications.addError(text); } - saveBoard(board:Board) { + saveBoard(board:Board, resetFilters = false) { this.inFlight = true; this.Boards .save(board) @@ -120,7 +120,8 @@ export class BoardComponent implements OnInit, OnDestroy { this.BoardCache.update(board); this.notifications.addSuccess(this.text.updateSuccessful); this.inFlight = false; - this.state.go('.', { query_props: null, isNew: false }, {custom: {notify: false}}); + let params = { isNew: false, query_props: (resetFilters ? null : this.state.params.query_props) }; + this.state.go('.', params, {custom: {notify: false}}); }); }