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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { AddToCollectionSelectors } from '@osf/features/collections/store/add-to
import { TagsInputComponent, TextInputComponent, TruncatedTextComponent } from '@shared/components';
import { InputLimits } from '@shared/constants';
import { ResourceType } from '@shared/enums';
import { License } from '@shared/models';
import { LicenseModel } from '@shared/models';
import { Project } from '@shared/models/projects';
import { InterpolatePipe } from '@shared/pipes';
import { ToastService } from '@shared/services';
Expand Down Expand Up @@ -74,14 +74,14 @@ export class ProjectMetadataStepComponent {
private readonly toastService = inject(ToastService);
private readonly destroyRef = inject(DestroyRef);
private readonly formService = inject(ProjectMetadataFormService);
protected readonly currentYear = new Date();
readonly currentYear = new Date();

protected readonly ProjectMetadataFormControls = ProjectMetadataFormControls;
protected readonly inputLimits = InputLimits;
readonly ProjectMetadataFormControls = ProjectMetadataFormControls;
readonly inputLimits = InputLimits;

protected readonly selectedProject = select(ProjectsSelectors.getSelectedProject);
protected readonly collectionLicenses = select(AddToCollectionSelectors.getCollectionLicenses);
protected readonly isSelectedProjectUpdateSubmitting = select(ProjectsSelectors.getSelectedProjectUpdateSubmitting);
readonly selectedProject = select(ProjectsSelectors.getSelectedProject);
readonly collectionLicenses = select(AddToCollectionSelectors.getCollectionLicenses);
readonly isSelectedProjectUpdateSubmitting = select(ProjectsSelectors.getSelectedProjectUpdateSubmitting);

stepperActiveValue = input.required<number>();
targetStepValue = input.required<number>();
Expand All @@ -91,21 +91,21 @@ export class ProjectMetadataStepComponent {
stepChange = output<number>();
metadataSaved = output<void>();

protected actions = createDispatchMap({
actions = createDispatchMap({
updateCollectionSubmissionMetadata: UpdateProjectMetadata,
getAllContributors: GetAllContributors,
getCollectionLicenses: GetCollectionLicenses,
clearProjects: ClearProjects,
});

protected readonly projectMetadataForm: FormGroup<ProjectMetadataForm> = this.formService.createForm();
protected readonly projectTags = signal<string[]>([]);
protected readonly selectedLicense = signal<License | null>(null);
readonly projectMetadataForm: FormGroup<ProjectMetadataForm> = this.formService.createForm();
readonly projectTags = signal<string[]>([]);
readonly selectedLicense = signal<LicenseModel | null>(null);

private readonly projectMetadataFormValue = toSignal(this.projectMetadataForm.valueChanges);
private readonly initialProjectMetadataFormValues = signal<string | null>(null);

protected readonly projectLicense = computed(() => {
readonly projectLicense = computed(() => {
const project = this.selectedProject();
return project ? (this.collectionLicenses().find((license) => license.id === project.licenseId) ?? null) : null;
});
Expand All @@ -131,7 +131,7 @@ export class ProjectMetadataStepComponent {
}

handleSelectCollectionLicense(event: SelectChangeEvent): void {
const license = event.value as License;
const license = event.value as LicenseModel;
const project = this.selectedProject();

if (!license || !project) return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { FormControl } from '@angular/forms';

import { ProjectMetadataFormControls } from '@osf/features/collections/enums';
import { License } from '@shared/models';
import { LicenseModel } from '@shared/models';

export interface ProjectMetadataForm {
[ProjectMetadataFormControls.Title]: FormControl<string>;
[ProjectMetadataFormControls.Description]: FormControl<string>;
[ProjectMetadataFormControls.License]: FormControl<License | null>;
[ProjectMetadataFormControls.License]: FormControl<LicenseModel | null>;
[ProjectMetadataFormControls.Tags]: FormControl<string[]>;
[ProjectMetadataFormControls.LicenseYear]: FormControl<string>;
[ProjectMetadataFormControls.CopyrightHolders]: FormControl<string>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { map, Observable } from 'rxjs';
import { inject, Injectable } from '@angular/core';

import { CollectionsMapper, LicensesMapper } from '@shared/mappers';
import { CollectionSubmissionPayload, License, LicensesResponseJsonApi } from '@shared/models';
import { CollectionSubmissionPayload, LicenseModel, LicensesResponseJsonApi } from '@shared/models';
import { JsonApiService } from '@shared/services';

import { environment } from 'src/environments/environment';
Expand All @@ -15,7 +15,7 @@ export class AddToCollectionService {
private apiUrl = environment.apiUrl;
private readonly jsonApiService = inject(JsonApiService);

fetchCollectionLicenses(providerId: string): Observable<License[]> {
fetchCollectionLicenses(providerId: string): Observable<LicenseModel[]> {
return this.jsonApiService
.get<LicensesResponseJsonApi>(`${this.apiUrl}/providers/collections/${providerId}/licenses/`, {
'page[size]': 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormControl, FormGroup, Validators } from '@angular/forms';
import { ProjectMetadataFormControls } from '@osf/features/collections/enums';
import { ProjectMetadataForm } from '@osf/features/collections/models';
import { CustomValidators } from '@osf/shared/helpers';
import { License, ProjectMetadataUpdatePayload } from '@shared/models';
import { LicenseModel, ProjectMetadataUpdatePayload } from '@shared/models';
import { Project } from '@shared/models/projects';

@Injectable({
Expand Down Expand Up @@ -40,7 +40,7 @@ export class ProjectMetadataFormService {
});
}

updateLicenseValidators(form: FormGroup<ProjectMetadataForm>, license: License): void {
updateLicenseValidators(form: FormGroup<ProjectMetadataForm>, license: LicenseModel): void {
const yearControl = form.get(ProjectMetadataFormControls.LicenseYear);
const copyrightHoldersControl = form.get(ProjectMetadataFormControls.CopyrightHolders);

Expand All @@ -56,7 +56,7 @@ export class ProjectMetadataFormService {
populateFormFromProject(
form: FormGroup<ProjectMetadataForm>,
project: Project,
license: License | null
license: LicenseModel | null
): { tags: string[] } {
const tags = project.tags || [];

Expand All @@ -73,7 +73,7 @@ export class ProjectMetadataFormService {
return { tags };
}

patchLicenseData(form: FormGroup<ProjectMetadataForm>, license: License, project: Project): void {
patchLicenseData(form: FormGroup<ProjectMetadataForm>, license: LicenseModel, project: Project): void {
form.patchValue({
[ProjectMetadataFormControls.License]: license,
[ProjectMetadataFormControls.LicenseYear]:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { License } from '@shared/models';
import { LicenseModel } from '@shared/models';
import { AsyncStateModel } from '@shared/models/store';

export interface AddToCollectionStateModel {
collectionLicenses: AsyncStateModel<License[]>;
collectionLicenses: AsyncStateModel<LicenseModel[]>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h2>{{ 'project.overview.metadata.contributors' | translate }}</h2>
<div class="inline-flex gap-1 line-height-2 pt-4">
@for (contributor of contributors(); track contributor.id) {
<div>
<a class="font-bold"> {{ contributor.fullName }}</a>
<a class="font-bold" [routerLink]="['/user', contributor.userId]"> {{ contributor.fullName }}</a>
<span>{{ $last ? '' : ',' }}</span>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { MockProvider } from 'ng-mocks';

import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';

import { ContributorModel } from '@osf/shared/models';
import { MOCK_CONTRIBUTOR, TranslateServiceMock } from '@shared/mocks';
Expand All @@ -14,7 +17,7 @@ describe('MetadataContributorsComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MetadataContributorsComponent],
providers: [TranslateServiceMock],
providers: [TranslateServiceMock, MockProvider(ActivatedRoute)],
}).compileComponents();

fixture = TestBed.createComponent(MetadataContributorsComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { Button } from 'primeng/button';
import { Card } from 'primeng/card';

import { ChangeDetectionStrategy, Component, input, output } from '@angular/core';
import { RouterLink } from '@angular/router';

import { ContributorModel } from '@osf/shared/models';

@Component({
selector: 'osf-metadata-contributors',
imports: [Button, Card, TranslatePipe],
imports: [Button, Card, TranslatePipe, RouterLink],
templateUrl: './metadata-contributors.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h2>{{ 'project.overview.metadata.description' | translate }}</h2>
<p-button
severity="secondary"
[label]="'common.buttons.edit' | translate"
(click)="openEditDescriptionDialog.emit()"
(onClick)="openEditDescriptionDialog.emit()"
></p-button>
}
</div>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h2>{{ 'project.overview.metadata.fundingSupport' | translate }}</h2>
<p-button
severity="secondary"
[label]="'common.buttons.edit' | translate"
(click)="openEditFundingDialog.emit()"
(onClick)="openEditFundingDialog.emit()"
></p-button>
}
</div>
Expand All @@ -22,23 +22,21 @@ <h2>{{ 'project.overview.metadata.fundingSupport' | translate }}</h2>
@if (funder.awardUri) {
<p>
{{ 'files.detail.resourceMetadata.fields.awardUri' | translate }}:
<a [href]="funder.awardUri" target="_blank" class="text-primary text-sm">{{ funder.awardTitle }}</a>
<a class="font-bold" [href]="funder.awardUri" target="_blank">
{{ funder.awardUri }}
</a>
</p>
}

@if (funder.awardNumber) {
<p>{{ 'files.detail.resourceMetadata.fields.awardNumber' | translate }} : {{ funder.awardNumber }}</p>
}

@if (funder.awardUri) {
<a [href]="funder.awardUri" target="_blank" class="text-primary text-sm">{{ funder.awardUri }}</a>
<p>{{ 'files.detail.resourceMetadata.fields.awardNumber' | translate }}: {{ funder.awardNumber }}</p>
}
</div>
}
</div>
} @else {
<div class="pt-4">
<p class="text-color-secondary">{{ 'project.overview.metadata.noSupplements' | translate }}</p>
<p class="text-color-secondary">{{ 'project.overview.metadata.noInformation' | translate }}</p>
</div>
}
</p-card>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Card } from 'primeng/card';

import { ChangeDetectionStrategy, Component, input, output } from '@angular/core';

import { Funder } from '@osf/features/metadata/models';
import { Funder } from '../../models';

@Component({
selector: 'osf-metadata-funding',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h2>{{ 'project.overview.metadata.license' | translate }}</h2>
<p-button
severity="secondary"
[label]="'common.buttons.edit' | translate"
(click)="openEditLicenseDialog.emit()"
(onClick)="openEditLicenseDialog.emit()"
/>
}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Card } from 'primeng/card';

import { ChangeDetectionStrategy, Component, input, output } from '@angular/core';

import { License } from '@shared/models';
import { LicenseModel } from '@shared/models';

@Component({
selector: 'osf-metadata-license',
Expand All @@ -16,5 +16,5 @@ import { License } from '@shared/models';
export class MetadataLicenseComponent {
openEditLicenseDialog = output<void>();
hideEditLicense = input<boolean>(false);
license = input<License | null>(null);
license = input<LicenseModel | null>(null);
}
Loading
Loading