Skip to content

Commit f0944a8

Browse files
committed
update preprint licance set logic
1 parent a3dd1d9 commit f0944a8

File tree

5 files changed

+18
-0
lines changed

5 files changed

+18
-0
lines changed

src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-metadata-step.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angula
1414

1515
import { formInputLimits } from '@osf/features/preprints/constants';
1616
import { MetadataForm, PreprintModel, PreprintProviderDetails } from '@osf/features/preprints/models';
17+
import { PreprintSelectors } from '@osf/features/preprints/store/preprint';
1718
import {
1819
CreatePreprint,
1920
FetchLicenses,
@@ -77,6 +78,7 @@ export class PreprintsMetadataStepComponent implements OnInit {
7778
licenses = select(PreprintStepperSelectors.getLicenses);
7879
createdPreprint = select(PreprintStepperSelectors.getPreprint);
7980
isUpdatingPreprint = select(PreprintStepperSelectors.isPreprintSubmitting);
81+
isLicenseSet = select(PreprintSelectors.isLicenseSet);
8082

8183
provider = input.required<PreprintProviderDetails | undefined>();
8284
nextClicked = output<void>();
@@ -85,6 +87,9 @@ export class PreprintsMetadataStepComponent implements OnInit {
8587
ngOnInit() {
8688
this.actions.fetchLicenses();
8789
this.initForm();
90+
console.log('this.createdPreprint ' + this.createdPreprint());
91+
// console.log('selectedLicense ' + this.selectedLicense());
92+
alert('this.createdPreprint ' + this.isLicenseSet());
8893
}
8994

9095
initForm() {
@@ -135,6 +140,7 @@ export class PreprintsMetadataStepComponent implements OnInit {
135140
}
136141

137142
selectLicense(license: LicenseModel) {
143+
alert('selectLicense');
138144
if (license.requiredFields.length) {
139145
return;
140146
}

src/app/features/preprints/mappers/preprints.mapper.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class PreprintsMapper {
3838
static fromPreprintJsonApi(
3939
response: ApiData<PreprintAttributesJsonApi, null, PreprintRelationshipsJsonApi, PreprintLinksJsonApi>
4040
): PreprintModel {
41+
console.log(' response ', response);
4142
return {
4243
id: response.id,
4344
dateCreated: response.attributes.date_created,
@@ -82,6 +83,9 @@ export class PreprintsMapper {
8283
articleDoiLink: response.links.doi,
8384
embeddedLicense: null,
8485
providerId: response.relationships?.provider?.data?.id,
86+
defaultLicenseId: response.attributes.default_license_id,
87+
// license: response.attributes.license_record,
88+
isLicenseSet: !!response.attributes.license_record,
8589
};
8690
}
8791

src/app/features/preprints/models/preprint-json-api.models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export interface PreprintAttributesJsonApi {
3737
why_no_prereg: StringOrNull;
3838
prereg_links: string[];
3939
prereg_link_info: PreregLinkInfo | null;
40+
default_license_id: string;
4041
}
4142

4243
export interface PreprintRelationshipsJsonApi {

src/app/features/preprints/models/preprint.models.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export interface PreprintModel {
4747
articleDoiLink?: string;
4848
identifiers?: IdentifierModel[];
4949
providerId: string;
50+
defaultLicenseId?: string;
51+
isLicenseSet?: boolean;
5052
}
5153

5254
export interface PreprintFilesLinks {

src/app/features/preprints/store/preprint/preprint.selectors.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ export class PreprintSelectors {
1111
return state.preprint.data;
1212
}
1313

14+
@Selector([PreprintState])
15+
static isLicenseSet(state: PreprintStateModel) {
16+
return state.preprint.data?.isLicenseSet || null;
17+
}
18+
1419
@Selector([PreprintState])
1520
static isPreprintSubmitting(state: PreprintStateModel) {
1621
return state.preprint.isSubmitting;

0 commit comments

Comments
 (0)