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

fix: archive selected is not the good one in breadcrumb

parent 92a2698f
No related branches found
No related tags found
No related merge requests found
import {
ChangeDetectionStrategy,
Component,
OnDestroy,
OnInit,
} from "@angular/core";
import {
......@@ -40,7 +41,7 @@ import {
styleUrls: ["./home-detail.routable.scss"],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HomeDetailRoutable extends SharedAbstractPresentational implements OnInit {
export class HomeDetailRoutable extends SharedAbstractPresentational implements OnInit, OnDestroy {
@Select(HomeState.isLoading) isLoadingObs: Observable<boolean>;
@Select(HomeState.isLoadingPrepareDownload) isLoadingPrepareDownloadObs: Observable<boolean>;
@Select(HomeState.current) currentObs: Observable<ArchiveMetadata>;
......@@ -71,6 +72,10 @@ export class HomeDetailRoutable extends SharedAbstractPresentational implements
));
}
ngOnDestroy(): void {
this.store.dispatch(new HomeAction.CleanCurrent());
}
private retrieveCurrentModelWithUrl(): void {
this._resId = this.route.snapshot.paramMap.get(AppRoutesEnum.paramIdWithoutPrefixParam);
this.getById(this._resId);
......
......@@ -12,6 +12,7 @@ import {
DlcmData,
DlcmRoutes,
} from "@app/shared/models/dlcm-route.model";
import {HomeState} from "@home/stores/home.state";
import {HomeOrganizationalUnitArchiveState} from "@home/stores/organizational-unit/archive/home-organizational-unit-archive.state";
import {HomeOrganizationalUnitState} from "@home/stores/organizational-unit/home-organizational-unit.state";
import {TRANSLATE} from "solidify-frontend";
......@@ -26,7 +27,7 @@ const routes: DlcmRoutes = [
path: HomePageRoutesEnum.detail + AppRoutesEnum.separator + AppRoutesEnum.paramId,
component: HomeDetailRoutable,
data: {
breadcrumbMemoizedSelector: HomeOrganizationalUnitArchiveState.currentTitle,
breadcrumbMemoizedSelector: HomeState.currentTitle,
},
},
{
......@@ -47,7 +48,7 @@ const routes: DlcmRoutes = [
path: HomePageRoutesEnum.detail + AppRoutesEnum.separator + AppRoutesEnum.paramId,
component: HomeDetailRoutable,
data: {
breadcrumbMemoizedSelector: HomeOrganizationalUnitArchiveState.currentTitle,
breadcrumbMemoizedSelector: HomeState.currentTitle,
},
},
],
......
import {SearchScopeEnum} from "@app/features/home/enums/search-scope.enum";
import {Rss} from "@app/features/home/models/rss.model";
import {ArchiveMetadata} from "@app/shared/models/business/archive-metadata.model";
import {LocalStateEnum} from "@shared/enums/local-state.enum";
import {
CollectionTyped,
QueryParameters,
} from "solidify-frontend";
const state = LocalStateEnum.home;
export namespace HomeAction {
export class ChangeQueryParameters {
static readonly type: string = "[Home] Change Query Parameters";
static readonly type: string = `[${state}] Change Query Parameters`;
constructor(public queryParameters?: QueryParameters) {
}
}
export class ChangeSearchScope {
static readonly type: string = "[Home] Change Filter";
static readonly type: string = `[${state}] Change Filter`;
constructor(public searchScope: SearchScopeEnum) {
}
......@@ -23,78 +26,80 @@ export namespace HomeAction {
}
export class Search {
static readonly type: string = "[Home] Search";
static readonly type: string = `[${state}] Search`;
constructor(public resetPagination: boolean, public search?: string, public queryParameters?: QueryParameters) {
}
}
export class SearchSuccess {
static readonly type: string = "[Home] Search Success";
static readonly type: string = `[${state}] Search Success`;
constructor(public list?: CollectionTyped<ArchiveMetadata> | null | undefined) {
}
}
export class SearchFail {
static readonly type: string = "[Home] Search Fail";
static readonly type: string = `[${state}] Search Fail`;
}
export class SearchDetail {
static readonly type: string = "[Home] Search Detail";
static readonly type: string = `[${state}] Search Detail`;
constructor(public resId: string) {
}
}
export class SearchDetailSuccess {
static readonly type: string = "[Home] Search Detail Success";
static readonly type: string = `[${state}] Search Detail Success`;
constructor(public model: ArchiveMetadata) {
}
}
export class SearchDetailFail {
static readonly type: string = "[Home] Search Detail Fail";
static readonly type: string = `[${state}] Search Detail Fail`;
constructor() {
}
}
export class GetRss {
static readonly type: string = "[Home] Get Rss";
static readonly type: string = `[${state}] Get Rss`;
constructor() {
}
}
export class GetRssSuccess {
static readonly type: string = "[Home] Get Rss Success";
static readonly type: string = `[${state}] Get Rss Success`;
constructor(public rss: Rss) {
}
}
export class GetRssFail {
static readonly type: string = "[Home] Get Rss Fail";
static readonly type: string = `[${state}] Get Rss Fail`;
constructor() {
}
}
export class Download {
static readonly type: string = `[Home] Download`;
static readonly type: string = `[${state}] Download`;
constructor(public dataFile: ArchiveMetadata) {
}
}
export class DownloadFail {
static readonly type: string = `[Home] Download Fail`;
static readonly type: string = `[${state}] Download Fail`;
constructor() {
}
}
export class CleanCurrent {
static readonly type: string = `[${state}] Clean Current`;
}
}
......@@ -27,6 +27,7 @@ import {
Store,
} from "@ngxs/store";
import {ApiActionEnum} from "@shared/enums/api-action.enum";
import {MetadataUtil} from "@shared/utils/metadata.util";
import {saveAs} from "file-saver";
import {NgxXml2jsonService} from "ngx-xml2json";
import {
......@@ -123,6 +124,14 @@ export class HomeState {
return state.isLoadingCounterDownloadPreparation > 0;
}
@Selector()
static currentTitle(state: HomeStateModel): string | undefined {
if (isNullOrUndefined(state.current)) {
return undefined;
}
return MetadataUtil.getTitle(SearchScopeEnum.public, state.current.metadata);
}
@Action(HomeAction.ChangeQueryParameters)
changeQueryParameters(ctx: StateContext<HomeStateModel>, action: HomeAction.ChangeQueryParameters): void {
ctx.patchState({
......@@ -329,7 +338,7 @@ export class HomeState {
catchError(error => {
pooling = false;
throw error;
})
}),
);
}
......@@ -388,5 +397,11 @@ export class HomeState {
});
}
@Action(HomeAction.CleanCurrent)
cleanCurrent(ctx: StateContext<HomeStateModel>, action: HomeAction.CleanCurrent): void {
ctx.patchState({
current: undefined,
});
}
}
......@@ -55,14 +55,6 @@ export class HomeOrganizationalUnitArchiveState extends AssociationNoSqlReadOnly
return AccessResourceApiEnum.organizationalUnits;
}
@Selector()
static currentTitle(state: HomeOrganizationalUnitArchiveStateModel): string | undefined {
if (isNullOrUndefined(state.selected) || isEmptyArray(state.selected)) {
return undefined;
}
return MetadataUtil.getTitle(SearchScopeEnum.public, state.selected[0].metadata);
}
@OverrideDefaultAction()
@Action(HomeOrgUnitArchiveAction.GetAll)
getAll<U>(ctx: StateContext<HomeOrganizationalUnitArchiveStateModel>, action: HomeOrgUnitArchiveAction.GetAll): Observable<CollectionTyped<U>> {
......
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