Commit 7cbed373 authored by Florent Poittevin's avatar Florent Poittevin
Browse files

fix(search): display error message and clean search result when error append

parent 74757564
......@@ -20,21 +20,23 @@ export namespace HomeAction {
}
}
export class Search {
export class Search extends BaseAction {
static readonly type: string = `[${state}] Search`;
constructor(public resetPagination: boolean, public search?: string, public facetsSelected?: MappingObject<string[]>, public viewMode?: ViewModeTableEnum, public queryParameters?: QueryParameters) {
super();
}
}
export class SearchSuccess {
export class SearchSuccess extends BaseSubAction<Search> {
static readonly type: string = `[${state}] Search Success`;
constructor(public collection?: CollectionTyped<Archive> | null | undefined) {
constructor(public parentAction: Search, public collection?: CollectionTyped<Archive> | null | undefined) {
super(parentAction);
}
}
export class SearchFail {
export class SearchFail extends BaseSubAction<Search> {
static readonly type: string = `[${state}] Search Fail`;
}
......
......@@ -27,6 +27,7 @@ import {
StateContext,
Store,
} from "@ngxs/store";
import {LabelTranslateEnum} from "@shared/enums/label-translate.enum";
import {urlSeparator} from "@shared/enums/routes.enum";
import {StateEnum} from "@shared/enums/state.enum";
import {ViewModeTableEnum} from "@shared/enums/view-mode-table.enum";
......@@ -178,10 +179,10 @@ export class HomeState extends BasicState<HomeStateModel> {
_facets: collection._facets,
} as CollectionTyped<Archive>;
collectionArchive._data = ArchiveHelper.adaptListArchivesMetadataInArchive(collection._data);
ctx.dispatch(new HomeAction.SearchSuccess(collectionArchive));
ctx.dispatch(new HomeAction.SearchSuccess(action, collectionArchive));
}),
catchError((error: SolidifyHttpErrorResponseModel) => {
ctx.dispatch(new HomeAction.SearchFail());
ctx.dispatch(new HomeAction.SearchFail(action));
throw error;
}),
);
......@@ -218,7 +219,10 @@ export class HomeState extends BasicState<HomeStateModel> {
searchFail(ctx: StateContext<HomeStateModel>): void {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter - 1,
list: [],
total: 0,
});
this.notificationService.showError(LabelTranslateEnum.notificationHttpInternalError);
}
@Action(HomeAction.SearchRelativeArchive)
......
......@@ -151,7 +151,7 @@ export namespace SharedAipOrgUnitAction {
}
export class Search {
static readonly type: string = "[${state}] Search";
static readonly type: string = `[${state}] Search`;
constructor(public resetPagination: boolean, public search?: string, public queryParameters?: QueryParameters) {
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment