From bef1d1710674bb3c3a6fffba5d57c7c80cf5d192 Mon Sep 17 00:00:00 2001 From: nsemets Date: Fri, 28 Nov 2025 14:09:16 +0200 Subject: [PATCH] fix(subjects): fixed subjects for registry overview --- .../registry-overview-metadata.component.ts | 4 +- .../subjects/subjects.component.html | 4 +- .../subjects/subjects.component.scss | 3 + .../tags-list/tags-list.component.html | 2 +- .../stores/subjects/subjects.actions.ts | 2 +- .../shared/stores/subjects/subjects.state.ts | 57 ++++++------------- src/styles/overrides/chip.scss | 4 +- src/styles/overrides/tag.scss | 2 +- 8 files changed, 29 insertions(+), 49 deletions(-) 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.title' | translate }}

-

{{ 'shared.subjects.description' | translate }}

+

{{ 'shared.subjects.description' | translate }}

- + @if (!selected().length) {

{{ '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 @@ } @else { @for (tag of tags(); track tag) { - + } @empty {

{{ '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, section: keyof SubjectsModel, error: Error) { - ctx.patchState({ - [section]: { - ...ctx.getState()[section], - isLoading: false, - error: error.message, - }, - }); - return throwError(() => error); - } } diff --git a/src/styles/overrides/chip.scss b/src/styles/overrides/chip.scss index fd31e98a5..bbff4aa63 100644 --- a/src/styles/overrides/chip.scss +++ b/src/styles/overrides/chip.scss @@ -1,5 +1,5 @@ .p-chip { - --p-chip-background: var(--bg-blue-3); + --p-chip-background: var(--bg-blue-2); --p-chip-border-radius: 0.25rem; --p-chip-color: var(--dark-blue-1); --p-chip-padding-y: 0.25rem; @@ -13,7 +13,7 @@ } &:hover { - --p-chip-background: var(--bg-blue-2); + --p-chip-background: var(--bg-blue-3); --p-chip-color: var(--pr-blue-3); .p-chip-remove-icon { diff --git a/src/styles/overrides/tag.scss b/src/styles/overrides/tag.scss index c0fb70971..f67f87755 100644 --- a/src/styles/overrides/tag.scss +++ b/src/styles/overrides/tag.scss @@ -8,7 +8,7 @@ --p-tag-secondary-background: var(--grey-1); --p-tag-secondary-color: var(--white); - --p-tag-info-background: var(--bg-blue-3); + --p-tag-info-background: var(--bg-blue-2); --p-tag-info-color: var(--dark-blue-1); }