Skip to content

Commit

Permalink
fix: filter favorites in aas-table
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfaron committed Feb 12, 2024
1 parent 03c8783 commit 08dec6f
Show file tree
Hide file tree
Showing 27 changed files with 918 additions and 254 deletions.
3 changes: 3 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"CONTENT_ROOT": "projects/aas-server/build",
"WEB_ROOT": "projects/aas-portal/dist",
"ASSETS": "projects/aas-server/src/assets",
"USER_STORAGE": "mongodb://localhost:27017/aasportal-users",
// "TEMPLATE_STORAGE": "http://localhost:8080/templates",
// "AAS_INDEX": "mysql://localhost:3306",
"ENDPOINTS": "[\"file:///endpoints/samples?name=Samples\"]",
}
},
Expand Down
3 changes: 3 additions & 0 deletions projects/aas-lib/src/lib/aas-table/aas-table.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum AASTableActionType {
TOGGLE_SELECTIONS = '[AASTable] toggle selections',
SET_SELECTIONS = '[AASTable] set selections',
UPDATE_VIEW = '[AASTable] update view',
SET_FILTER = '[AASTable] set filter',
}

export interface UpdateViewAction extends TypedAction<AASTableActionType.UPDATE_VIEW> {
Expand All @@ -45,3 +46,5 @@ export const setSelections = createAction(AASTableActionType.SET_SELECTIONS, pro
export const expandRow = createAction(AASTableActionType.EXPAND, props<{ row: AASTableRow }>());

export const collapseRow = createAction(AASTableActionType.COLLAPSE, props<{ row: AASTableRow }>());

export const setFilter = createAction(AASTableActionType.SET_FILTER, props<{ filter?: string }>());
21 changes: 20 additions & 1 deletion projects/aas-lib/src/lib/aas-table/aas-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { AASQuery } from '../types/aas-query-params';
import { ClipboardService } from '../clipboard.service';
import { WindowService } from '../window.service';
import { ViewMode } from '../types/view-mode';
import { TranslateService } from '@ngx-translate/core';

@Component({
selector: 'fhg-aas-table',
Expand All @@ -29,17 +30,19 @@ export class AASTableComponent implements OnInit, OnChanges, OnDestroy {
private readonly store: Store<AASTableFeatureState>;
private readonly subscription: Subscription = new Subscription();
private _selected: AASDocument[] = [];
private _filter: Observable<string> | null = null;
private shiftKey = false;
private altKey = false;

public constructor(
private readonly router: Router,
private readonly translate: TranslateService,
store: Store,
private readonly clipboard: ClipboardService,
private readonly window: WindowService,
) {
this.store = store as Store<AASTableFeatureState>;
this.rows = this.store.select(AASTableSelectors.selectRows);
this.rows = this.store.select(AASTableSelectors.selectRows(this.translate));
this.everySelected = this.store.select(AASTableSelectors.selectEverySelected);
this.someSelected = this.store.select(AASTableSelectors.selectSomeSelected);

Expand Down Expand Up @@ -68,6 +71,22 @@ export class AASTableComponent implements OnInit, OnChanges, OnDestroy {
return this._selected;
}

@Input()
public get filter(): Observable<string> | null {
return this._filter;
}

public set filter(value: Observable<string> | null) {
if (value !== this._filter) {
this._filter = value;
if (this._filter) {
this.subscription.add(
this._filter.subscribe(value => this.store.dispatch(AASTableActions.setFilter({ filter: value }))),
);
}
}
}

public set selected(values: AASDocument[]) {
if (!equalArray(this._selected, values)) {
this.store.dispatch(AASTableActions.setSelections({ documents: values }));
Expand Down
Loading

0 comments on commit 08dec6f

Please sign in to comment.