diff --git a/src/app/core/submission/models/submission-cc-license.model.ts b/src/app/core/submission/models/submission-cc-license.model.ts index 8ab235941fc..9ad60ea2462 100644 --- a/src/app/core/submission/models/submission-cc-license.model.ts +++ b/src/app/core/submission/models/submission-cc-license.model.ts @@ -43,4 +43,5 @@ export interface Option { id: string; label: string; description: string; + default: boolean; } diff --git a/src/app/submission/sections/cc-license/submission-section-cc-licenses.component.html b/src/app/submission/sections/cc-license/submission-section-cc-licenses.component.html index 93251f5a2d1..3d6ff635a6c 100644 --- a/src/app/submission/sections/cc-license/submission-section-cc-licenses.component.html +++ b/src/app/submission/sections/cc-license/submission-section-cc-licenses.component.html @@ -1,147 +1,142 @@ @if (submissionCcLicenses) { -
-
- - -
-
+
+

+ + + + {{ getSelectedCcLicense().name }} + + + + {{ 'submission.sections.ccLicense.change' | translate }} + + + {{ 'submission.sections.ccLicense.select' | translate }} + + + + + + + + +
} -@if (getSelectedCcLicense()) { - @for (field of getSelectedCcLicense().fields; track field) { -
+ +
+
+
-
- {{ field.label }} +
{{ field.label }} +
-
+
- @if (field.enums?.length > 5) { - - - @if (option) { - - {{ option.label }} + + + + {{ option.label }} + {{ 'submission.sections.ccLicense.option.select' | translate }} + + +
+ +
+
+
+ + +
+
+ + {{ option.label }} +
+
+
+ + +
+
+ + {{ field.description }} +
+
+
+ + +
+
+ + {{ field.description }} +
+
+
+
+ + +
+
+ {{ 'submission.sections.ccLicense.selected' | translate }} + {{ licenseMap[licenseLink] }}. +

{{ 'submission.sections.ccLicense.link2' | translate }}

+
+
+

+
+
+
+ + + {{ 'submission.sections.ccLicense.copyrighted' | translate }} + + + + {{ 'submission.sections.ccLicense.confirmation' | translate }} - } - @if (!option) { + + - {{ 'submission.sections.ccLicense.option.select' | translate }} + {{ 'submission.sections.ccLicense.cczero' | translate }} - } - - -
- @for (option of field.enums; track option) { - - } -
-
- - } - @if (field.enums?.length <= 5) { - @for (option of field.enums; track option) { -
-
- - {{ option.label }} -
+
- } - } -
- } -} - -@if (ccLicenseLink$) { - @let licenseLink = (ccLicenseLink$ | async); - @if (licenseLink) { -
-
- {{ 'submission.sections.ccLicense.link' | translate }} -
- - {{ licenseLink }} - -
-
- - {{ 'submission.sections.ccLicense.confirmation' | translate }}
-
- } @else { - - } -} + +
+ + +

{{ 'submission.sections.ccLicense.attribution' | translate }}, creativecommons.org

