Merge pull request #7191 from opf/fix/29905/do-not-save-board-filters

[29905] Do not save board filters unless explicitly saved
pull/7195/head
Henriette Dinger 6 years ago committed by GitHub
commit 37eb61b3c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      frontend/src/app/modules/boards/board/board-filter/board-filter.component.ts
  2. 3
      frontend/src/app/modules/boards/board/board.component.html
  3. 9
      frontend/src/app/modules/boards/board/board.component.ts

@ -21,9 +21,16 @@ import {ApiV3Filter} from "core-components/api/api-v3/api-v3-filter-builder";
templateUrl: './board-filter.component.html' templateUrl: './board-filter.component.html'
}) })
export class BoardFilterComponent implements OnInit, OnDestroy { export class BoardFilterComponent implements OnInit, OnDestroy {
/** Current active */
@Input() public board:Board; @Input() public board:Board;
@Output() public filters = new DebouncedEventEmitter<ApiV3Filter[]>(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<ApiV3Filter[]>(componentDestroyed(this));
constructor(private readonly currentProjectService:CurrentProjectService, constructor(private readonly currentProjectService:CurrentProjectService,
private readonly querySpace:IsolatedQuerySpace, private readonly querySpace:IsolatedQuerySpace,
@ -62,16 +69,16 @@ export class BoardFilterComponent implements OnInit, OnDestroy {
let filterHash = this.urlParamsHelper.buildV3GetFilters(filters); let filterHash = this.urlParamsHelper.buildV3GetFilters(filters);
let query_props = JSON.stringify(filterHash); 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() { private loadQueryForm() {
this.queryFormDm this.queryFormDm
.loadWithParams( .loadWithParams(
{ filters: JSON.stringify(this.board.filters) }, {filters: JSON.stringify(this.filters)},
undefined, undefined,
this.currentProjectService.id this.currentProjectService.id
) )

@ -48,7 +48,8 @@
<div class="boards-filters-container"> <div class="boards-filters-container">
<board-filter [board]="board" <board-filter [board]="board"
(filters)="updateFilters($event)"></board-filter> [filters]="filters"
(onFiltersChanged)="updateFilters($event)"></board-filter>
</div> </div>
</ng-container> </ng-container>

@ -89,7 +89,7 @@ export class BoardComponent implements OnInit, OnDestroy {
.subscribe(board => { .subscribe(board => {
this.board = board; this.board = board;
let queryProps = this.state.params.query_props; 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) { if (!initialized) {
this.dynamicCss.requireHighlighting(); this.dynamicCss.requireHighlighting();
@ -105,14 +105,14 @@ export class BoardComponent implements OnInit, OnDestroy {
saveWithNameAndFilters(board:Board, newName:string) { saveWithNameAndFilters(board:Board, newName:string) {
board.name = newName; board.name = newName;
board.filters = this.filters; board.filters = this.filters;
return this.saveBoard(board); return this.saveBoard(board, true);
} }
showError(text = this.text.loadingError) { showError(text = this.text.loadingError) {
this.notifications.addError(text); this.notifications.addError(text);
} }
saveBoard(board:Board) { saveBoard(board:Board, resetFilters = false) {
this.inFlight = true; this.inFlight = true;
this.Boards this.Boards
.save(board) .save(board)
@ -120,7 +120,8 @@ export class BoardComponent implements OnInit, OnDestroy {
this.BoardCache.update(board); this.BoardCache.update(board);
this.notifications.addSuccess(this.text.updateSuccessful); this.notifications.addSuccess(this.text.updateSuccessful);
this.inFlight = false; 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}});
}); });
} }

Loading…
Cancel
Save