mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
CST-11045 added sections parts
This commit is contained in:
@@ -1,17 +1,21 @@
|
|||||||
import {NotifyServiceObject} from './notify-service-submission.model'
|
import {NotifyServiceObject} from './notify-service-submission.model'
|
||||||
|
import { LdnService } from '../../../admin/admin-ldn-services/ldn-services-model/ldn-services.model';
|
||||||
/**
|
/**
|
||||||
* An interface to represent the submission's item accesses condition.
|
* An interface to represent the submission's item ldn-services condition.
|
||||||
*/
|
*/
|
||||||
export interface WorkspaceitemSectionNotifyServiceRequestItemDissemination extends NotifyServiceObject {
|
export interface WorkspaceitemSectionNotifyServiceRequestItemDissemination extends NotifyServiceObject {
|
||||||
/**
|
/**
|
||||||
* The access condition id
|
* The ldn-review service
|
||||||
*/
|
*/
|
||||||
id: string;
|
reviewService: LdnService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boolean that indicates whether the current item must be findable via search or browse.
|
* The ldn-endorse service
|
||||||
*/
|
*/
|
||||||
discoverable: boolean;
|
endorseService: LdnService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ldn-ingest service
|
||||||
|
*/
|
||||||
|
ingestService: LdnService;
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { LdnServiceComponent } from './ldn-service.component';
|
||||||
|
|
||||||
|
describe('LdnServiceComponent', () => {
|
||||||
|
let component: LdnServiceComponent;
|
||||||
|
let fixture: ComponentFixture<LdnServiceComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ LdnServiceComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(LdnServiceComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
129
src/app/submission/sections/ldn-service/ldn-service.component.ts
Normal file
129
src/app/submission/sections/ldn-service/ldn-service.component.ts
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
import { ChangeDetectorRef, Component, Inject, ViewChild } from '@angular/core';
|
||||||
|
import { DynamicFormControlEvent } from '@ng-dynamic-forms/core';
|
||||||
|
import { Observable, Subscription } from 'rxjs';
|
||||||
|
import { SectionModelComponent } from '../models/section.model';
|
||||||
|
import { renderSectionFor } from '../sections-decorator';
|
||||||
|
import { SectionsType } from '../sections-type';
|
||||||
|
import { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder/json-patch-operation-path-combiner';
|
||||||
|
import { FormComponent } from '../../../shared/form/form.component';
|
||||||
|
import { CollectionDataService } from '../../../core/data/collection-data.service';
|
||||||
|
import { FormBuilderService } from '../../../shared/form/builder/form-builder.service';
|
||||||
|
import { SectionFormOperationsService } from '../form/section-form-operations.service';
|
||||||
|
import { FormService } from '../../../shared/form/form.service';
|
||||||
|
import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder';
|
||||||
|
import { SectionsService } from '../sections.service';
|
||||||
|
import { SubmissionService } from '../../submission.service';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { SectionDataObject } from '../models/section-data.model';
|
||||||
|
import {
|
||||||
|
WorkspaceitemSectionNotifyServiceRequestItemDissemination
|
||||||
|
} from '../../../core/submission/models/workspaceitem-section-form-notify-service.model';
|
||||||
|
import { hasValue } from '../../../shared/empty.util';
|
||||||
|
/**
|
||||||
|
* This component represents a section that contains the submission ldn-service form.
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-ldn-service',
|
||||||
|
templateUrl: './ldn-service.component.html',
|
||||||
|
styleUrls: ['./ldn-service.component.scss']
|
||||||
|
})
|
||||||
|
@renderSectionFor(SectionsType.LdnService)
|
||||||
|
export class LdnServiceComponent extends SectionModelComponent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The [[JsonPatchOperationPathCombiner]] object
|
||||||
|
* @type {JsonPatchOperationPathCombiner}
|
||||||
|
*/
|
||||||
|
protected pathCombiner: JsonPatchOperationPathCombiner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array to track all subscriptions and unsubscribe them onDestroy
|
||||||
|
* @type {Array}
|
||||||
|
*/
|
||||||
|
protected subs: Subscription[] = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A boolean representing if div should start collapsed
|
||||||
|
*/
|
||||||
|
public isCollapsed = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The FormComponent reference
|
||||||
|
*/
|
||||||
|
@ViewChild('formRef') private formRef: FormComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize instance variables
|
||||||
|
*
|
||||||
|
* @param {ChangeDetectorRef} changeDetectorRef
|
||||||
|
* @param {CollectionDataService} collectionDataService
|
||||||
|
* @param {FormBuilderService} formBuilderService
|
||||||
|
* @param {SectionFormOperationsService} formOperationsService
|
||||||
|
* @param {FormService} formService
|
||||||
|
* @param {JsonPatchOperationsBuilder} operationsBuilder
|
||||||
|
* @param {SectionsService} sectionService
|
||||||
|
* @param {SubmissionService} submissionService
|
||||||
|
* @param {TranslateService} translateService
|
||||||
|
* @param {string} injectedCollectionId
|
||||||
|
* @param {SectionDataObject} injectedSectionData
|
||||||
|
* @param {string} injectedSubmissionId
|
||||||
|
*/
|
||||||
|
constructor(protected changeDetectorRef: ChangeDetectorRef,
|
||||||
|
protected collectionDataService: CollectionDataService,
|
||||||
|
protected formBuilderService: FormBuilderService,
|
||||||
|
protected formOperationsService: SectionFormOperationsService,
|
||||||
|
protected formService: FormService,
|
||||||
|
protected operationsBuilder: JsonPatchOperationsBuilder,
|
||||||
|
protected sectionService: SectionsService,
|
||||||
|
protected submissionService: SubmissionService,
|
||||||
|
protected translateService: TranslateService,
|
||||||
|
@Inject('collectionIdProvider') public injectedCollectionId: string,
|
||||||
|
@Inject('sectionDataProvider') public injectedSectionData: SectionDataObject,
|
||||||
|
@Inject('submissionIdProvider') public injectedSubmissionId: string) {
|
||||||
|
super(injectedCollectionId, injectedSectionData, injectedSubmissionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize all instance variables
|
||||||
|
*/
|
||||||
|
onSectionInit() {
|
||||||
|
this.pathCombiner = new JsonPatchOperationPathCombiner('sections', this.sectionData.id);
|
||||||
|
this.subs.push(
|
||||||
|
this.sectionService.getSectionData(this.submissionId, this.sectionData.id, this.sectionData.sectionType)
|
||||||
|
.subscribe((ldnServicesSection: WorkspaceitemSectionNotifyServiceRequestItemDissemination) => {
|
||||||
|
console.log(ldnServicesSection);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method called when a form dfChange event is fired.
|
||||||
|
* Dispatch form operations based on changes.
|
||||||
|
*/
|
||||||
|
onChange(event: DynamicFormControlEvent) {
|
||||||
|
const path = this.formOperationsService.getFieldPathSegmentedFromChangeEvent(event);
|
||||||
|
const value = this.formOperationsService.getFieldValueFromChangeEvent(event);
|
||||||
|
if (value) {
|
||||||
|
this.operationsBuilder.add(this.pathCombiner.getPath(path), value.value.toString(), false, true);
|
||||||
|
this.sectionService.dispatchRemoveSectionErrors(this.submissionId, this.sectionData.id);
|
||||||
|
} else {
|
||||||
|
this.operationsBuilder.remove(this.pathCombiner.getPath(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unsubscribe from all subscriptions
|
||||||
|
*/
|
||||||
|
onSectionDestroy() {
|
||||||
|
this.subs
|
||||||
|
.filter((subscription) => hasValue(subscription))
|
||||||
|
.forEach((subscription) => subscription.unsubscribe());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getSectionStatus(): Observable<boolean> {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
27
src/app/submission/sections/ldn-service/ldn-service.model.ts
Normal file
27
src/app/submission/sections/ldn-service/ldn-service.model.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
export const SECTION_LDN_SERVICE_FORM_LAYOUT = {
|
||||||
|
|
||||||
|
granted: {
|
||||||
|
element: {
|
||||||
|
container: 'custom-control custom-checkbox pl-1',
|
||||||
|
control: 'custom-control-input',
|
||||||
|
label: 'custom-control-label pt-1'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const SECTION_LDN_SERVICE_FORM_MODEL = [
|
||||||
|
{
|
||||||
|
id: 'granted',
|
||||||
|
label: 'submission.sections.license.granted-label',
|
||||||
|
required: true,
|
||||||
|
value: false,
|
||||||
|
validators: {
|
||||||
|
required: null
|
||||||
|
},
|
||||||
|
errorMessages: {
|
||||||
|
required: 'submission.sections.license.required',
|
||||||
|
notgranted: 'submission.sections.license.notgranted'
|
||||||
|
},
|
||||||
|
type: 'CHECKBOX',
|
||||||
|
}
|
||||||
|
];
|
@@ -9,4 +9,5 @@ export enum SectionsType {
|
|||||||
SherpaPolicies = 'sherpaPolicy',
|
SherpaPolicies = 'sherpaPolicy',
|
||||||
Identifiers = 'identifiers',
|
Identifiers = 'identifiers',
|
||||||
Collection = 'collection',
|
Collection = 'collection',
|
||||||
|
LdnService = 'ldn-service'
|
||||||
}
|
}
|
||||||
|
@@ -67,6 +67,7 @@ import {
|
|||||||
} from './sections/sherpa-policies/metadata-information/metadata-information.component';
|
} from './sections/sherpa-policies/metadata-information/metadata-information.component';
|
||||||
import { SectionFormOperationsService } from './sections/form/section-form-operations.service';
|
import { SectionFormOperationsService } from './sections/form/section-form-operations.service';
|
||||||
import {SubmissionSectionIdentifiersComponent} from './sections/identifiers/section-identifiers.component';
|
import {SubmissionSectionIdentifiersComponent} from './sections/identifiers/section-identifiers.component';
|
||||||
|
import { LdnServiceComponent } from './sections/ldn-service/ldn-service.component';
|
||||||
|
|
||||||
const ENTRY_COMPONENTS = [
|
const ENTRY_COMPONENTS = [
|
||||||
// put only entry components that use custom decorator
|
// put only entry components that use custom decorator
|
||||||
@@ -76,6 +77,7 @@ const ENTRY_COMPONENTS = [
|
|||||||
SubmissionSectionCcLicensesComponent,
|
SubmissionSectionCcLicensesComponent,
|
||||||
SubmissionSectionAccessesComponent,
|
SubmissionSectionAccessesComponent,
|
||||||
SubmissionSectionSherpaPoliciesComponent,
|
SubmissionSectionSherpaPoliciesComponent,
|
||||||
|
LdnServiceComponent
|
||||||
];
|
];
|
||||||
|
|
||||||
const DECLARATIONS = [
|
const DECLARATIONS = [
|
||||||
@@ -114,6 +116,7 @@ const DECLARATIONS = [
|
|||||||
CoreModule.forRoot(),
|
CoreModule.forRoot(),
|
||||||
SharedModule,
|
SharedModule,
|
||||||
StoreModule.forFeature('submission', submissionReducers, storeModuleConfig as StoreConfig<SubmissionState, Action>),
|
StoreModule.forFeature('submission', submissionReducers, storeModuleConfig as StoreConfig<SubmissionState, Action>),
|
||||||
|
EffectsModule.forFeature(),
|
||||||
EffectsModule.forFeature(submissionEffects),
|
EffectsModule.forFeature(submissionEffects),
|
||||||
JournalEntitiesModule.withEntryComponents(),
|
JournalEntitiesModule.withEntryComponents(),
|
||||||
ResearchEntitiesModule.withEntryComponents(),
|
ResearchEntitiesModule.withEntryComponents(),
|
||||||
|
Reference in New Issue
Block a user