-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,044 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/app/core/submission/models/submission-cc-licence-link.resource-type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ResourceType } from '../../shared/resource-type'; | ||
|
||
/** | ||
* The resource type for License | ||
* | ||
* Needs to be in a separate file to prevent circular | ||
* dependencies in webpack. | ||
*/ | ||
export const SUBMISSION_CC_LICENSE_URL = new ResourceType('submissioncclicenseUrl'); |
9 changes: 9 additions & 0 deletions
9
src/app/core/submission/models/submission-cc-licence.resource-type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ResourceType } from '../../shared/resource-type'; | ||
|
||
/** | ||
* The resource type for License | ||
* | ||
* Needs to be in a separate file to prevent circular | ||
* dependencies in webpack. | ||
*/ | ||
export const SUBMISSION_CC_LICENSE = new ResourceType('submissioncclicense'); |
23 changes: 23 additions & 0 deletions
23
src/app/core/submission/models/submission-cc-license-url.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { autoserialize, inheritSerialization } from 'cerialize'; | ||
import { typedObject } from '../../cache/builders/build-decorators'; | ||
import { excludeFromEquals } from '../../utilities/equals.decorators'; | ||
import { ResourceType } from '../../shared/resource-type'; | ||
import { HALResource } from '../../shared/hal-resource.model'; | ||
import { SUBMISSION_CC_LICENSE_URL } from './submission-cc-licence-link.resource-type'; | ||
|
||
@typedObject | ||
@inheritSerialization(HALResource) | ||
export class SubmissionCcLicenceUrl extends HALResource { | ||
|
||
static type = SUBMISSION_CC_LICENSE_URL; | ||
|
||
/** | ||
* The object type | ||
*/ | ||
@excludeFromEquals | ||
@autoserialize | ||
type: ResourceType; | ||
|
||
@autoserialize | ||
url: string; | ||
} |
42 changes: 42 additions & 0 deletions
42
src/app/core/submission/models/submission-cc-license.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { autoserialize, inheritSerialization } from 'cerialize'; | ||
import { typedObject } from '../../cache/builders/build-decorators'; | ||
import { excludeFromEquals } from '../../utilities/equals.decorators'; | ||
import { ResourceType } from '../../shared/resource-type'; | ||
import { HALResource } from '../../shared/hal-resource.model'; | ||
import { SUBMISSION_CC_LICENSE } from './submission-cc-licence.resource-type'; | ||
|
||
@typedObject | ||
@inheritSerialization(HALResource) | ||
export class SubmissionCcLicence extends HALResource { | ||
|
||
static type = SUBMISSION_CC_LICENSE; | ||
|
||
/** | ||
* The object type | ||
*/ | ||
@excludeFromEquals | ||
@autoserialize | ||
type: ResourceType; | ||
|
||
@autoserialize | ||
id: string; | ||
|
||
@autoserialize | ||
name: string; | ||
|
||
@autoserialize | ||
fields: Field[]; | ||
} | ||
|
||
export interface Field { | ||
id: string; | ||
label: string; | ||
description: string; | ||
enums: Option[]; | ||
} | ||
|
||
export interface Option { | ||
id: string; | ||
label: string; | ||
description: string; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/app/core/submission/models/workspaceitem-section-cc-license.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Option } from './submission-cc-license.model'; | ||
|
||
/** | ||
* An interface to represent the submission's creative commons license section data. | ||
*/ | ||
export interface WorkspaceitemSectionCcLicenseObject { | ||
ccLicense?: { | ||
id: string; | ||
fields: { | ||
[fieldId: string]: Option; | ||
} | ||
}; | ||
uri?: string; | ||
accepted?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/app/core/submission/submission-cc-license-data.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Injectable } from '@angular/core'; | ||
import { Store } from '@ngrx/store'; | ||
import { NotificationsService } from '../../shared/notifications/notifications.service'; | ||
import { dataService } from '../cache/builders/build-decorators'; | ||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; | ||
import { ObjectCacheService } from '../cache/object-cache.service'; | ||
import { CoreState } from '../core.reducers'; | ||
import { HALEndpointService } from '../shared/hal-endpoint.service'; | ||
import { DataService } from '../data/data.service'; | ||
import { RequestService } from '../data/request.service'; | ||
import { SUBMISSION_CC_LICENSE } from './models/submission-cc-licence.resource-type'; | ||
import { SubmissionCcLicence } from './models/submission-cc-license.model'; | ||
import { DefaultChangeAnalyzer } from '../data/default-change-analyzer.service'; | ||
|
||
@Injectable() | ||
@dataService(SUBMISSION_CC_LICENSE) | ||
export class SubmissionCcLicenseDataService extends DataService<SubmissionCcLicence> { | ||
|
||
protected linkPath = 'submissioncclicenses'; | ||
|
||
constructor( | ||
protected comparator: DefaultChangeAnalyzer<SubmissionCcLicence>, | ||
protected halService: HALEndpointService, | ||
protected http: HttpClient, | ||
protected notificationsService: NotificationsService, | ||
protected objectCache: ObjectCacheService, | ||
protected rdbService: RemoteDataBuildService, | ||
protected requestService: RequestService, | ||
protected store: Store<CoreState>, | ||
) { | ||
super(); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
src/app/core/submission/submission-cc-license-url-data.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Injectable } from '@angular/core'; | ||
import { Store } from '@ngrx/store'; | ||
import { NotificationsService } from '../../shared/notifications/notifications.service'; | ||
import { dataService } from '../cache/builders/build-decorators'; | ||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; | ||
import { ObjectCacheService } from '../cache/object-cache.service'; | ||
import { CoreState } from '../core.reducers'; | ||
import { HALEndpointService } from '../shared/hal-endpoint.service'; | ||
import { DataService } from '../data/data.service'; | ||
import { RequestService } from '../data/request.service'; | ||
import { DefaultChangeAnalyzer } from '../data/default-change-analyzer.service'; | ||
import { SubmissionCcLicenceUrl } from './models/submission-cc-license-url.model'; | ||
import { SUBMISSION_CC_LICENSE_URL } from './models/submission-cc-licence-link.resource-type'; | ||
import { Field, Option, SubmissionCcLicence } from './models/submission-cc-license.model'; | ||
import { Observable } from 'rxjs'; | ||
import { filter, map, switchMap } from 'rxjs/operators'; | ||
import { getRemoteDataPayload, getSucceededRemoteData } from '../shared/operators'; | ||
import { isNotEmpty } from '../../shared/empty.util'; | ||
|
||
@Injectable() | ||
@dataService(SUBMISSION_CC_LICENSE_URL) | ||
export class SubmissionCcLicenseUrlDataService extends DataService<SubmissionCcLicenceUrl> { | ||
|
||
protected linkPath = 'submissioncclicenseUrl-search'; | ||
|
||
constructor( | ||
protected comparator: DefaultChangeAnalyzer<SubmissionCcLicenceUrl>, | ||
protected halService: HALEndpointService, | ||
protected http: HttpClient, | ||
protected notificationsService: NotificationsService, | ||
protected objectCache: ObjectCacheService, | ||
protected rdbService: RemoteDataBuildService, | ||
protected requestService: RequestService, | ||
protected store: Store<CoreState>, | ||
) { | ||
super(); | ||
} | ||
|
||
/** | ||
* Get the link to the Creative Commons license corresponding to the given type and options. | ||
* @param ccLicense the Creative Commons license type | ||
* @param options the selected options of the license fields | ||
*/ | ||
getCcLicenseLink(ccLicense: SubmissionCcLicence, options: Map<Field, Option>): Observable<string> { | ||
|
||
return this.getSearchByHref( | ||
'rightsByQuestions',{ | ||
searchParams: [ | ||
{ | ||
fieldName: 'license', | ||
fieldValue: ccLicense.id | ||
}, | ||
...ccLicense.fields.map( | ||
(field) => { | ||
return { | ||
fieldName: `answer_${field.id}`, | ||
fieldValue: options.get(field).id, | ||
} | ||
}), | ||
] | ||
} | ||
).pipe( | ||
switchMap((href) => this.findByHref(href)), | ||
getSucceededRemoteData(), | ||
getRemoteDataPayload(), | ||
map((response) => response.url), | ||
); | ||
} | ||
|
||
protected getSearchEndpoint(searchMethod: string): Observable<string> { | ||
return this.halService.getEndpoint(`${this.linkPath}`).pipe( | ||
filter((href: string) => isNotEmpty(href)), | ||
map((href: string) => `${href}/${searchMethod}`)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<div> | ||
|
||
<div ngbDropdown class="btn-group" (openChange)="toggled.emit($event)"> | ||
|
||
<div class="input-group-prepend" *ngIf="label"> | ||
<span id="dsSelectMenuLabel" class="input-group-text"> | ||
{{ label | translate }} | ||
</span> | ||
</div> | ||
|
||
<button aria-describedby="dsSelectMenuLabel" | ||
id="dsSelectMenuButton" | ||
class="btn btn-outline-primary selection" | ||
(blur)="close.emit($event)" | ||
(click)="close.emit($event)" | ||
[disabled]="disabled" | ||
ngbDropdownToggle> | ||
<ng-content select=".selection"></ng-content> | ||
</button> | ||
|
||
<div ngbDropdownMenu | ||
class="dropdown-menu" | ||
id="dsSelectDropdownMenu" | ||
aria-labelledby="dsSelectMenuButton"> | ||
<div aria-labelledby="dropdownMenuButton"> | ||
<ng-content select=".menu"></ng-content> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { DsSelectComponent } from './ds-select.component'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
|
||
describe('DsSelectComponent', () => { | ||
let component: DsSelectComponent; | ||
let fixture: ComponentFixture<DsSelectComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
TranslateModule.forRoot(), | ||
], | ||
declarations: [ | ||
DsSelectComponent, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DsSelectComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
|
||
/** | ||
* Component which represent a DSpace dropdown selector. | ||
*/ | ||
@Component({ | ||
selector: 'ds-select', | ||
templateUrl: './ds-select.component.html', | ||
styleUrls: ['./ds-select.component.scss'] | ||
}) | ||
export class DsSelectComponent { | ||
|
||
/** | ||
* An optional label for the dropdown selector. | ||
*/ | ||
@Input() | ||
label: string; | ||
|
||
/** | ||
* Whether the dropdown selector is disabled. | ||
*/ | ||
@Input() | ||
disabled: boolean; | ||
|
||
/** | ||
* Emits an event when the dropdown selector is opened or closed. | ||
*/ | ||
@Output() | ||
toggled = new EventEmitter(); | ||
|
||
/** | ||
* Emits an event when the dropdown selector or closed. | ||
*/ | ||
@Output() | ||
close = new EventEmitter(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.