Skip to content

Commit 7e89236

Browse files
DSpace Application ProductionBrian Keese
authored andcommitted
Creative Commons Licenses (10x)
1 parent 444edd4 commit 7e89236

5 files changed

Lines changed: 225 additions & 149 deletions

File tree

src/app/core/submission/models/submission-cc-license.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ export interface Option {
4343
id: string;
4444
label: string;
4545
description: string;
46+
default: boolean;
4647
}
Lines changed: 118 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,142 @@
11
@if (submissionCcLicenses) {
2-
<div class="mb-4 ccLicense-select">
3-
<div ngbDropdown>
4-
<input id="cc-license-dropdown"
5-
class="form-control"
6-
[(ngModel)]="selectedCcLicense.name"
7-
placeholder="{{ !storedCcLicenseLink ? ('submission.sections.ccLicense.select' | translate) : ('submission.sections.ccLicense.change' | translate)}}"
8-
[ngModelOptions]="{standalone: true}"
9-
ngbDropdownToggle
10-
role="combobox"
11-
#script="ngModel">
12-
<div ngbDropdownMenu aria-labelledby="cc-license-dropdown" class="w-100 scrollable-menu"
13-
role="menu"
14-
infiniteScroll
15-
(scroll)="onScroll($event)"
16-
[infiniteScrollDistance]="5"
17-
[infiniteScrollThrottle]="300"
18-
[infiniteScrollUpDistance]="1.5"
19-
[fromRoot]="true"
20-
[scrollWindow]="false">
21-
22-
@if(submissionCcLicenses?.length === 0) {
23-
<button class="dropdown-item disabled">
24-
{{ 'submission.sections.ccLicense.none' | translate }}
25-
</button>
26-
} @else {
27-
@for(license of submissionCcLicenses; track license.id) {
28-
<button class="dropdown-item" (click)="selectCcLicense(license)">
29-
{{ license.name }}
30-
</button>
31-
}
32-
}
33-
</div>
34-
</div>
35-
</div>
2+
<div class="mb-4 ccLicense-select">
3+
<p [dsMarkdown]="'submission.sections.ccLicense.info' | translate "></p>
4+
<ds-select [disabled]="!submissionCcLicenses">
5+
<ng-container class="selection">
6+
<span *ngIf="getSelectedCcLicense()">
7+
{{ getSelectedCcLicense().name }}
8+
</span>
9+
<span *ngIf="submissionCcLicenses && !getSelectedCcLicense()">
10+
<ng-container *ngIf="storedCcLicenseLink">
11+
{{ 'submission.sections.ccLicense.change' | translate }}
12+
</ng-container>
13+
<ng-container *ngIf="!storedCcLicenseLink">
14+
{{ 'submission.sections.ccLicense.select' | translate }}
15+
</ng-container>
16+
</span>
17+
</ng-container>
18+
<ng-container class="menu">
19+
<button *ngIf="submissionCcLicenses?.length == 0"
20+
class="dropdown-item disabled">
21+
{{ 'submission.sections.ccLicense.none' | translate }}
22+
</button>
23+
<button *ngFor="let license of submissionCcLicenses"
24+
class="dropdown-item"
25+
(click)="selectCcLicense(license)">
26+
{{ license.name }}
27+
</button>
28+
</ng-container>
29+
</ds-select>
30+
</div>
3631
}
3732

