diff --git a/src/app/features/registry/components/registry-overview-metadata/registry-overview-metadata.component.ts b/src/app/features/registry/components/registry-overview-metadata/registry-overview-metadata.component.ts index ef35929bc..c2c3b4686 100644 --- a/src/app/features/registry/components/registry-overview-metadata/registry-overview-metadata.component.ts +++ b/src/app/features/registry/components/registry-overview-metadata/registry-overview-metadata.component.ts @@ -63,8 +63,8 @@ export class RegistryOverviewMetadataComponent { isIdentifiersLoading = select(RegistrySelectors.isIdentifiersLoading); institutions = select(RegistrySelectors.getInstitutions); isInstitutionsLoading = select(RegistrySelectors.isInstitutionsLoading); - subjects = select(SubjectsSelectors.getSubjects); - isSubjectsLoading = select(SubjectsSelectors.getSubjectsLoading); + subjects = select(SubjectsSelectors.getSelectedSubjects); + isSubjectsLoading = select(SubjectsSelectors.areSelectedSubjectsLoading); bibliographicContributors = select(ContributorsSelectors.getBibliographicContributors); isBibliographicContributorsLoading = select(ContributorsSelectors.isBibliographicContributorsLoading); diff --git a/src/app/shared/components/subjects/subjects.component.html b/src/app/shared/components/subjects/subjects.component.html index e647ef075..44139f2ed 100644 --- a/src/app/shared/components/subjects/subjects.component.html +++ b/src/app/shared/components/subjects/subjects.component.html @@ -1,8 +1,8 @@
{{ 'shared.subjects.description' | translate }}
+{{ 'shared.subjects.description' | translate }}
-{{ 'shared.subjects.noSelected' | translate }}
} @else { diff --git a/src/app/shared/components/subjects/subjects.component.scss b/src/app/shared/components/subjects/subjects.component.scss index e69de29bb..d3460bfb5 100644 --- a/src/app/shared/components/subjects/subjects.component.scss +++ b/src/app/shared/components/subjects/subjects.component.scss @@ -0,0 +1,3 @@ +.card { + --p-card-body-padding: 0.75rem; +} diff --git a/src/app/shared/components/tags-list/tags-list.component.html b/src/app/shared/components/tags-list/tags-list.component.html index 69ea7d7ec..4611bdeaf 100644 --- a/src/app/shared/components/tags-list/tags-list.component.html +++ b/src/app/shared/components/tags-list/tags-list.component.html @@ -3,7 +3,7 @@{{ 'project.overview.metadata.noTags' | translate }}
} diff --git a/src/app/shared/stores/subjects/subjects.actions.ts b/src/app/shared/stores/subjects/subjects.actions.ts index 63241f70a..55fd967a1 100644 --- a/src/app/shared/stores/subjects/subjects.actions.ts +++ b/src/app/shared/stores/subjects/subjects.actions.ts @@ -27,7 +27,7 @@ export class FetchChildrenSubjects { } export class UpdateResourceSubjects { - static readonly type = '[Subjects] Update Resource Project'; + static readonly type = '[Subjects] Update Resource Subjects'; constructor( public resourceId: string, diff --git a/src/app/shared/stores/subjects/subjects.state.ts b/src/app/shared/stores/subjects/subjects.state.ts index 6dd296910..0ea1ed7c5 100644 --- a/src/app/shared/stores/subjects/subjects.state.ts +++ b/src/app/shared/stores/subjects/subjects.state.ts @@ -1,9 +1,10 @@ import { Action, State, StateContext } from '@ngxs/store'; -import { catchError, tap, throwError } from 'rxjs'; +import { catchError, tap } from 'rxjs'; import { inject, Injectable } from '@angular/core'; +import { handleSectionError } from '@osf/shared/helpers/state-error.handler'; import { SubjectModel } from '@osf/shared/models/subject/subject.model'; import { SubjectsService } from '@osf/shared/services/subjects.service'; @@ -29,40 +30,27 @@ export class SubjectsState { return; } + const targetSection = search ? 'searchedSubjects' : 'subjects'; + ctx.patchState({ - subjects: { - ...ctx.getState().subjects, + [targetSection]: { + ...ctx.getState()[targetSection], isLoading: true, error: null, }, - searchedSubjects: { - ...ctx.getState().searchedSubjects, - isLoading: search ? true : false, - error: null, - }, }); return this.subjectsService.getSubjects(resourceType, providerId, search).pipe( tap((subjects) => { - if (search) { - ctx.patchState({ - searchedSubjects: { - data: subjects, - isLoading: false, - error: null, - }, - }); - } else { - ctx.patchState({ - subjects: { - data: subjects, - isLoading: false, - error: null, - }, - }); - } + ctx.patchState({ + [targetSection]: { + data: subjects, + isLoading: false, + error: null, + }, + }); }), - catchError((error) => this.handleError(ctx, 'subjects', error)) + catchError((error) => handleSectionError(ctx, targetSection, error)) ); } @@ -88,7 +76,7 @@ export class SubjectsState { }, }); }), - catchError((error) => this.handleError(ctx, 'subjects', error)) + catchError((error) => handleSectionError(ctx, 'subjects', error)) ); } @@ -116,7 +104,7 @@ export class SubjectsState { }, }); }), - catchError((error) => this.handleError(ctx, 'selectedSubjects', error)) + catchError((error) => handleSectionError(ctx, 'selectedSubjects', error)) ); } @@ -147,7 +135,7 @@ export class SubjectsState { }, }); }), - catchError((error) => this.handleError(ctx, 'selectedSubjects', error)) + catchError((error) => handleSectionError(ctx, 'selectedSubjects', error)) ); } @@ -171,15 +159,4 @@ export class SubjectsState { return subject; }); } - - private handleError(ctx: StateContext