diff --git a/src/app/features/registry/pages/registry-overview/registry-overview.component.ts b/src/app/features/registry/pages/registry-overview/registry-overview.component.ts
index ef6f6d95a..9c67b8a16 100644
--- a/src/app/features/registry/pages/registry-overview/registry-overview.component.ts
+++ b/src/app/features/registry/pages/registry-overview/registry-overview.component.ts
@@ -26,7 +26,7 @@ import { hasViewOnlyParam, toCamelCase } from '@osf/shared/helpers';
import { MapRegistryOverview } from '@osf/shared/mappers';
import { SchemaResponse, ToolbarResource } from '@osf/shared/models';
import { ToastService } from '@osf/shared/services';
-import { GetBookmarksCollectionId } from '@osf/shared/stores';
+import { FetchSelectedSubjects, GetBookmarksCollectionId, SubjectsSelectors } from '@osf/shared/stores';
import { ViewOnlyLinkMessageComponent } from '@shared/components/view-only-link-message/view-only-link-message.component';
import { ArchivingMessageComponent, RegistryRevisionsComponent, RegistryStatusesComponent } from '../../components';
@@ -36,7 +36,6 @@ import {
GetRegistryById,
GetRegistryInstitutions,
GetRegistryReviewActions,
- GetRegistrySubjects,
RegistryOverviewSelectors,
SetRegistryCustomCitation,
} from '../../store/registry-overview';
@@ -76,8 +75,8 @@ export class RegistryOverviewComponent {
readonly registry = select(RegistryOverviewSelectors.getRegistry);
readonly isRegistryLoading = select(RegistryOverviewSelectors.isRegistryLoading);
readonly isAnonymous = select(RegistryOverviewSelectors.isRegistryAnonymous);
- readonly subjects = select(RegistryOverviewSelectors.getSubjects);
- readonly isSubjectsLoading = select(RegistryOverviewSelectors.isSubjectsLoading);
+ readonly subjects = select(SubjectsSelectors.getSelectedSubjects);
+ readonly areSubjectsLoading = select(SubjectsSelectors.areSelectedSubjectsLoading);
readonly institutions = select(RegistryOverviewSelectors.getInstitutions);
readonly isInstitutionsLoading = select(RegistryOverviewSelectors.isInstitutionsLoading);
readonly schemaBlocks = select(RegistryOverviewSelectors.getSchemaBlocks);
@@ -87,6 +86,15 @@ export class RegistryOverviewComponent {
readonly isSchemaResponseLoading = select(RegistriesSelectors.getSchemaResponseLoading);
revisionInProgress: SchemaResponse | undefined;
+ isLoading = computed(
+ () =>
+ this.isRegistryLoading() ||
+ this.isInstitutionsLoading() ||
+ this.isSchemaBlocksLoading() ||
+ this.isSchemaResponseLoading() ||
+ this.areSubjectsLoading()
+ );
+
readonly schemaResponse = computed(() => {
const registry = this.registry();
const index = this.selectedRevisionIndex();
@@ -141,7 +149,7 @@ export class RegistryOverviewComponent {
private readonly actions = createDispatchMap({
getRegistryById: GetRegistryById,
getBookmarksId: GetBookmarksCollectionId,
- getSubjects: GetRegistrySubjects,
+ getSubjects: FetchSelectedSubjects,
getInstitutions: GetRegistryInstitutions,
setCustomCitation: SetRegistryCustomCitation,
getRegistryReviewActions: GetRegistryReviewActions,
@@ -179,7 +187,7 @@ export class RegistryOverviewComponent {
return !this.registry()?.withdrawn;
}),
tap(() => {
- this.actions.getSubjects(id);
+ this.actions.getSubjects(id, ResourceType.Registration);
this.actions.getInstitutions(id);
})
)
@@ -201,7 +209,6 @@ export class RegistryOverviewComponent {
}
navigateToFile(fileId: string): void {
- // [NM] TODO: add logic to handle fileId
this.router.navigate(['/files', fileId]);
}
diff --git a/src/app/features/registry/registry.routes.ts b/src/app/features/registry/registry.routes.ts
index 22da6cde0..23a05095d 100644
--- a/src/app/features/registry/registry.routes.ts
+++ b/src/app/features/registry/registry.routes.ts
@@ -40,7 +40,7 @@ export const registryRoutes: Routes = [
loadComponent: () =>
import('./pages/registry-overview/registry-overview.component').then((c) => c.RegistryOverviewComponent),
providers: [
- provideStates([RegistriesState, CitationsState]),
+ provideStates([RegistriesState, SubjectsState, CitationsState]),
ProvidersHandlers,
ProjectsHandlers,
LicensesHandlers,
diff --git a/src/app/features/registry/services/registry-overview.service.ts b/src/app/features/registry/services/registry-overview.service.ts
index 3d7b12a01..f06a96364 100644
--- a/src/app/features/registry/services/registry-overview.service.ts
+++ b/src/app/features/registry/services/registry-overview.service.ts
@@ -7,11 +7,9 @@ import { ReviewAction, ReviewActionsResponseJsonApi } from '@osf/features/modera
import { MapRegistryOverview } from '@osf/features/registry/mappers';
import {
GetRegistryOverviewJsonApi,
- GetResourceSubjectsJsonApi,
RegistryOverview,
RegistryOverviewJsonApiData,
RegistryOverviewWithMeta,
- RegistrySubject,
} from '@osf/features/registry/models';
import { InstitutionsMapper, ReviewActionsMapper } from '@osf/shared/mappers';
import { PageSchemaMapper } from '@osf/shared/mappers/registration';
@@ -48,17 +46,6 @@ export class RegistryOverviewService {
.pipe(map((response) => ({ registry: MapRegistryOverview(response.data), meta: response.meta })));
}
- getSubjects(registryId: string): Observable
{
- const params = {
- 'page[size]': 100,
- page: 1,
- };
-
- return this.jsonApiService
- .get(`${this.apiUrl}/registrations/${registryId}/subjects/`, params)
- .pipe(map((response) => response.data.map((subject) => ({ id: subject.id, text: subject.attributes.text }))));
- }
-
getInstitutions(registryId: string): Observable {
const params = {
'page[size]': 100,
diff --git a/src/app/features/registry/store/registry-overview/registry-overview.actions.ts b/src/app/features/registry/store/registry-overview/registry-overview.actions.ts
index 99d42c047..e412a254c 100644
--- a/src/app/features/registry/store/registry-overview/registry-overview.actions.ts
+++ b/src/app/features/registry/store/registry-overview/registry-overview.actions.ts
@@ -10,12 +10,6 @@ export class GetRegistryById {
) {}
}
-export class GetRegistrySubjects {
- static readonly type = '[Registry Overview] Get Registry Subjects';
-
- constructor(public registryId: string) {}
-}
-
export class GetRegistryInstitutions {
static readonly type = '[Registry Overview] Get Registry Institutions';
diff --git a/src/app/features/registry/store/registry-overview/registry-overview.model.ts b/src/app/features/registry/store/registry-overview/registry-overview.model.ts
index f242d3f17..ebf0c081e 100644
--- a/src/app/features/registry/store/registry-overview/registry-overview.model.ts
+++ b/src/app/features/registry/store/registry-overview/registry-overview.model.ts
@@ -1,11 +1,10 @@
import { ReviewAction } from '@osf/features/moderation/models';
-import { RegistryOverview, RegistrySubject } from '@osf/features/registry/models';
+import { RegistryOverview } from '@osf/features/registry/models';
import { Institution, PageSchema } from '@osf/shared/models';
import { AsyncStateModel } from '@shared/models';
export interface RegistryOverviewStateModel {
registry: AsyncStateModel;
- subjects: AsyncStateModel;
institutions: AsyncStateModel;
schemaBlocks: AsyncStateModel;
moderationActions: AsyncStateModel;
@@ -18,11 +17,6 @@ export const REGISTRY_OVERVIEW_DEFAULTS: RegistryOverviewStateModel = {
isLoading: false,
error: null,
},
- subjects: {
- data: [],
- isLoading: false,
- error: null,
- },
institutions: {
data: [],
isLoading: false,
diff --git a/src/app/features/registry/store/registry-overview/registry-overview.selectors.ts b/src/app/features/registry/store/registry-overview/registry-overview.selectors.ts
index be11689a5..60ce06083 100644
--- a/src/app/features/registry/store/registry-overview/registry-overview.selectors.ts
+++ b/src/app/features/registry/store/registry-overview/registry-overview.selectors.ts
@@ -1,7 +1,7 @@
import { Selector } from '@ngxs/store';
import { ReviewAction } from '@osf/features/moderation/models';
-import { RegistryOverview, RegistrySubject } from '@osf/features/registry/models';
+import { RegistryOverview } from '@osf/features/registry/models';
import { Institution, PageSchema } from '@osf/shared/models';
import { RegistryOverviewStateModel } from './registry-overview.model';
@@ -23,16 +23,6 @@ export class RegistryOverviewSelectors {
return state.isAnonymous;
}
- @Selector([RegistryOverviewState])
- static getSubjects(state: RegistryOverviewStateModel): RegistrySubject[] | null {
- return state.subjects.data;
- }
-
- @Selector([RegistryOverviewState])
- static isSubjectsLoading(state: RegistryOverviewStateModel): boolean {
- return state.subjects.isLoading;
- }
-
@Selector([RegistryOverviewState])
static getInstitutions(state: RegistryOverviewStateModel): Institution[] | null {
return state.institutions.data;
diff --git a/src/app/features/registry/store/registry-overview/registry-overview.state.ts b/src/app/features/registry/store/registry-overview/registry-overview.state.ts
index de1507a47..b940a59e0 100644
--- a/src/app/features/registry/store/registry-overview/registry-overview.state.ts
+++ b/src/app/features/registry/store/registry-overview/registry-overview.state.ts
@@ -8,6 +8,7 @@ import { inject, Injectable } from '@angular/core';
import { SetCurrentProvider } from '@osf/core/store/provider/provider.actions';
import { SetUserAsModerator } from '@osf/core/store/user';
import { handleSectionError } from '@osf/shared/helpers';
+import { SubjectsService } from '@osf/shared/services';
import { RegistryOverviewService } from '../../services';
@@ -16,7 +17,6 @@ import {
GetRegistryById,
GetRegistryInstitutions,
GetRegistryReviewActions,
- GetRegistrySubjects,
GetSchemaBlocks,
MakePublic,
SetRegistryCustomCitation,
@@ -32,6 +32,7 @@ import { REGISTRY_OVERVIEW_DEFAULTS, RegistryOverviewStateModel } from './regist
})
export class RegistryOverviewState {
private readonly registryOverviewService = inject(RegistryOverviewService);
+ private readonly subjectsService = inject(SubjectsService);
@Action(GetRegistryById)
getRegistryById(ctx: StateContext, action: GetRegistryById) {
@@ -70,32 +71,6 @@ export class RegistryOverviewState {
);
}
- @Action(GetRegistrySubjects)
- getRegistrySubjects(ctx: StateContext, action: GetRegistrySubjects) {
- const state = ctx.getState();
- ctx.patchState({
- subjects: {
- ...state.subjects,
- isLoading: true,
- },
- });
-
- return this.registryOverviewService.getSubjects(action.registryId).pipe(
- tap({
- next: (subjects) => {
- ctx.patchState({
- subjects: {
- data: subjects,
- isLoading: false,
- error: null,
- },
- });
- },
- }),
- catchError((error) => handleSectionError(ctx, 'subjects', error))
- );
- }
-
@Action(GetRegistryInstitutions)
getRegistryInstitutions(ctx: StateContext, action: GetRegistryInstitutions) {
const state = ctx.getState();
diff --git a/src/app/shared/components/resource-metadata/resource-metadata.component.html b/src/app/shared/components/resource-metadata/resource-metadata.component.html
index 7a13b18f4..7d6c4bb15 100644
--- a/src/app/shared/components/resource-metadata/resource-metadata.component.html
+++ b/src/app/shared/components/resource-metadata/resource-metadata.component.html
@@ -136,7 +136,7 @@ {{ 'project.overview.metadata.subjects' | translate }}
@if (resource.subjects.length) {
@for (subject of resource.subjects; track subject.id) {
-
+
}
} @else {
{{ 'project.overview.metadata.noSubjects' | translate }}
diff --git a/src/app/shared/components/subjects/subjects.component.html b/src/app/shared/components/subjects/subjects.component.html
index 39fc1c960..e91393d6e 100644
--- a/src/app/shared/components/subjects/subjects.component.html
+++ b/src/app/shared/components/subjects/subjects.component.html
@@ -39,7 +39,9 @@
{{ 'shared.subjects.title' | translate }}