Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/app/features/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router';

import { MY_PROJECTS_TABLE_PARAMS } from '@osf/core/constants';
import { MyProjectsItem } from '@osf/features/my-projects/models';
import { AddProjectFormComponent, MyProjectsTableComponent, SubHeaderComponent } from '@osf/shared/components';
import { MyProjectsTableComponent, SubHeaderComponent } from '@osf/shared/components';
import { SortOrder } from '@osf/shared/enums';
import { TableParameters } from '@osf/shared/models';
import { IS_MEDIUM } from '@osf/shared/utils';
import { FetchUserInstitutions } from '@shared/stores';

import { CreateProjectDialogComponent } from '../my-projects/components';
import { MyProjectsSearchFilters } from '../my-projects/models';
import { ClearMyProjects, GetMyProjects, MyProjectsSelectors } from '../my-projects/store';
import { AccountSettingsService } from '../settings/account-settings/services';
Expand Down Expand Up @@ -233,7 +234,7 @@ export class HomeComponent implements OnInit {
this.isSubmitting.set(true);

this.dialogService
.open(AddProjectFormComponent, {
.open(CreateProjectDialogComponent, {
width: dialogWidth,
focusOnShow: false,
header: this.translateService.instant('myProjects.header.createProject'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ChangeDetectionStrategy, Component, computed, input } from '@angular/co
import { RouterLink } from '@angular/router';

import { ResourceTab } from '@shared/enums';
import { Subject } from '@shared/models';
import { SubjectModel } from '@shared/models';

@Component({
selector: 'osf-browse-by-subjects',
Expand All @@ -17,7 +17,7 @@ import { Subject } from '@shared/models';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BrowseBySubjectsComponent {
subjects = input.required<Subject[]>();
subjects = input.required<SubjectModel[]>();
linksToSearchPageForSubject = computed(() => {
return this.subjects().map((subject) => ({
resourceTab: ResourceTab.Preprints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h2>Publication DOI</h2>
</p-card>

<div class="m-t-24">
<osf-preprints-subjects />
<osf-preprints-subjects [preprintId]="createdPreprint()?.id" />
</div>

<p-card styleClass="m-t-24" class="card">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<osf-subjects
[areSubjectsUpdating]="isSubjectsUpdating()"
[selected]="selectedSubjects()"
(loadChildren)="getSubjectChildren($event)"
(searchChanged)="searchSubjects($event)"
(updateSelection)="updateSelectedSubjects($event)"
/>
<p-card>
<osf-subjects
[areSubjectsUpdating]="isSubjectsUpdating()"
[selected]="selectedSubjects()"
(loadChildren)="getSubjectChildren($event)"
(searchChanged)="searchSubjects($event)"
(updateSelection)="updateSelectedSubjects($event)"
></osf-subjects>
</p-card>
Original file line number Diff line number Diff line change
@@ -1,49 +1,56 @@
import { createDispatchMap, select } from '@ngxs/store';

import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { Card } from 'primeng/card';

import {
FetchPreprintsSubjects,
SubmitPreprintSelectors,
UpdatePreprintsSubjects,
} from '@osf/features/preprints/store/submit-preprint';
import { ChangeDetectionStrategy, Component, input, OnInit } from '@angular/core';

import { SubmitPreprintSelectors } from '@osf/features/preprints/store/submit-preprint';
import { SubjectsComponent } from '@osf/shared/components';
import { Subject } from '@osf/shared/models';
import { FetchChildrenSubjects, FetchSubjects } from '@osf/shared/stores';
import { ResourceType } from '@osf/shared/enums';
import { SubjectModel } from '@osf/shared/models';
import {
FetchChildrenSubjects,
FetchSelectedSubjects,
FetchSubjects,
SubjectsSelectors,
UpdateResourceSubjects,
} from '@osf/shared/stores';

@Component({
selector: 'osf-preprints-subjects',
imports: [SubjectsComponent],
imports: [SubjectsComponent, Card],
templateUrl: './preprints-subjects.component.html',
styleUrl: './preprints-subjects.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class PreprintsSubjectsComponent implements OnInit {
preprintId = input<string>();

private readonly selectedProviderId = select(SubmitPreprintSelectors.getSelectedProviderId);
protected selectedSubjects = select(SubmitPreprintSelectors.getSelectedSubjects);
protected isSubjectsUpdating = select(SubmitPreprintSelectors.isSubjectsUpdating);
protected selectedSubjects = select(SubjectsSelectors.getSelectedSubjects);
protected isSubjectsUpdating = select(SubjectsSelectors.areSelectedSubjectsLoading);

protected actions = createDispatchMap({
fetchSubjects: FetchSubjects,
fetchPreprintsSubjects: FetchPreprintsSubjects,
fetchSelectedSubjects: FetchSelectedSubjects,
fetchChildrenSubjects: FetchChildrenSubjects,
updatePreprintsSubjects: UpdatePreprintsSubjects,
updateResourceSubjects: UpdateResourceSubjects,
});

ngOnInit(): void {
this.actions.fetchSubjects(this.selectedProviderId()!);
this.actions.fetchPreprintsSubjects();
this.actions.fetchSubjects(ResourceType.Preprint, this.selectedProviderId()!);
this.actions.fetchSelectedSubjects(this.preprintId()!, ResourceType.Preprint);
}

getSubjectChildren(parentId: string) {
this.actions.fetchChildrenSubjects(parentId);
}

searchSubjects(search: string) {
this.actions.fetchSubjects(search);
this.actions.fetchSubjects(ResourceType.Preprint, this.selectedProviderId()!, search);
}

updateSelectedSubjects(subjects: Subject[]) {
this.actions.updatePreprintsSubjects(subjects);
updateSelectedSubjects(subjects: SubjectModel[]) {
this.actions.updateResourceSubjects(this.preprintId()!, ResourceType.Preprint, subjects);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PreprintProviderDetailsJsonApi,
PreprintProviderShortInfo,
} from '@osf/features/preprints/models';
import { Subject, SubjectDataJsonApi } from '@shared/models';
import { SubjectDataJsonApi, SubjectModel } from '@shared/models';

export class PreprintProvidersMapper {
static fromPreprintProviderDetailsGetResponse(response: PreprintProviderDetailsJsonApi): PreprintProviderDetails {
Expand Down Expand Up @@ -44,7 +44,7 @@ export class PreprintProvidersMapper {
}));
}

static fromSubjectsGetResponse(data: SubjectDataJsonApi[]): Subject[] {
static fromSubjectsGetResponse(data: SubjectDataJsonApi[]): SubjectModel[] {
return data.map((subject) => ({
id: subject.id,
name: subject.attributes.text,
Expand Down
6 changes: 0 additions & 6 deletions src/app/features/preprints/preprints.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import { provideStates } from '@ngxs/store';
import { Routes } from '@angular/router';

import { PreprintsComponent } from '@osf/features/preprints/preprints.component';
import { PreprintSubjectsService } from '@osf/features/preprints/services';
import { PreprintProvidersState } from '@osf/features/preprints/store/preprint-providers';
import { PreprintsDiscoverState } from '@osf/features/preprints/store/preprints-discover';
import { PreprintsResourcesFiltersState } from '@osf/features/preprints/store/preprints-resources-filters';
import { PreprintsResourcesFiltersOptionsState } from '@osf/features/preprints/store/preprints-resources-filters-options';
import { SubmitPreprintState } from '@osf/features/preprints/store/submit-preprint';
import { ContributorsState, SubjectsState } from '@shared/stores';
import { SUBJECTS_SERVICE } from '@shared/tokens/subjects.token';

export const preprintsRoutes: Routes = [
{
Expand All @@ -26,10 +24,6 @@ export const preprintsRoutes: Routes = [
ContributorsState,
SubjectsState,
]),
{
provide: SUBJECTS_SERVICE,
useClass: PreprintSubjectsService,
},
],
children: [
{
Expand Down
1 change: 0 additions & 1 deletion src/app/features/preprints/services/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export { PreprintFilesService } from './preprint-files.service';
export { PreprintLicensesService } from './preprint-licenses.service';
export { PreprintProvidersService } from './preprint-providers.service';
export { PreprintSubjectsService } from './preprint-subjects.service';
export { PreprintsService } from './preprints.service';
export { PreprintsProjectsService } from './preprints-projects.service';
export { PreprintsFiltersOptionsService } from './preprints-resource-filters.service';
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
PreprintProviderDetailsJsonApi,
PreprintProviderShortInfo,
} from '@osf/features/preprints/models';
import { Subject, SubjectsResponseJsonApi } from '@shared/models';
import { SubjectModel, SubjectsResponseJsonApi } from '@shared/models';

import { environment } from 'src/environments/environment';

Expand Down Expand Up @@ -55,7 +55,7 @@ export class PreprintProvidersService {
);
}

getHighlightedSubjectsByProviderId(providerId: string): Observable<Subject[]> {
getHighlightedSubjectsByProviderId(providerId: string): Observable<SubjectModel[]> {
return this.jsonApiService
.get<SubjectsResponseJsonApi>(`${this.baseUrl}${providerId}/subjects/highlighted/?page[size]=20`)
.pipe(
Expand Down
78 changes: 0 additions & 78 deletions src/app/features/preprints/services/preprint-subjects.service.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { PreprintProviderDetails, PreprintProviderShortInfo } from '@osf/features/preprints/models';
import { AsyncStateModel, Subject } from '@shared/models';
import { AsyncStateModel, SubjectModel } from '@shared/models';

export interface PreprintProvidersStateModel {
preprintProvidersDetails: AsyncStateModel<PreprintProviderDetails[]>;
preprintProvidersToAdvertise: AsyncStateModel<PreprintProviderShortInfo[]>;
preprintProvidersAllowingSubmissions: AsyncStateModel<PreprintProviderShortInfo[]>;
highlightedSubjectsForProvider: AsyncStateModel<Subject[]>;
highlightedSubjectsForProvider: AsyncStateModel<SubjectModel[]>;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { StringOrNull } from '@core/helpers';
import { PreprintFileSource } from '@osf/features/preprints/enums';
import { Preprint } from '@osf/features/preprints/models';
import { LicenseOptions, OsfFile, Subject } from '@shared/models';
import { LicenseOptions, OsfFile } from '@shared/models';

export class SetSelectedPreprintProviderId {
static readonly type = '[Submit Preprint] Set Selected Preprint Provider Id';
Expand Down Expand Up @@ -91,16 +91,6 @@ export class SaveLicense {
) {}
}

export class FetchPreprintsSubjects {
static readonly type = '[Submit Preprint] Fetch Registration Subjects';
}

export class UpdatePreprintsSubjects {
static readonly type = '[Submit Preprint] Update Registration Subject';

constructor(public subjects: Subject[]) {}
}

export class DisconnectProject {
static readonly type = '[Submit Preprint] Disconnect Preprint Project';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { StringOrNull } from '@core/helpers';
import { PreprintFileSource } from '@osf/features/preprints/enums';
import { Preprint, PreprintFilesLinks } from '@osf/features/preprints/models';
import { AsyncStateModel, IdName, OsfFile, Subject } from '@shared/models';
import { AsyncStateModel, IdName, OsfFile } from '@shared/models';
import { License } from '@shared/models/license.model';

export interface SubmitPreprintStateModel {
Expand All @@ -13,6 +13,5 @@ export interface SubmitPreprintStateModel {
availableProjects: AsyncStateModel<IdName[]>;
projectFiles: AsyncStateModel<OsfFile[]>;
licenses: AsyncStateModel<License[]>;
subjects: AsyncStateModel<Subject[]>;
preprintProject: AsyncStateModel<IdName | null>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ export class SubmitPreprintSelectors {
return state.licenses.data;
}

@Selector([SubmitPreprintState])
static getSelectedSubjects(state: SubmitPreprintStateModel) {
return state.subjects.data;
}

@Selector([SubmitPreprintState])
static isSubjectsUpdating(state: SubmitPreprintStateModel) {
return state.subjects.isLoading;
}

@Selector([SubmitPreprintState])
static getPreprintProject(state: SubmitPreprintStateModel) {
return state.preprintProject.data;
Expand Down
Loading