38-
@if (getSelectedCcLicense()) {
39-
@for (field of getSelectedCcLicense().fields; track field) {
40-
<div
41-
class="mb-4">
33+
<ng-container *ngIf="getSelectedCcLicense()">
34+
<div class="form-control" style="height: auto">
35+
<div *ngFor="let field of getSelectedCcLicense().fields" class="m-0">
36+
4237
<div class="d-flex flex-row">
43-
<div class="fw-bold {{ field.id }}">
44-
{{ field.label }}
38+
<div class="font-weight-bold {{ field.id }}">{{ field.label }}
39+
<button class="btn btn-outline-info btn-sm ml-2 mb-1" (click)="openInfoModal(infoModal)">
40+
<i class="fas fa-question"></i>
41+
</button>
4542
</div>
46-
<button
47-
class="btn btn-outline-info btn-sm ms-2"
48-
(click)="openInfoModal(infoModal)">
49-
<i class="fas fa-question"></i>
50-
</button>
5143
</div>
44+
5245
<ng-template #infoModal>
5346
<div>
5447
<div class="modal-header mb-4 ">
5548
<div>
56-
<h4>
57-
{{ field.label }}
58-
</h4>
49+
<h4>{{ field.label }}</h4>
5950
<div [innerHTML]="field.description"></div>
6051
</div>
61-
<button type="button" class="btn-close"
62-
(click)="closeInfoModal()" aria-label="Close">
52+
<button type="button" class="close mb-1" (click)="closeInfoModal()" aria-label="Close">
53+
<span aria-hidden="true">×</span>
6354
</button>
6455
</div>
6556
<div class="modal-body">
66-
@for (value of field.enums; track value) {
67-
<div
68-
class="mb-4">
69-
<h5>
70-
{{ value.label }}
71-
</h5>
72-
<div [innerHTML]="value.description" class="fw-light"></div>
73-
</div>
74-
}
57+
<div *ngFor="let value of field.enums" class="mb-4">
58+
<h5>{{ value.label }}</h5>
59+
<div [innerHTML]="value.description" class="font-weight-light"></div>
60+
</div>
7561
</div>
7662
</div>
7763
</ng-template>
78-
@if (field.enums?.length > 5) {
79-
<ds-select [disabled]="field.id === 'jurisdiction' && defaultJurisdiction !== undefined && defaultJurisdiction !== 'none'">
80-
<ng-container class="selection" *ngVar="getSelectedOption(getSelectedCcLicense(), field) as option">
81-
@if (option) {
82-
<span>
83-
{{ option.label }}
64+
65+
<ds-select *ngIf="field.enums && field.enums?.length > 5" [disabled]="field.id === 'jurisdiction' && defaultJurisdiction !== undefined && defaultJurisdiction !== 'none'">
66+
<ng-container class="selection" *ngVar="getSelectedOption(getSelectedCcLicense(), field) as option">
67+
<span *ngIf="option">{{ option.label }}</span>
68+
<span *ngIf="!option">{{ 'submission.sections.ccLicense.option.select' | translate }}</span>
69+
</ng-container>
70+
<ng-container class="menu">
71+
<div class="options-select-menu overflow-auto">
72+
<button *ngFor="let option of field.enums" class="dropdown-item" (click)="selectOption(getSelectedCcLicense(), field, option)">
73+
{{ option.label }}
74+
</button>
75+
</div>
76+
</ng-container>
77+
</ds-select>
78+
79+
<ng-container *ngIf="field.enums && field.enums?.length <= 5">
80+
<div *ngFor="let option of field.enums" class="d-flex flex-row ml-3">
81+
<div (click)="selectOption(getSelectedCcLicense(), field, option)">
82+
<input type="radio" title="{{ option.label }}" class="mr-1" [checked]="isSelectedOption(getSelectedCcLicense(), field, option)">
83+
<span>{{ option.label }}</span>
84+
</div>
85+
</div>
86+
</ng-container>
87+
88+
<ng-container *ngIf="field.type && field.type === 'textarea'">
89+
<div role="group" class="form-row" style="width: 100%;">
90+
<div class="col-sm-12 d-flex flex-column justify-content-start">
91+
<textarea [(ngModel)]="data.ccLicense.fields['dc_rights']" (blur)="updateInput(getSelectedCcLicense(), field)" class="form-control" cols="20"
92+
id="{{ field.id }}" name="{{ field.id }}" rows="2" spellcheck="true" wrap="undefined"></textarea>
93+
<small class="text-muted ds-hint">{{ field.description }}</small>
94+
</div>
95+
</div>
96+
</ng-container>
97+
98+
<ng-container *ngIf="field.type && field.type === 'input'">
99+
<div role="group" class="form-row" style="width: 100%;">
100+
<div class="col-sm-12 d-flex flex-column justify-content-start">
101+
<input [(ngModel)]="data.ccLicense.fields['dc_rights_uri']" (blur)="updateInput(getSelectedCcLicense(), field)" class="form-control" id="{{ field.id }}"
102+
name="{{ field.id }}" spellcheck="false" type="text">
103+
<small class="text-muted ds-hint ng-star-inserted">{{ field.description }}</small>
104+
</div>
105+
</div>
106+
</ng-container>
107+
</div>
108+
109+
<ng-container *ngVar="getCcLicenseLink$() | async as licenseLink">
110+
<div class="mt-2 p-2 text-dark alert-info">
111+
<div *ngIf="licenseLink && licenseLink!='All Rights Reserved' && licenseLink!='http://creativecommons.org/publicdomain/zero/1.0/'">
112+
{{ 'submission.sections.ccLicense.selected' | translate }}
113+
<a class="license-link" href="{{ licenseLink }}" target="_blank" rel="noopener noreferrer">{{ licenseMap[licenseLink] }}</a>.
114+
<p>{{ 'submission.sections.ccLicense.link2' | translate }}</p>
115+
</div>
116+
<div *ngIf="licenseLink && licenseLink=='http://creativecommons.org/publicdomain/zero/1.0/'">
117+
<p [dsMarkdown]="'submission.sections.ccLicense.publicdomain' | translate"></p>
118+
</div>
119+
<div class="m-2">
120+
<div (click)="setAccepted(!accepted)">
121+
<input type="checkbox" class="mr-2" title="accepted">
122+
<span *ngIf="licenseLink=='All Rights Reserved'; else other_content">
123+
{{ 'submission.sections.ccLicense.copyrighted' | translate }}
124+
</span>
125+
<ng-template #other_content>
126+
<span *ngIf="licenseLink!='http://creativecommons.org/publicdomain/zero/1.0/'; else zero_content">
127+
{{ 'submission.sections.ccLicense.confirmation' | translate }}
84128
</span>
85-
}
86-
@if (!option) {
129+
</ng-template>
130+
<ng-template #zero_content>
87131
<span>
88-
{{ 'submission.sections.ccLicense.option.select' | translate }}
132+
{{ 'submission.sections.ccLicense.cczero' | translate }}
89133
</span>
90-
}
91-
</ng-container>
92-
<ng-container class="menu">
93-
<div class="options-select-menu overflow-auto">
94-
@for (option of field.enums; track option) {
95-
<button
96-
class="dropdown-item"
97-
(click)="selectOption(getSelectedCcLicense(), field, option)">
98-
{{ option.label }}
99-
</button>
100-
}
101-
</div>
102-
</ng-container>
103-
</ds-select>
104-
}
105-
@if (field.enums?.length <= 5) {
106-
@for (option of field.enums; track option) {
107-
<div
108-
class="d-flex flex-row m-1">
109-
<div (click)="selectOption(getSelectedCcLicense(), field, option)">
110-
<input type="radio"
111-
title="{{ option.label }}"
112-
class="me-1"
113-
[checked]="isSelectedOption(getSelectedCcLicense(), field, option)">
114-
<span>{{ option.label }}</span>
115-
</div>
134+
</ng-template>
116135
</div>
117-
}
118-
}
119-
</div>
120-
}
121-
}
122-
123-
@if (ccLicenseLink$) {
124-
@let licenseLink = (ccLicenseLink$ | async);
125-
@if (licenseLink) {
126-
<div
127-
class="mt-2 p-4 bg-light text-dark">
128-
<div>
129-
{{ 'submission.sections.ccLicense.link' | translate }}
130-
</div>
131-
<a class="license-link" href="{{ licenseLink }}" target="_blank" rel="noopener noreferrer">
132-
{{ licenseLink }}
133-
</a>
134-
<div class="m-2">
135-
<div (click)="setAccepted(!accepted)">
136-
<input type="checkbox"
137-
class="me-2"
138-
title="accepted"
139-
[checked]="accepted">
140-
<span> {{ 'submission.sections.ccLicense.confirmation' | translate }}</span>
141136
</div>
142137
</div>
143-
</div>
144-
} @else {
145-
<ds-loading></ds-loading>
146-
}
147-
}
138+
</ng-container>
139+
</div>
140+
</ng-container>
141+
142+
<p class="small mb-0 mt-3">{{ 'submission.sections.ccLicense.attribution' | translate }}, <a href="http://creativecommons.org" target="_blank">creativecommons.org</a></p>

