Merge pull request #8429 from opf/fix/33346/add-list-modal

[33346] Derive available values for Board AddListModal from widget options
pull/8435/head
Henriette Darge 4 years ago committed by GitHub
commit 7cd646194b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
  2. 10
      frontend/src/app/modules/boards/board/board-actions/assignee/assignee-action.service.ts
  3. 5
      frontend/src/app/modules/boards/board/board-actions/board-action.service.ts
  4. 16
      frontend/src/app/modules/boards/board/board-actions/status/status-action.service.ts
  5. 10
      frontend/src/app/modules/boards/board/board-actions/version/version-action.service.ts
  6. 26
      frontend/src/app/modules/boards/board/board-partitioned-page/board-list-container.component.ts
  7. 5
      frontend/src/app/modules/boards/board/board.ts

@ -35,7 +35,6 @@ import {Board} from "core-app/modules/boards/board/board";
import {StateService} from "@uirouter/core"; import {StateService} from "@uirouter/core";
import {BoardService} from "core-app/modules/boards/board/board.service"; import {BoardService} from "core-app/modules/boards/board/board.service";
import {BoardCacheService} from "core-app/modules/boards/board/board-cache.service"; import {BoardCacheService} from "core-app/modules/boards/board/board-cache.service";
import {QueryResource} from "core-app/modules/hal/resources/query-resource";
import {BoardActionsRegistryService} from "core-app/modules/boards/board/board-actions/board-actions-registry.service"; import {BoardActionsRegistryService} from "core-app/modules/boards/board/board-actions/board-actions-registry.service";
import {BoardActionService} from "core-app/modules/boards/board/board-actions/board-action.service"; import {BoardActionService} from "core-app/modules/boards/board/board-actions/board-action.service";
import {HalResource} from "core-app/modules/hal/resources/hal-resource"; import {HalResource} from "core-app/modules/hal/resources/hal-resource";
@ -53,8 +52,8 @@ export class AddListModalComponent extends OpModalComponent implements OnInit {
/** Active board */ /** Active board */
public board:Board; public board:Board;
/** Current set of queries */ /** Current active set of values */
public queries:QueryResource[]; public active:Set<string>;
/** Action service used by the board */ /** Action service used by the board */
public actionService:BoardActionService; public actionService:BoardActionService;
@ -114,11 +113,11 @@ export class AddListModalComponent extends OpModalComponent implements OnInit {
super.ngOnInit(); super.ngOnInit();
this.board = this.locals.board; this.board = this.locals.board;
this.queries = this.locals.queries; this.active = new Set(this.locals.active as string[]);
this.actionService = this.boardActions.get(this.board.actionAttribute!); this.actionService = this.boardActions.get(this.board.actionAttribute!);
this.actionService this.actionService
.getAvailableValues(this.board, this.queries) .getAvailableValues(this.board, this.active)
.then(available => { .then(available => {
this.availableValues = available; this.availableValues = available;
if (this.availableValues.length === 0) { if (this.availableValues.length === 0) {

@ -98,17 +98,13 @@ export class BoardAssigneeActionService implements BoardActionService {
* queries in the board. * queries in the board.
* *
* @param board The board we're looking at * @param board The board we're looking at
* @param queries The active set of queries * @param active The active set of values (hrefs)
*/ */
public getAvailableValues(board:Board, queries:QueryResource[]):Promise<HalResource[]> { public getAvailableValues(board:Board, active:Set<string>):Promise<HalResource[]> {
const active = new Set(
queries.map(query => this.getFilterHref(query))
);
return this return this
.getAssignees() .getAssignees()
.then(results => .then(results =>
results.filter(assignee => !active.has(assignee.href!)) results.filter(assignee => !active.has(assignee.id!))
); );
} }

@ -40,8 +40,11 @@ export interface BoardActionService {
/** /**
* Get available values from the active queries * Get available values from the active queries
*
* @param board The board we're looking at
* @param active The active set of values (hrefs or plain values)
*/ */
getAvailableValues(board:Board, queries:QueryResource[]):Promise<HalResource[]>; getAvailableValues(board:Board, active:Set<string>):Promise<HalResource[]>;
/** /**
* Get action specific items that shall be shown in the list menu * Get action specific items that shall be shown in the list menu

@ -82,10 +82,12 @@ export class BoardStatusActionService implements BoardActionService {
name: value.name, name: value.name,
}; };
let filter = { status: { let filter = {
status: {
operator: '=' as FilterOperator, operator: '=' as FilterOperator,
values: [value.id] values: [value.id]
}}; }
};
return this.boardListsService.addQuery(board, params, [filter]); return this.boardListsService.addQuery(board, params, [filter]);
} }
@ -95,16 +97,12 @@ export class BoardStatusActionService implements BoardActionService {
* queries in the board. * queries in the board.
* *
* @param board The board we're looking at * @param board The board we're looking at
* @param queries The active set of queries * @param active The active set of values (hrefs or plain values)
*/ */
public getAvailableValues(board:Board, queries:QueryResource[]):Promise<HalResource[]> { public getAvailableValues(board:Board, active:Set<string>):Promise<HalResource[]> {
const active = new Set(
queries.map(query => this.getFilterHref(query))
);
return this.getStatuses() return this.getStatuses()
.then(results => .then(results =>
results.filter(status => !active.has(status.href!)) results.filter(status => !active.has(status.id!))
); );
} }

@ -118,16 +118,12 @@ export class BoardVersionActionService implements BoardActionService {
* queries in the board. * queries in the board.
* *
* @param board The board we're looking at * @param board The board we're looking at
* @param queries The active set of queries * @param active The active set of values (hrefs or plain values)
*/ */
public getAvailableValues(board:Board, queries:QueryResource[]):Promise<HalResource[]> { public getAvailableValues(board:Board, active:Set<string>):Promise<HalResource[]> {
const active = new Set(
queries.map(query => this.getFilterHref(query))
);
return this.getVersions() return this.getVersions()
.then(results => .then(results =>
results.filter(version => !active.has(version.href!)) results.filter(version => !active.has(version.id!))
); );
} }

@ -13,7 +13,7 @@ import {BannersService} from "core-app/modules/common/enterprise/banners.service
import {DragAndDropService} from "core-app/modules/common/drag-and-drop/drag-and-drop.service"; import {DragAndDropService} from "core-app/modules/common/drag-and-drop/drag-and-drop.service";
import {QueryUpdatedService} from "core-app/modules/boards/board/query-updated/query-updated.service"; import {QueryUpdatedService} from "core-app/modules/boards/board/query-updated/query-updated.service";
import {UntilDestroyedMixin} from "core-app/helpers/angular/until-destroyed.mixin"; import {UntilDestroyedMixin} from "core-app/helpers/angular/until-destroyed.mixin";
import {Board} from "core-app/modules/boards/board/board"; import {Board, BoardWidgetOption} from "core-app/modules/boards/board/board";
import {CdkDragDrop, moveItemInArray} from "@angular/cdk/drag-drop"; import {CdkDragDrop, moveItemInArray} from "@angular/cdk/drag-drop";
import {GridWidgetResource} from "core-app/modules/hal/resources/grid-widget-resource"; import {GridWidgetResource} from "core-app/modules/hal/resources/grid-widget-resource";
import {BoardPartitionedPageComponent} from "core-app/modules/boards/board/board-partitioned-page/board-partitioned-page.component"; import {BoardPartitionedPageComponent} from "core-app/modules/boards/board/board-partitioned-page/board-partitioned-page.component";
@ -130,11 +130,11 @@ export class BoardListContainerComponent extends UntilDestroyedMixin implements
}) })
.catch(error => this.showError(error)); .catch(error => this.showError(error));
} else { } else {
const queries = this.lists.map(list => list.query); const active = this.getActionFiltersFromWidget(board);
this.opModalService.show( this.opModalService.show(
AddListModalComponent, AddListModalComponent,
this.injector, this.injector,
{ board: board, queries: queries } { board: board, active: active }
); );
} }
} }
@ -183,4 +183,24 @@ export class BoardListContainerComponent extends UntilDestroyedMixin implements
}); });
} }
/**
* Returns the current filter values for an action board.
* By extracting them from the widget options, we can avoid waiting for the queries
* to be loaded for each list
*
* @param board
*/
private getActionFiltersFromWidget(board:Board):string[] {
return board.grid.widgets
.map(widget => {
const options:BoardWidgetOption = widget.options as any;
const filter = _.find(options.filters, (filter) => !!filter[board.actionAttribute!]);
if (filter) {
return filter[board.actionAttribute!].values[0];
}
})
.filter(value => !!value);
}
} }

@ -5,6 +5,11 @@ import {ApiV3Filter} from "core-components/api/api-v3/api-v3-filter-builder";
export type BoardType = 'free'|'action'; export type BoardType = 'free'|'action';
export interface BoardWidgetOption {
queryId:string;
filters:ApiV3Filter[];
}
export class Board { export class Board {
constructor(public grid:GridResource) { constructor(public grid:GridResource) {
} }

Loading…
Cancel
Save