Skip to content

Commit

Permalink
fix documenten tab query params (#1169)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbritense authored and ThomasMinkeRitense committed Sep 20, 2024
1 parent bcb8af6 commit 8369ab0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 30 deletions.
6 changes: 3 additions & 3 deletions projects/valtimo/dossier/src/lib/models/tabs.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ export class TabLoaderImpl implements TabLoader<TabImpl> {
initialTab = this._tabs[0] || null;
}

this.load(initialTab);
this.load(initialTab, true);
}

public load(newTab: TabImpl): void {
public load(newTab: TabImpl, isInitial = false): void {
if (newTab !== this._activeTab) {
this._tabs.forEach(tab => tab.deactivate());
this.replaceView(newTab);
this.replaceUrlState(newTab);
if (!isInitial) this.replaceUrlState(newTab);
this.setActive(newTab);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
uploading: uploading$ | async,
relatedFiles: relatedFiles$ | async,
fields: fields$ | async,
initialSortState: initialSortState$ | async,
supportedDocumentenApiFeatures: supportedDocumentenApiFeatures$ | async
supportedDocumentenApiFeatures: supportedDocumentenApiFeatures$ | async,
} as obs"
>
@if ((!obs.fieldsLoading && obs.fields.length) || obs.fieldsLoading) {
Expand All @@ -31,9 +30,6 @@
[items]="obs.relatedFiles"
[fields]="obs.fields"
[loading]="obs.loading"
[initialSortState]="
obs?.supportedDocumentenApiFeatures?.supportsSortableColumns && obs.initialSortState
"
(rowClicked)="onRowClick($event)"
(sortChanged)="
obs?.supportedDocumentenApiFeatures?.supportsSortableColumns && onSortChanged($event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ export class DossierDetailTabDocumentenApiDocumentsComponent implements OnInit,
combineLatest([
this.documentenApiColumnService.getConfiguredColumns(documentDefinitionName),
this._supportedDocumentenApiFeatures$,
this._sort$,
])
),
map(([columns, supportedDocumentenApiFeatures]) => {
map(([columns, supportedDocumentenApiFeatures, sort]) => {
const defaultSortColumn: ConfiguredColumn | undefined = columns.find(
(column: ConfiguredColumn) => !!column.defaultSort
);
if (!!defaultSortColumn && supportedDocumentenApiFeatures.supportsSortableColumns) {
if (!!defaultSortColumn && !sort && supportedDocumentenApiFeatures.supportsSortableColumns) {
this._sort$.next({sort: `${defaultSortColumn.key},${defaultSortColumn.defaultSort}`});
}

Expand Down Expand Up @@ -153,25 +154,6 @@ export class DossierDetailTabDocumentenApiDocumentsComponent implements OnInit,
filter(documentId => !!documentId)
);

public readonly initialSortState$: Observable<SortState | null> = this.route.queryParamMap.pipe(
map(params => params['params']),
map(params => {
if (!!params['sort']) {
const paramsSplit = params['sort'].split(',');
const state = {
name: paramsSplit[0],
direction: paramsSplit[1],
};

return {
isSorting: true,
state,
};
}
return null;
})
);

public isAdmin: boolean;
public showZaakLinkWarning: boolean;
public uploadProcessLinkedSet = false;
Expand Down Expand Up @@ -256,7 +238,6 @@ export class DossierDetailTabDocumentenApiDocumentsComponent implements OnInit,

public ngOnInit(): void {
this.setInitialFilterAndSort();
this.openQueryParamsSubscription();
this.setUploadProcessLinked();
this.isUserAdmin();
this.iconService.registerAll([Filter16, TagGroup16, Upload16]);
Expand Down Expand Up @@ -456,6 +437,7 @@ export class DossierDetailTabDocumentenApiDocumentsComponent implements OnInit,
.subscribe(({filter, sort}) => {
this._sort$.next({sort});
this.filter$.next(filter);
this.openQueryParamsSubscription();
});
}
}

0 comments on commit 8369ab0

Please sign in to comment.