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
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,27 @@ <h3>{{ 'collections.addToCollection.resourceMetadata' | translate }}</h3>
<p-divider class="my-3" />
@if (license.requiredFields.length) {
<div class="flex flex-column gap-3 mb-3 w-full md:flex-row">
<div class="w-full md:w-6">
<label for="licenseYear"> {{ 'common.labels.year' | translate }} </label>
<p-datePicker
inputId="licenseYear"
[formControlName]="ProjectMetadataFormControls.LicenseYear"
[maxDate]="currentYear"
dataType="string"
view="year"
dateFormat="yy"
@if (license.requiredFields.includes('year')) {
<div class="w-full md:w-6">
<label for="licenseYear"> {{ 'common.labels.year' | translate }} </label>
<p-datePicker
inputId="licenseYear"
[formControlName]="ProjectMetadataFormControls.LicenseYear"
[maxDate]="currentYear"
dataType="string"
view="year"
dateFormat="yy"
/>
</div>
}
@if (license.requiredFields.includes('copyrightHolders')) {
<osf-text-input
class="w-full md:w-6"
label="shared.license.copyrightHolders"
[control]="projectMetadataForm.controls[ProjectMetadataFormControls.CopyrightHolders]"
[maxLength]="inputLimits.fullName.maxLength"
/>
</div>
<osf-text-input
class="w-full md:w-6"
label="shared.license.copyrightHolders"
[control]="projectMetadataForm.controls[ProjectMetadataFormControls.CopyrightHolders]"
[maxLength]="inputLimits.fullName.maxLength"
/>
}
</div>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class ProjectMetadataStepComponent {
this.formService.updateLicenseValidators(this.projectMetadataForm, license);
});
}
this.populateFormFromProject();
untracked(() => this.populateFormFromProject());
});

effect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ export class ProjectMetadataFormService {
const yearControl = form.get(ProjectMetadataFormControls.LicenseYear);
const copyrightHoldersControl = form.get(ProjectMetadataFormControls.CopyrightHolders);

const validators = license.requiredFields.length ? [CustomValidators.requiredTrimmed()] : [];

yearControl?.setValidators(validators);
copyrightHoldersControl?.setValidators(validators);
yearControl?.setValidators(license.requiredFields.includes('year') ? [CustomValidators.requiredTrimmed()] : []);
copyrightHoldersControl?.setValidators(
license.requiredFields.includes('copyrightHolders') ? [CustomValidators.requiredTrimmed()] : []
);

yearControl?.updateValueAndValidity();
copyrightHoldersControl?.updateValueAndValidity();
Expand Down
Loading