mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
CC License Submission Step - implement contract change
This commit is contained in:
@@ -10,15 +10,8 @@ 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 { Field, Option, SubmissionCcLicence } from './models/submission-cc-license.model';
|
||||
import { SubmissionCcLicence } from './models/submission-cc-license.model';
|
||||
import { DefaultChangeAnalyzer } from '../data/default-change-analyzer.service';
|
||||
import {
|
||||
getRemoteDataPayload,
|
||||
getSucceededRemoteData,
|
||||
} from '../shared/operators';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
import { SubmissionCcLicenseUrlDataService } from './submission-cc-license-url-data.service';
|
||||
|
||||
@Injectable()
|
||||
@dataService(SUBMISSION_CC_LICENSE)
|
||||
@@ -35,39 +28,7 @@ export class SubmissionCcLicenseDataService extends DataService<SubmissionCcLice
|
||||
protected rdbService: RemoteDataBuildService,
|
||||
protected requestService: RequestService,
|
||||
protected store: Store<CoreState>,
|
||||
protected submissionCcLicenseUrlDataService: SubmissionCcLicenseUrlDataService,
|
||||
) {
|
||||
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.submissionCcLicenseUrlDataService.findByHref(href)),
|
||||
getSucceededRemoteData(),
|
||||
getRemoteDataPayload(),
|
||||
map((response) => response.url),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -12,12 +12,17 @@ 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 = 'submissioncclicenses';
|
||||
protected linkPath = 'submissioncclicenseUrl-search';
|
||||
|
||||
constructor(
|
||||
protected comparator: DefaultChangeAnalyzer<SubmissionCcLicenceUrl>,
|
||||
@@ -31,4 +36,41 @@ export class SubmissionCcLicenseUrlDataService extends DataService<SubmissionCcL
|
||||
) {
|
||||
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}`));
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ import { WorkspaceitemSectionCcLicenseObject } from '../../../core/submission/mo
|
||||
import { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder/json-patch-operation-path-combiner';
|
||||
import { isNotEmpty } from '../../../shared/empty.util';
|
||||
import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder';
|
||||
import { SubmissionCcLicenseUrlDataService } from "../../../core/submission/submission-cc-license-url-data.service";
|
||||
|
||||
/**
|
||||
* This component represents the submission section to select the Creative Commons license.
|
||||
@@ -80,6 +81,7 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent
|
||||
protected modalService: NgbModal,
|
||||
protected sectionService: SectionsService,
|
||||
protected submissionCcLicensesDataService: SubmissionCcLicenseDataService,
|
||||
protected submissionCcLicenseUrlDataService: SubmissionCcLicenseUrlDataService,
|
||||
protected operationsBuilder: JsonPatchOperationsBuilder,
|
||||
@Inject('collectionIdProvider') public injectedCollectionId: string,
|
||||
@Inject('sectionDataProvider') public injectedSectionData: SectionDataObject,
|
||||
@@ -180,7 +182,7 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent
|
||||
return undefined;
|
||||
}
|
||||
const selectedCcLicense = this.getSelectedCcLicense();
|
||||
return this.submissionCcLicensesDataService.getCcLicenseLink(
|
||||
return this.submissionCcLicenseUrlDataService.getCcLicenseLink(
|
||||
selectedCcLicense,
|
||||
new Map(selectedCcLicense.fields.map(
|
||||
(field) => [field, this.getSelectedOption(selectedCcLicense, field)]
|
||||
|
Reference in New Issue
Block a user