Skip to content

Commit

Permalink
chore: TRACEFOSS-2726 added deeplinks
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-mwesener committed Nov 24, 2023
1 parent 3f296c6 commit 62e62f1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
16 changes: 15 additions & 1 deletion frontend/src/app/modules/core/user/table-settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import { Injectable } from '@angular/core';
import { PartTableType } from '@shared/components/table/table.model';
import { Subject } from 'rxjs';
import {TableViewConfig} from "@shared/components/parts-table/table-view-config.model";

@Injectable({
providedIn: 'root',
Expand All @@ -28,7 +29,7 @@ export class TableSettingsService {
private settingsKey = 'TableViewSettings';
private changeEvent = new Subject<void>();

storeTableSettings(partTableType: PartTableType, tableSettingsList: any ): void {
storeTableSettings(tableSettingsList: any ): void {
// before setting anything, all maps in new tableSettingList should be stringified
Object.keys(tableSettingsList).forEach(tableSetting => {
console.log(tableSetting, "settings");
Expand All @@ -52,6 +53,19 @@ export class TableSettingsService {
return settingsObject;
}

storedTableSettingsInvalid(tableViewConfig: TableViewConfig, tableType: PartTableType):boolean{
let isInvalid = false;
const storage = this.getStoredTableSettings();
for (const col of tableViewConfig.displayedColumns.values()){
if (!storage[tableType].columnsForDialog.include(col)){
console.warn("Found issue in tablesettings", col);
isInvalid = true;
}
}
localStorage.removeItem(this.settingsKey);
return isInvalid;
}

emitChangeEvent() {
this.changeEvent.next();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import {
} from "@shared/components/parts-table/parts-as-planned-customer-configuration.model";
import {Router} from "@angular/router";
import {ALERT_BASE_ROUTE, INVESTIGATION_BASE_ROUTE} from "@core/known-route";
import {ToastService} from "@shared/components/toasts/toast.service";


@Component({
Expand Down Expand Up @@ -138,7 +139,11 @@ export class PartsTableComponent implements OnInit {
@Output() clickSelectAction = new EventEmitter<void>();
@Output() filterActivated = new EventEmitter<any>();

constructor(private readonly tableSettingsService: TableSettingsService, private dialog: MatDialog, private router: Router) {
constructor(
private readonly tableSettingsService: TableSettingsService,
private dialog: MatDialog,
private router: Router,
private toastService: ToastService) {
}


Expand Down Expand Up @@ -246,6 +251,10 @@ export class PartsTableComponent implements OnInit {

private setupTableViewSettings() {
const tableSettingsList = this.tableSettingsService.getStoredTableSettings();

if (this.tableSettingsService.storedTableSettingsInvalid(this.tableViewConfig, this.tableType)){

}
// check if there are table settings list
if (tableSettingsList) {
// if yes, check if there is a table-setting for this table type
Expand All @@ -260,7 +269,7 @@ export class PartsTableComponent implements OnInit {
columnsForTable: this.tableViewConfig.displayedColumns,
filterColumnsForTable: this.tableViewConfig.filterColumns
};
this.tableSettingsService.storeTableSettings(this.tableType, tableSettingsList);
this.tableSettingsService.storeTableSettings(tableSettingsList);
this.setupTableConfigurations(this.tableViewConfig.displayedColumns, this.tableViewConfig.filterColumns, this.tableViewConfig.sortableColumns, this.tableViewConfig.displayFilterColumnMappings, this.tableViewConfig.filterFormGroup);
}
} else {
Expand All @@ -273,7 +282,7 @@ export class PartsTableComponent implements OnInit {
filterColumnsForTable: this.tableViewConfig.filterColumns
}
}
this.tableSettingsService.storeTableSettings(this.tableType, newTableSettingsList);
this.tableSettingsService.storeTableSettings(newTableSettingsList);
this.setupTableConfigurations(this.tableViewConfig.displayedColumns, this.tableViewConfig.filterColumns, this.tableViewConfig.sortableColumns, this.tableViewConfig.displayFilterColumnMappings, this.tableViewConfig.filterFormGroup);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class TableSettingsComponent {
} as TableViewSettings;

// save all values back to localstorage
this.tableSettingsService.storeTableSettings(this.tableType, tableSettingsList);
this.tableSettingsService.storeTableSettings(tableSettingsList);

// trigger action that table will refresh
this.tableSettingsService.emitChangeEvent();
Expand Down

0 comments on commit 62e62f1

Please sign in to comment.