diff --git a/src/app/features/preprints/components/stepper/metadata-step/metadata-step.component.html b/src/app/features/preprints/components/stepper/metadata-step/metadata-step.component.html index 552394153..1e2736c74 100644 --- a/src/app/features/preprints/components/stepper/metadata-step/metadata-step.component.html +++ b/src/app/features/preprints/components/stepper/metadata-step/metadata-step.component.html @@ -10,7 +10,7 @@

{{ 'shared.license.title' | translate }}

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

{{ 'shared.license.helpText' | translate }} - {{ 'common.links.helpGuide' | translate }}{{ 'common.links.helpGuide' | translate }}.

subjectArray[0]), contributors: response.embeds.bibliographic_contributors?.data?.map((contributor) => ({ id: contributor.embeds.users.data.id, diff --git a/src/app/features/project/overview/models/project-overview.models.ts b/src/app/features/project/overview/models/project-overview.models.ts index 3a4bda79b..64b632ba1 100644 --- a/src/app/features/project/overview/models/project-overview.models.ts +++ b/src/app/features/project/overview/models/project-overview.models.ts @@ -52,7 +52,6 @@ export interface ProjectOverview { currentUserIsContributor: boolean; currentUserIsContributorOrGroupMember: boolean; wikiEnabled: boolean; - subjects: ProjectOverviewSubject[]; contributors: ProjectOverviewContributor[]; customCitation: string | null; region?: IdTypeModel; @@ -66,11 +65,6 @@ export interface ProjectOverview { rootParentId?: string; } -export interface ProjectOverviewSubject { - id: string; - text: string; -} - export interface ProjectOverviewWithMeta { project: ProjectOverview; meta?: MetaAnonymousJsonApi; @@ -104,7 +98,6 @@ export interface ProjectOverviewGetResponseJsonApi { current_user_is_contributor: boolean; current_user_is_contributor_or_group_member: boolean; wiki_enabled: boolean; - subjects: ProjectOverviewSubject[][]; custom_citation: string | null; }; embeds: { diff --git a/src/app/features/project/overview/project-overview.component.ts b/src/app/features/project/overview/project-overview.component.ts index 5513a813f..59827e4c2 100644 --- a/src/app/features/project/overview/project-overview.component.ts +++ b/src/app/features/project/overview/project-overview.component.ts @@ -40,12 +40,14 @@ import { ClearWiki, CollectionsSelectors, CurrentResourceSelectors, + FetchSelectedSubjects, GetBookmarksCollectionId, GetCollectionProvider, GetConfiguredStorageAddons, GetHomeWiki, GetLinkedResources, GetResourceWithChildren, + SubjectsSelectors, } from '@osf/shared/stores'; import { GetActivityLogs } from '@osf/shared/stores/activity-logs'; import { @@ -119,6 +121,8 @@ export class ProjectOverviewComponent extends DataciteTrackerComponent implement isReviewActionsLoading = select(CollectionsModerationSelectors.getCurrentReviewActionLoading); components = select(CurrentResourceSelectors.getResourceWithChildren); areComponentsLoading = select(CurrentResourceSelectors.isResourceWithChildrenLoading); + subjects = select(SubjectsSelectors.getSelectedSubjects); + areSubjectsLoading = select(SubjectsSelectors.areSelectedSubjectsLoading); readonly activityPageSize = 5; readonly activityDefaultPage = 1; @@ -141,6 +145,7 @@ export class ProjectOverviewComponent extends DataciteTrackerComponent implement getComponentsTree: GetResourceWithChildren, getRootFolders: GetRootFolders, getConfiguredStorageAddons: GetConfiguredStorageAddons, + getSubjects: FetchSelectedSubjects, }); currentProject = select(ProjectOverviewSelectors.getProject); @@ -178,14 +183,19 @@ export class ProjectOverviewComponent extends DataciteTrackerComponent implement resourceOverview = computed(() => { const project = this.currentProject(); + const subjects = this.subjects(); if (project) { - return MapProjectOverview(project, this.isAnonymous()); + return MapProjectOverview(project, subjects, this.isAnonymous()); } return null; }); isLoading = computed( - () => this.isProjectLoading() || this.isCollectionProviderLoading() || this.isReviewActionsLoading() + () => + this.isProjectLoading() || + this.isCollectionProviderLoading() || + this.isReviewActionsLoading() || + this.areSubjectsLoading() ); currentResource = computed(() => { @@ -221,6 +231,7 @@ export class ProjectOverviewComponent extends DataciteTrackerComponent implement if (currentProject) { const rootParentId = currentProject.rootParentId ?? currentProject.id; this.actions.getComponentsTree(rootParentId, currentProject.id, ResourceType.Project); + this.actions.getSubjects(currentProject.id, ResourceType.Project); } }); } diff --git a/src/app/features/project/project.routes.ts b/src/app/features/project/project.routes.ts index bf93b0e7d..7326c49a5 100644 --- a/src/app/features/project/project.routes.ts +++ b/src/app/features/project/project.routes.ts @@ -45,6 +45,7 @@ export const projectRoutes: Routes = [ CollectionsState, CollectionsModerationState, ActivityLogsState, + SubjectsState, ]), ], }, diff --git a/src/app/features/registries/components/metadata/registries-license/registries-license.component.html b/src/app/features/registries/components/metadata/registries-license/registries-license.component.html index 2a0123131..3f94d45df 100644 --- a/src/app/features/registries/components/metadata/registries-license/registries-license.component.html +++ b/src/app/features/registries/components/metadata/registries-license/registries-license.component.html @@ -4,7 +4,7 @@

{{ 'shared.license.title' | translate }}

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

{{ 'shared.license.helpText' | translate }} - {{ 'common.links.helpGuide' | translate }}{{ 'common.links.helpGuide' | translate }}.

[], null>; diff --git a/src/app/features/registry/models/index.ts b/src/app/features/registry/models/index.ts index fcf6c2b48..7d096d036 100644 --- a/src/app/features/registry/models/index.ts +++ b/src/app/features/registry/models/index.ts @@ -1,6 +1,5 @@ export * from './bibliographic-contributors.models'; export * from './get-registry-overview-json-api.model'; -export * from './get-resource-subjects-json-api.model'; export * from './linked-nodes.models'; export * from './linked-nodes-json-api.model'; export * from './linked-registrations-json-api.model'; @@ -10,5 +9,4 @@ export * from './registry-components-json-api.model'; export * from './registry-contributor-json-api.model'; export * from './registry-metadata.models'; export * from './registry-overview.models'; -export * from './registry-subject.model'; export * from './resources'; diff --git a/src/app/features/registry/models/registry-overview.models.ts b/src/app/features/registry/models/registry-overview.models.ts index 778b13fad..59aeb0e17 100644 --- a/src/app/features/registry/models/registry-overview.models.ts +++ b/src/app/features/registry/models/registry-overview.models.ts @@ -1,5 +1,5 @@ import { ProjectOverviewContributor } from '@osf/features/project/overview/models'; -import { RegistrationQuestions, RegistrySubject } from '@osf/features/registry/models'; +import { RegistrationQuestions } from '@osf/features/registry/models'; import { IdTypeModel, LicenseModel, @@ -7,6 +7,7 @@ import { MetaAnonymousJsonApi, ProviderModel, SchemaResponse, + SubjectModel, } from '@osf/shared/models'; import { RegistrationReviewStates, RegistryStatus, RevisionReviewStates } from '@shared/enums'; @@ -45,7 +46,7 @@ export interface RegistryOverview { currentUserIsContributorOrGroupMember: boolean; wikiEnabled: boolean; region?: IdTypeModel; - subjects?: RegistrySubject[]; + subjects?: SubjectModel[]; customCitation: string; hasData: boolean; hasAnalyticCode: boolean; diff --git a/src/app/features/registry/models/registry-subject.model.ts b/src/app/features/registry/models/registry-subject.model.ts deleted file mode 100644 index 19f1c6c07..000000000 --- a/src/app/features/registry/models/registry-subject.model.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface RegistrySubject { - id: string; - text: string; -} diff --git a/src/app/features/registry/pages/registry-overview/registry-overview.component.html b/src/app/features/registry/pages/registry-overview/registry-overview.component.html index 00d7ee9d4..52f18d280 100644 --- a/src/app/features/registry/pages/registry-overview/registry-overview.component.html +++ b/src/app/features/registry/pages/registry-overview/registry-overview.component.html @@ -1,4 +1,4 @@ -@if (!isRegistryLoading() && !isSubjectsLoading() && !isInstitutionsLoading() && !isSchemaBlocksLoading()) { +@if (!isLoading()) {
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 }}