src/app/submission/sections/cc-license/submission-section-cc-licenses.component.spec.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ describe('SubmissionSectionCcLicensesComponent', () => {
5656
{
5757
id: 'test enum id 1a I',
5858
label: 'test enum label 1a I',
59+
default: true,
5960
description: 'test enum description 1a I',
6061
},
6162
{
6263
id: 'test enum id 1a II',
6364
label: 'test enum label 1a II',
65+
default: false,
6466
description: 'test enum description 1a II',
6567
},
6668
],
@@ -73,11 +75,13 @@ describe('SubmissionSectionCcLicensesComponent', () => {
7375
{
7476
id: 'test enum id 1b I',
7577
label: 'test enum label 1b I',
78+
default: true,
7679
description: 'test enum description 1b I',
7780
},
7881
{
7982
id: 'test enum id 1b II',
8083
label: 'test enum label 1b II',
84+
default: false,
8185
description: 'test enum description 1b II',
8286
},
8387
],
@@ -102,12 +106,14 @@ describe('SubmissionSectionCcLicensesComponent', () => {
102106
{
103107
id: 'test enum id 2a I',
104108
label: 'test enum label 2a I',
105-
description: 'test enum description 2a I',
109+
default: true,
110+
description: 'test enum description 2a I'
106111
},
107112
{
108113
id: 'test enum id 2a II',
109114
label: 'test enum label 2a II',
110-
description: 'test enum description 2a II',
115+
default: false,
116+
description: 'test enum description 2a II'
111117
},
112118
],
113119
},
@@ -119,12 +125,14 @@ describe('SubmissionSectionCcLicensesComponent', () => {
119125
{
120126
id: 'test enum id 2b I',
121127
label: 'test enum label 2b I',
122-
description: 'test enum description 2b I',
128+
default: true,
129+
description: 'test enum description 2b I'
123130
},
124131
{
125132
id: 'test enum id 2b II',
126133
label: 'test enum label 2b II',
127-
description: 'test enum description 2b II',
134+
default: false,
135+
description: 'test enum description 2b II'
128136
},
129137
],
130138
},

0 commit comments

Comments
 (0)