From 90dc6a9e8ff026fb3923c1b92b5a16f7e4a06d72 Mon Sep 17 00:00:00 2001 From: Tifenn GUILLAS Date: Tue, 27 Aug 2019 14:50:25 +0200 Subject: [PATCH] Fix bug rechargement detail page --- .../components/object-display.component.html | 5 ----- src/app/detail/containers/detail.component.html | 5 +++++ src/app/detail/containers/detail.component.ts | 8 ++++++-- src/app/detail/store/detail.action.ts | 14 +++++++++++--- src/app/detail/store/detail.effects.ts | 6 +++--- src/app/detail/store/detail.reducer.ts | 6 ++++-- 6 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/app/detail/components/object-display.component.html b/src/app/detail/components/object-display.component.html index 7f22bb8..6ecda8c 100644 --- a/src/app/detail/components/object-display.component.html +++ b/src/app/detail/components/object-display.component.html @@ -1,8 +1,3 @@ -
-
-

Object detail

-
-
diff --git a/src/app/detail/containers/detail.component.html b/src/app/detail/containers/detail.component.html index a6214c8..2772308 100644 --- a/src/app/detail/containers/detail.component.html +++ b/src/app/detail/containers/detail.component.html @@ -1,3 +1,8 @@ +
+
+

Object detail

+
+
Loading... diff --git a/src/app/detail/containers/detail.component.ts b/src/app/detail/containers/detail.component.ts index 86542ea..55c0e56 100644 --- a/src/app/detail/containers/detail.component.ts +++ b/src/app/detail/containers/detail.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, OnDestroy } from '@angular/core'; import { Location } from '@angular/common'; import { Observable } from 'rxjs'; @@ -19,7 +19,7 @@ interface StoreState { templateUrl: 'detail.component.html', styleUrls: ['detail.component.css'] }) -export class DetailComponent implements OnInit { +export class DetailComponent implements OnInit, OnDestroy { public pristine: Observable; public attributeList: Observable; public objectIsLoading: Observable; @@ -43,4 +43,8 @@ export class DetailComponent implements OnInit { goBackToResult() { this.location.back(); } + + ngOnDestroy() { + this.store.dispatch(new detailActions.DestroyDetailAction()); + } } diff --git a/src/app/detail/store/detail.action.ts b/src/app/detail/store/detail.action.ts index 2b12ccf..98cf571 100644 --- a/src/app/detail/store/detail.action.ts +++ b/src/app/detail/store/detail.action.ts @@ -9,10 +9,11 @@ export const COPY_ATTRIBUTE_LIST = '[Detail] Copy Attribute List'; export const RETRIEVE_OBJECT = '[Detail] Retrieve Object'; export const RETRIEVE_OBJECT_SUCCESS = '[Detail] Retrieve Object Success'; export const RETRIEVE_OBJECT_FAIL = '[Detail] Retrieve Object Fail'; +export const DESTROY_DETAIL = '[Detail] Destroy detail'; export class InitDetailAction implements Action { type = INIT_DETAIL; - + constructor(public payload: {} = null) { } } @@ -43,7 +44,7 @@ export class CopyAttributeListAction implements Action { export class RetrieveObjectAction implements Action { type = RETRIEVE_OBJECT; - constructor(public payload: {datasetName: string, idAttribute: number, id: string} = null) { } + constructor(public payload: { datasetName: string, idAttribute: number, id: string } = null) { } } export class RetrieveObjectSuccessAction implements Action { @@ -58,6 +59,12 @@ export class RetrieveObjectFailAction implements Action { constructor(public payload: {} = null) { } } +export class DestroyDetailAction implements Action { + type = DESTROY_DETAIL; + + constructor(public payload: {} = null) { } +} + export type Actions = InitDetailAction | LoadAttributeListAction @@ -66,4 +73,5 @@ export type Actions | CopyAttributeListAction | RetrieveObjectAction | RetrieveObjectSuccessAction - | RetrieveObjectFailAction; \ No newline at end of file + | RetrieveObjectFailAction + | DestroyDetailAction; diff --git a/src/app/detail/store/detail.effects.ts b/src/app/detail/store/detail.effects.ts index 6a286e9..08dc1d6 100644 --- a/src/app/detail/store/detail.effects.ts +++ b/src/app/detail/store/detail.effects.ts @@ -56,7 +56,7 @@ export class DetailEffects { map((attributeList: Attribute[]) => new detailActions.LoadAttributeListSuccessAction(attributeList)), catchError(() => of(new detailActions.LoadAttributeListFailAction())) ); - }) + }) ); @Effect() @@ -78,7 +78,7 @@ export class DetailEffects { switchMap(([action, state]) => { const attributeList = state.metamodel.attribute.datasetAttributeList; return of(new detailActions.LoadAttributeListSuccessAction(attributeList)); - }) + }) ); @Effect() @@ -103,4 +103,4 @@ export class DetailEffects { ofType(detailActions.RETRIEVE_OBJECT_FAIL), tap(_ => this.toastr.error('Loading Failed!', 'The object loading failed')) ); -} \ No newline at end of file +} diff --git a/src/app/detail/store/detail.reducer.ts b/src/app/detail/store/detail.reducer.ts index f6f36d7..0de17ac 100644 --- a/src/app/detail/store/detail.reducer.ts +++ b/src/app/detail/store/detail.reducer.ts @@ -1,6 +1,6 @@ import * as actions from './detail.action'; -import { Attribute } from '../../metamodel/model'; +import { Attribute } from '../../metamodel/model'; export interface State { attributeList: Attribute[]; @@ -27,7 +27,7 @@ export function reducer(state: State = initialState, action: actions.Actions): S case actions.LOAD_ATTRIBUTE_LIST_SUCCESS: const attributeList = action.payload as Attribute[]; - return  { + return { ...state, attributeList } @@ -50,6 +50,8 @@ export function reducer(state: State = initialState, action: actions.Actions): S objectIsLoaded: false }; + case actions.DESTROY_DETAIL: + return initialState; default: return state; -- GitLab