Skip to content
Open
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 @@ -45,6 +45,7 @@ import { InterpolatePipe } from '@osf/shared/pipes/interpolate.pipe';
import { ToastService } from '@osf/shared/services/toast.service';
import { GetAllContributors } from '@osf/shared/stores/contributors';
import { ClearProjects, ProjectsSelectors, UpdateProjectMetadata } from '@osf/shared/stores/projects';
import { CollectionsSelectors } from '@shared/stores/collections';

@Component({
selector: 'osf-project-metadata-step',
Expand Down Expand Up @@ -86,6 +87,7 @@ export class ProjectMetadataStepComponent {
readonly inputLimits = InputLimits;

readonly selectedProject = select(ProjectsSelectors.getSelectedProject);
readonly collectionProvider = select(CollectionsSelectors.getCollectionProvider);
readonly collectionLicenses = select(AddToCollectionSelectors.getCollectionLicenses);
readonly isSelectedProjectUpdateSubmitting = select(ProjectsSelectors.getSelectedProjectUpdateSubmitting);

Expand Down Expand Up @@ -113,7 +115,8 @@ export class ProjectMetadataStepComponent {

readonly projectLicense = computed(() => {
const project = this.selectedProject();
return project ? (this.collectionLicenses().find((license) => license.id === project.licenseId) ?? null) : null;
const licenseId = project?.licenseId || this.collectionProvider()?.defaultLicenseId;
return project ? (this.collectionLicenses().find((license) => license.id === licenseId) ?? null) : null;
});

private readonly isFormUnchanged = computed(() => {
Expand Down Expand Up @@ -235,7 +238,6 @@ export class ProjectMetadataStepComponent {
this.formService.updateLicenseValidators(this.projectMetadataForm, license);
});
}

this.populateFormFromProject();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { FormControl, FormGroup, Validators } from '@angular/forms';
import { UserSelectors } from '@core/store/user';
import { ProjectFormControls } from '@osf/shared/enums/create-project-form-controls.enum';
import { CustomValidators } from '@osf/shared/helpers/custom-form-validators.helper';
import { ProjectModel } from '@osf/shared/models/projects/projects.model';
import { InstitutionsSelectors } from '@osf/shared/stores/institutions';
import { ProjectsSelectors } from '@osf/shared/stores/projects';
import { RegionsSelectors } from '@osf/shared/stores/regions';
import { ProjectForm } from '@shared/models/projects/create-project-form.model';
import { ProjectModel } from '@shared/models/projects/projects.models';

import { AffiliatedInstitutionSelectComponent } from '../affiliated-institution-select/affiliated-institution-select.component';
import { ProjectSelectorComponent } from '../project-selector/project-selector.component';
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/mappers/collections/collections.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class CollectionsMapper {
id: response.relationships.primary_collection.data.id,
type: response.relationships.primary_collection.data.type,
},
defaultLicenseId: response.attributes?.default_license_id,
brand: response.embeds.brand.data
? {
id: response.embeds.brand.data.id,
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/models/collections/collections.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface CollectionProvider extends BaseProviderModel {
type: string;
};
brand: BrandModel | null;
defaultLicenseId?: string | null;
}

export interface CollectionFilters {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export interface BaseProviderAttributesJsonApi {
reviews_workflow: string;
share_publish_type: string;
share_source: string;
default_license_id?: string | null;
}