Skip to content

Commit 086188b

Browse files
authored
[ENG-9788] Subjects Metadata Not Displaying on Registration Overview Page #797
- Ticket: [ENG-9788] - Feature flag: n/a ## Summary of Changes 1. Fixed subjects on the registry overview page.
1 parent 1434ee6 commit 086188b

File tree

8 files changed

+29
-49
lines changed

8 files changed

+29
-49
lines changed

src/app/features/registry/components/registry-overview-metadata/registry-overview-metadata.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export class RegistryOverviewMetadataComponent {
6363
isIdentifiersLoading = select(RegistrySelectors.isIdentifiersLoading);
6464
institutions = select(RegistrySelectors.getInstitutions);
6565
isInstitutionsLoading = select(RegistrySelectors.isInstitutionsLoading);
66-
subjects = select(SubjectsSelectors.getSubjects);
67-
isSubjectsLoading = select(SubjectsSelectors.getSubjectsLoading);
66+
subjects = select(SubjectsSelectors.getSelectedSubjects);
67+
isSubjectsLoading = select(SubjectsSelectors.areSelectedSubjectsLoading);
6868

6969
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributors);
7070
isBibliographicContributorsLoading = select(ContributorsSelectors.isBibliographicContributorsLoading);

src/app/shared/components/subjects/subjects.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<h2 class="mb-2">{{ 'shared.subjects.title' | translate }}</h2>
22

3-
<p class="mb-1">{{ 'shared.subjects.description' | translate }}</p>
3+
<p class="mb-2">{{ 'shared.subjects.description' | translate }}</p>
44

5-
<p-card class="block text-base mb-3">
5+
<p-card class="card block text-sm mb-3">
66
@if (!selected().length) {
77
<p class="text-500">{{ 'shared.subjects.noSelected' | translate }}</p>
88
} @else {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.card {
2+
--p-card-body-padding: 0.75rem;
3+
}

src/app/shared/components/tags-list/tags-list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<p-skeleton height="1.5rem" />
44
} @else {
55
@for (tag of tags(); track tag) {
6-
<p-tag class="cursor-pointer hover:bg-black-alpha-10" [value]="tag" severity="info" (click)="onTagClick(tag)" />
6+
<p-tag class="cursor-pointer hover:bg-primary-100" [value]="tag" severity="info" (click)="onTagClick(tag)" />
77
} @empty {
88
<p>{{ 'project.overview.metadata.noTags' | translate }}</p>
99
}

src/app/shared/stores/subjects/subjects.actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class FetchChildrenSubjects {
2727
}
2828

2929
export class UpdateResourceSubjects {
30-
static readonly type = '[Subjects] Update Resource Project';
30+
static readonly type = '[Subjects] Update Resource Subjects';
3131

3232
constructor(
3333
public resourceId: string,

src/app/shared/stores/subjects/subjects.state.ts

Lines changed: 17 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Action, State, StateContext } from '@ngxs/store';
22

3-
import { catchError, tap, throwError } from 'rxjs';
3+
import { catchError, tap } from 'rxjs';
44

55
import { inject, Injectable } from '@angular/core';
66

7+
import { handleSectionError } from '@osf/shared/helpers/state-error.handler';
78
import { SubjectModel } from '@osf/shared/models/subject/subject.model';
89
import { SubjectsService } from '@osf/shared/services/subjects.service';
910

@@ -29,40 +30,27 @@ export class SubjectsState {
2930
return;
3031
}
3132

33+
const targetSection = search ? 'searchedSubjects' : 'subjects';
34+
3235
ctx.patchState({
33-
subjects: {
34-
...ctx.getState().subjects,
36+
[targetSection]: {
37+
...ctx.getState()[targetSection],
3538
isLoading: true,
3639
error: null,
3740
},
38-
searchedSubjects: {
39-
...ctx.getState().searchedSubjects,
40-
isLoading: search ? true : false,
41-
error: null,
42-
},
4341
});
4442

4543
return this.subjectsService.getSubjects(resourceType, providerId, search).pipe(
4644
tap((subjects) => {
47-
if (search) {
48-
ctx.patchState({
49-
searchedSubjects: {
50-
data: subjects,
51-
isLoading: false,
52-
error: null,
53-
},
54-
});
55-
} else {
56-
ctx.patchState({
57-
subjects: {
58-
data: subjects,
59-
isLoading: false,
60-
error: null,
61-
},
62-
});
63-
}
45+
ctx.patchState({
46+
[targetSection]: {
47+
data: subjects,
48+
isLoading: false,
49+
error: null,
50+
},
51+
});
6452
}),
65-
catchError((error) => this.handleError(ctx, 'subjects', error))
53+
catchError((error) => handleSectionError(ctx, targetSection, error))
6654
);
6755
}
6856

@@ -88,7 +76,7 @@ export class SubjectsState {
8876
},
8977
});
9078
}),
91-
catchError((error) => this.handleError(ctx, 'subjects', error))
79+
catchError((error) => handleSectionError(ctx, 'subjects', error))
9280
);
9381
}
9482

@@ -116,7 +104,7 @@ export class SubjectsState {
116104
},
117105
});
118106
}),
119-
catchError((error) => this.handleError(ctx, 'selectedSubjects', error))
107+
catchError((error) => handleSectionError(ctx, 'selectedSubjects', error))
120108
);
121109
}
122110

@@ -147,7 +135,7 @@ export class SubjectsState {
147135
},
148136
});
149137
}),
150-
catchError((error) => this.handleError(ctx, 'selectedSubjects', error))
138+
catchError((error) => handleSectionError(ctx, 'selectedSubjects', error))
151139
);
152140
}
153141

@@ -171,15 +159,4 @@ export class SubjectsState {
171159
return subject;
172160
});
173161
}
174-
175-
private handleError(ctx: StateContext<SubjectsModel>, section: keyof SubjectsModel, error: Error) {
176-
ctx.patchState({
177-
[section]: {
178-
...ctx.getState()[section],
179-
isLoading: false,
180-
error: error.message,
181-
},
182-
});
183-
return throwError(() => error);
184-
}
185162
}

src/styles/overrides/chip.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.p-chip {
2-
--p-chip-background: var(--bg-blue-3);
2+
--p-chip-background: var(--bg-blue-2);
33
--p-chip-border-radius: 0.25rem;
44
--p-chip-color: var(--dark-blue-1);
55
--p-chip-padding-y: 0.25rem;
@@ -13,7 +13,7 @@
1313
}
1414

1515
&:hover {
16-
--p-chip-background: var(--bg-blue-2);
16+
--p-chip-background: var(--bg-blue-3);
1717
--p-chip-color: var(--pr-blue-3);
1818

1919
.p-chip-remove-icon {

src/styles/overrides/tag.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
--p-tag-secondary-background: var(--grey-1);
99
--p-tag-secondary-color: var(--white);
1010

11-
--p-tag-info-background: var(--bg-blue-3);
11+
--p-tag-info-background: var(--bg-blue-2);
1212
--p-tag-info-color: var(--dark-blue-1);
1313
}
1414

0 commit comments

Comments
 (0)