diff --git a/src/app/submission/sections/cc-license/submission-section-cc-licenses.component.spec.ts b/src/app/submission/sections/cc-license/submission-section-cc-licenses.component.spec.ts index bcef6df20a2..acd838bc85a 100644 --- a/src/app/submission/sections/cc-license/submission-section-cc-licenses.component.spec.ts +++ b/src/app/submission/sections/cc-license/submission-section-cc-licenses.component.spec.ts @@ -56,11 +56,13 @@ describe('SubmissionSectionCcLicensesComponent', () => { { id: 'test enum id 1a I', label: 'test enum label 1a I', + default: true, description: 'test enum description 1a I', }, { id: 'test enum id 1a II', label: 'test enum label 1a II', + default: false, description: 'test enum description 1a II', }, ], @@ -73,11 +75,13 @@ describe('SubmissionSectionCcLicensesComponent', () => { { id: 'test enum id 1b I', label: 'test enum label 1b I', + default: true, description: 'test enum description 1b I', }, { id: 'test enum id 1b II', label: 'test enum label 1b II', + default: false, description: 'test enum description 1b II', }, ], @@ -102,12 +106,14 @@ describe('SubmissionSectionCcLicensesComponent', () => { { id: 'test enum id 2a I', label: 'test enum label 2a I', - description: 'test enum description 2a I', + default: true, + description: 'test enum description 2a I' }, { id: 'test enum id 2a II', label: 'test enum label 2a II', - description: 'test enum description 2a II', + default: false, + description: 'test enum description 2a II' }, ], }, @@ -119,12 +125,14 @@ describe('SubmissionSectionCcLicensesComponent', () => { { id: 'test enum id 2b I', label: 'test enum label 2b I', - description: 'test enum description 2b I', + default: true, + description: 'test enum description 2b I' }, { id: 'test enum id 2b II', label: 'test enum label 2b II', - description: 'test enum description 2b II', + default: false, + description: 'test enum description 2b II' }, ], }, diff --git a/src/app/submission/sections/cc-license/submission-section-cc-licenses.component.ts b/src/app/submission/sections/cc-license/submission-section-cc-licenses.component.ts index 5c36426d0b2..abfda0dd705 100644 --- a/src/app/submission/sections/cc-license/submission-section-cc-licenses.component.ts +++ b/src/app/submission/sections/cc-license/submission-section-cc-licenses.component.ts @@ -1,4 +1,8 @@ -import { AsyncPipe } from '@angular/common'; +import { + AsyncPipe, + NgForOf, + NgIf, +} from '@angular/common'; import { ChangeDetectorRef, Component, @@ -41,7 +45,7 @@ import { InfiniteScrollModule } from 'ngx-infinite-scroll'; import { BehaviorSubject, Observable, - of, + of as observableOf, Subscription, } from 'rxjs'; import { @@ -53,12 +57,13 @@ import { } from 'rxjs/operators'; import { DsSelectComponent } from '../../../shared/ds-select/ds-select.component'; -import { ThemedLoadingComponent } from '../../../shared/loading/themed-loading.component'; import { VarDirective } from '../../../shared/utils/var.directive'; import { SectionModelComponent } from '../models/section.model'; import { SectionDataObject } from '../models/section-data.model'; import { SectionsService } from '../sections.service'; import { renderSectionFor } from '../sections-decorator'; +import { TranslateService } from '@ngx-translate/core'; +import { MarkdownDirective } from '../../../shared/utils/markdown.directive'; /** * This component represents the submission section to select the Creative Commons license. @@ -68,15 +73,18 @@ import { renderSectionFor } from '../sections-decorator'; templateUrl: './submission-section-cc-licenses.component.html', styleUrls: ['./submission-section-cc-licenses.component.scss'], imports: [ + TranslateModule, + NgIf, AsyncPipe, + VarDirective, + NgForOf, DsSelectComponent, + NgbDropdownModule, FormsModule, InfiniteScrollModule, - NgbDropdownModule, - ThemedLoadingComponent, - TranslateModule, - VarDirective, + MarkdownDirective, ], + standalone: true, }) @renderSectionFor(SectionsType.CcLicense) export class SubmissionSectionCcLicensesComponent extends SectionModelComponent implements OnChanges, OnInit { @@ -109,6 +117,18 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent */ submissionCcLicenses: SubmissionCcLicence[] = []; + /** + * Map of licence uris to names + */ + public licenseMap: Record = { + 'http://creativecommons.org/licenses/by/4.0/' : 'CC BY 4.0 (Attribution 4.0 International)', + 'http://creativecommons.org/licenses/by-sa/4.0/' : 'CC BY-SA 4.0 (Attribution-ShareAlike 4.0 International)', + 'http://creativecommons.org/licenses/by-nc/4.0/' : 'CC BY-NC 4.0 (Attribution-NonCommercial 4.0 International)', + 'http://creativecommons.org/licenses/by-nc-sa/4.0/' : 'CC BY-NC-SA 4.0 (Attribution-NonCommercial-ShareAlike 4.0 International)', + 'http://creativecommons.org/licenses/by-nd/4.0/' : 'CC BY-ND 4.0 (Attribution-NoDerivatives 4.0 International)', + 'http://creativecommons.org/licenses/by-nc-nd/4.0/' : 'CC BY-NC-ND 4.0 (Attribution-NonCommercial-NoDerivatives 4.0 International)' + }; + /** * Reference to NgbModal */ @@ -170,6 +190,7 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent protected operationsBuilder: JsonPatchOperationsBuilder, protected configService: ConfigurationDataService, protected ref: ChangeDetectorRef, + private translate: TranslateService, @Inject('collectionIdProvider') public injectedCollectionId: string, @Inject('sectionDataProvider') public injectedSectionData: SectionDataObject, @Inject('submissionIdProvider') public injectedSubmissionId: string, @@ -212,10 +233,18 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent } this.selectedCcLicense = ccLicense; this.setAccepted(false); + + // Generate the defaults options for selected ccLicense + const defaults = {}; + ccLicense.fields.forEach(field => { + const defaultEnumOption = field.enums.find(enumOption => enumOption.default); + if (defaultEnumOption) { defaults[field.id] = defaultEnumOption; } + }); + this.updateSectionData({ ccLicense: { id: ccLicense.id, - fields: {}, + fields: defaults }, uri: undefined, }); @@ -254,6 +283,25 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent this.ccLicenseLink$ = this.getCcLicenseLink$(); } + /** + * Update value for a given license field. + * @param ccLicense the related Creative Commons license. + * @param field the field for which to set a value. + */ + updateInput(ccLicense: SubmissionCcLicence, field: Field) { + this.updateSectionData({ + ccLicense: { + id: ccLicense.id, + fields: Object.assign({}, this.data.ccLicense.fields, { + [field.id]: this.data.ccLicense.fields[field.id] + }), + }, + accepted: false, + uri: this.data.uri + }); + this.ccLicenseLink$ = this.getCcLicenseLink$(); + } + /** * Get the selected option for a given license field. * @param ccLicense the related Creative Commons license. @@ -282,7 +330,7 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent getCcLicenseLink$(): Observable { if (this.storedCcLicenseLink) { - return of(this.storedCcLicenseLink); + return observableOf(this.storedCcLicenseLink); } if (!this.getSelectedCcLicense() || this.getSelectedCcLicense().fields.some( (field) => !this.getSelectedOption(this.getSelectedCcLicense(), field))) { @@ -348,12 +396,18 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent if (this.data.accepted !== data.accepted) { const path = this.pathCombiner.getPath('uri'); if (data.accepted) { - this.getCcLicenseLink$().pipe( - take(1), - ).subscribe((link) => { - this.operationsBuilder.add(path, link.toString(), false, true); - }); - } else if (this.data.uri) { + if (data.ccLicense.id === 'other') { + this.operationsBuilder.add(path, { 'uri': data.ccLicense.fields.dc_rights_uri, 'rights': data.ccLicense.fields.dc_rights }, false, true); + } else if (data.ccLicense.id === 'none') { + this.operationsBuilder.add(path, { 'uri': '', 'rights': this.translate.instant('submission.sections.ccLicense.copyrighted') }, false, true); + } else { + this.getCcLicenseLink$().pipe( + take(1), + ).subscribe((link) => { + this.operationsBuilder.add(path, link.toString(), false, true); + }); + } + } else if (!!this.data.uri) { this.operationsBuilder.remove(path); } } diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 6551143ff13..34f1ffe26a1 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -5812,19 +5812,33 @@ "submission.sections.describe.relationship-lookup.name-variant.notification.decline": "Use only for this submission", - "submission.sections.ccLicense.type": "License Type", + "submission.sections.ccLicense.attribution": "The language in this tool is adapted from Creative Commons", + + "submission.sections.ccLicense.change": "License selector…", - "submission.sections.ccLicense.select": "Select a license type…", + "submission.sections.ccLicense.confirmation": "I grant the license above", - "submission.sections.ccLicense.change": "Change your license type…", + "submission.sections.ccLicense.copyrighted": "This work is protected by copyright unless stated otherwise.", - "submission.sections.ccLicense.none": "No licenses available", + "submission.sections.ccLicense.cczero": "I have read and understand the terms and intended legal effect of CC0 (Public domain). I hereby waive all copyright and related or neighboring rights together with all associated claims and causes of action with respect to this work to the extent possible under the law.", - "submission.sections.ccLicense.option.select": "Select an option…", + "submission.sections.ccLicense.info": "Select license terms to limit how others may reuse your work. We recommend a CC BY-NC Creative Commons (CC) license. Learn more at About CC Licenses or use the “Help me choose” option in the License Selector. Tip: If you save and then re-visit this submission form, your previous entries in this section will not be displayed. However, they will remain saved unless you make a new selection in this section.", "submission.sections.ccLicense.link": "You’ve selected the following license:", - "submission.sections.ccLicense.confirmation": "I grant the license above", + "submission.sections.ccLicense.link2": "All Creative Commons licenses require attribution, meaning that credit must be given to you, the creator.", + + "submission.sections.ccLicense.none": "No licenses available", + + "submission.sections.ccLicense.option.select": "Select…", + + "submission.sections.ccLicense.publicdomain": "You have chosen to put your work into the public domain using the CC0 Public Domain Dedication deed.", + + "submission.sections.ccLicense.select": "License selector…", + + "submission.sections.ccLicense.selected": "You have selected", + + "submission.sections.ccLicense.type": "License Type", "submission.sections.general.add-more": "Add more", @@ -5874,7 +5888,7 @@ "submission.sections.submit.progressbar.accessCondition": "Item access conditions", - "submission.sections.submit.progressbar.CClicense": "Creative commons license", + "submission.sections.submit.progressbar.CClicense": "Rights", "submission.sections.submit.progressbar.CustomUrlStep": "Custom Url", @@ -5888,6 +5902,10 @@ "submission.sections.submit.progressbar.duplicates": "Potential duplicates", + "submission.sections.submit.progressbar.describe.rights": "Rights Statement", + + "submission.sections.submit.progressbar.detect-duplicate": "Potential duplicates", + "submission.sections.submit.progressbar.identifiers": "Identifiers", "submission.sections.submit.progressbar.license": "Deposit license",