Skip to content
Snippets Groups Projects
Commit d4a24516 authored by Florent Poittevin's avatar Florent Poittevin
Browse files

fix: aip list preserve previously org unit retrieve

parent eb30899c
No related branches found
No related tags found
No related merge requests found
......@@ -69,7 +69,7 @@ import {
styleUrls: ["../../../../../../shared/components/routables/shared-abstract-list/shared-abstract-list.routable.scss"],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AipListRoutable extends SharedAbstractListRoutable<AipExtended, PreservationAipStateModel> implements OnInit {
export class AipListRoutable extends SharedAbstractListRoutable<AipExtended, PreservationAipStateModel> implements OnInit, OnDestroy {
readonly KEY_BACK_BUTTON: string | undefined = TRANSLATE("preservation.aip.button.back");
readonly KEY_CREATE_BUTTON: string = undefined;
readonly KEY_PARAM_NAME: keyof AipExtended & string = undefined;
......@@ -82,28 +82,28 @@ export class AipListRoutable extends SharedAbstractListRoutable<AipExtended, Pre
listObs: Observable<AipExtended[]> = this.listAdaptedBS.asObservable();
listOriginObs: Observable<AipExtended[]> = ResourceState.list(this.store, PreservationAipState);
FIRST_TAB_INDEX: number = 0;
SECOND_TAB_INDEX: number = 1;
THIRD_TAB_INDEX: number = 2;
All_TAB_INDEX: number = 0;
UNIT_TAB_INDEX: number = 1;
COLLECTION_TAB_INDEX: number = 2;
storagion_number: number | undefined = undefined;
@Input()
set archivalUnit(value: number) {
// TODO Retrieve this info from url, this component is a routable so it should be instanciate by routing
if (value === this.SECOND_TAB_INDEX) {
if (value === this.UNIT_TAB_INDEX) {
this.getAipListWithParameter(true);
} else if (value === this.THIRD_TAB_INDEX) {
} else if (value === this.COLLECTION_TAB_INDEX) {
this.getAipListWithParameter(false);
} else {
this.getAipListWithParameter(undefined);
}
}
constructor(protected store: Store,
constructor(protected readonly store: Store,
protected readonly _route: ActivatedRoute,
protected _changeDetector: ChangeDetectorRef,
private translate: TranslateService,
protected readonly _changeDetector: ChangeDetectorRef,
private readonly translate: TranslateService,
protected readonly _actions$: Actions,
protected readonly _dialog: MatDialog) {
super(store, _changeDetector, _route, _actions$, _dialog, LocalStateEnum.preservation_aip, aipActionNameSpace, {
......@@ -116,18 +116,6 @@ export class AipListRoutable extends SharedAbstractListRoutable<AipExtended, Pre
this.storagion_number = +this._route.snapshot.paramMap.get(AppRoutesEnum.paramIdWithoutPrefixParam);
this.subscribe(
this.listOriginObs.pipe(
distinctUntilChanged(),
filter(list => !isNullOrUndefined(list)),
tap(list => {
let listOfOrgId = list.map(aip => aip.info.organizationalUnitId);
listOfOrgId = ArrayUtil.distinct(listOfOrgId);
this.store.dispatch(new PreservationAipOrgUnitAction.GetByListId(listOfOrgId));
this.listAdaptedBS.next(list);
}),
),
);
this.subscribe(
this._actions$.pipe(
ofActionCompleted(PreservationAipOrgUnitAction.GetByListIdSuccess),
......@@ -146,7 +134,21 @@ export class AipListRoutable extends SharedAbstractListRoutable<AipExtended, Pre
});
this.listAdaptedBS.next(newList);
}),
));
),
);
this.subscribe(
this.listOriginObs.pipe(
distinctUntilChanged(),
filter(list => !isNullOrUndefined(list)),
tap(list => {
let listOfOrgId = list.map(aip => aip.info.organizationalUnitId);
listOfOrgId = ArrayUtil.distinct(listOfOrgId);
this.store.dispatch(new PreservationAipOrgUnitAction.GetByListId(listOfOrgId, true));
this.listAdaptedBS.next(list);
}),
),
);
}
// @override
......@@ -212,9 +214,11 @@ export class AipListRoutable extends SharedAbstractListRoutable<AipExtended, Pre
}
getOrganizationalUnitNameFromId(resId: string, listOrgUnits: AccessOrganizationalUnit[]): string {
const orgUnits = listOrgUnits.find(o => o.resId === resId);
if (orgUnits) {
return orgUnits.name;
if (!isNullOrUndefined(listOrgUnits)) {
const orgUnits = listOrgUnits.find(o => o.resId === resId);
if (orgUnits) {
return orgUnits.name;
}
}
return this.translate.instant("access.organizationalUnitNotFound");
}
......@@ -238,4 +242,8 @@ export class AipListRoutable extends SharedAbstractListRoutable<AipExtended, Pre
back(): void {
this._store.dispatch(new Navigate([RoutesEnum.preservationAip]));
}
ngOnDestroy(): void {
super.ngOnDestroy();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment