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. 20
      frontend/src/app/modules/boards/board/board-actions/status/status-action.service.ts
  5. 14
      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 {BoardService} from "core-app/modules/boards/board/board.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 {BoardActionService} from "core-app/modules/boards/board/board-actions/board-action.service";
import {HalResource} from "core-app/modules/hal/resources/hal-resource";
@ -53,8 +52,8 @@ export class AddListModalComponent extends OpModalComponent implements OnInit {
/** Active board */
public board:Board;
/** Current set of queries */
public queries:QueryResource[];
/** Current active set of values */
public active:Set<string>;
/** Action service used by the board */
public actionService:BoardActionService;
@ -114,11 +113,11 @@ export class AddListModalComponent extends OpModalComponent implements OnInit {
super.ngOnInit();
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
.getAvailableValues(this.board, this.queries)
.getAvailableValues(this.board, this.active)
.then(available => {
this.availableValues = available;
if (this.availableValues.length === 0) {

@ -98,17 +98,13 @@ export class BoardAssigneeActionService implements BoardActionService {
* queries in the board.
*
* @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[]> {
const active = new Set(
queries.map(query => this.getFilterHref(query))
);
public getAvailableValues(board:Board, active:Set<string>):Promise<HalResource[]> {
return this
.getAssignees()
.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
*
* @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

@ -82,10 +82,12 @@ export class BoardStatusActionService implements BoardActionService {
name: value.name,
};
let filter = { status: {
operator: '=' as FilterOperator,
values: [value.id]
}};
let filter = {
status: {
operator: '=' as FilterOperator,
values: [value.id]
}
};
return this.boardListsService.addQuery(board, params, [filter]);
}
@ -95,16 +97,12 @@ export class BoardStatusActionService implements BoardActionService {
* queries in the board.
*
* @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[]> {
const active = new Set(
queries.map(query => this.getFilterHref(query))
);
public getAvailableValues(board:Board, active:Set<string>):Promise<HalResource[]> {
return this.getStatuses()
.then(results =>
results.filter(status => !active.has(status.href!))
results.filter(status => !active.has(status.id!))
);
}

@ -70,7 +70,7 @@ export class BoardVersionActionService implements BoardActionService {
}
public canAddToQuery(query:QueryResource):Promise<boolean> {
const formLink = _.get(query, 'results.createWorkPackage.href', null) ;
const formLink = _.get(query, 'results.createWorkPackage.href', null);
if (!formLink) {
return Promise.resolve(false);
@ -118,16 +118,12 @@ export class BoardVersionActionService implements BoardActionService {
* queries in the board.
*
* @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[]> {
const active = new Set(
queries.map(query => this.getFilterHref(query))
);
public getAvailableValues(board:Board, active:Set<string>):Promise<HalResource[]> {
return this.getVersions()
.then(results =>
results.filter(version => !active.has(version.href!))
results.filter(version => !active.has(version.id!))
);
}
@ -186,7 +182,7 @@ export class BoardVersionActionService implements BoardActionService {
private patchVersionStatus(version:VersionResource, newStatus:'open'|'closed'|'locked') {
this.versionDm
.patch(version, {status: newStatus })
.patch(version, { status: newStatus })
.then((version) => {
this.versionCache.updateValue(version.id!, version);
this.state.go('.', {}, { reload: true });

@ -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 {QueryUpdatedService} from "core-app/modules/boards/board/query-updated/query-updated.service";
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 {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";
@ -130,11 +130,11 @@ export class BoardListContainerComponent extends UntilDestroyedMixin implements
})
.catch(error => this.showError(error));
} else {
const queries = this.lists.map(list => list.query);
const active = this.getActionFiltersFromWidget(board);
this.opModalService.show(
AddListModalComponent,
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 interface BoardWidgetOption {
queryId:string;
filters:ApiV3Filter[];
}
export class Board {
constructor(public grid:GridResource) {
}

Loading…
Cancel
Save