mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 23:13:04 +00:00
ESLint: fix dangling commas
This commit is contained in:
@@ -10,20 +10,20 @@ import { getMockFormBuilderService } from '../../../shared/mocks/form-builder-se
|
||||
import { SubmissionAccessesConfigDataService } from '../../../core/config/submission-accesses-config-data.service';
|
||||
import {
|
||||
getSubmissionAccessesConfigNotChangeDiscoverableService,
|
||||
getSubmissionAccessesConfigService
|
||||
getSubmissionAccessesConfigService,
|
||||
} from '../../../shared/mocks/section-accesses-config.service.mock';
|
||||
import { SectionAccessesService } from './section-accesses.service';
|
||||
import { SectionFormOperationsService } from '../form/section-form-operations.service';
|
||||
import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder';
|
||||
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||
import {
|
||||
SubmissionJsonPatchOperationsService
|
||||
SubmissionJsonPatchOperationsService,
|
||||
} from '../../../core/submission/submission-json-patch-operations.service';
|
||||
import { getSectionAccessesService } from '../../../shared/mocks/section-accesses.service.mock';
|
||||
import { getMockFormOperationsService } from '../../../shared/mocks/form-operations-service.mock';
|
||||
import { getMockTranslateService } from '../../../shared/mocks/translate.service.mock';
|
||||
import {
|
||||
SubmissionJsonPatchOperationsServiceStub
|
||||
SubmissionJsonPatchOperationsServiceStub,
|
||||
} from '../../../shared/testing/submission-json-patch-operations-service.stub';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
DynamicCheckboxModel,
|
||||
DynamicDatePickerModel,
|
||||
DynamicFormArrayModel,
|
||||
DynamicSelectModel
|
||||
DynamicSelectModel,
|
||||
} from '@ng-dynamic-forms/core';
|
||||
import { AppState } from '../../../app.reducer';
|
||||
import { getMockFormService } from '../../../shared/mocks/form-service.mock';
|
||||
@@ -70,12 +70,12 @@ describe('SubmissionSectionAccessesComponent', () => {
|
||||
enabled: true,
|
||||
data: {
|
||||
discoverable: true,
|
||||
accessConditions: []
|
||||
accessConditions: [],
|
||||
},
|
||||
errorsToShow: [],
|
||||
serverValidationErrors: [],
|
||||
isLoading: false,
|
||||
isValid: true
|
||||
isValid: true,
|
||||
};
|
||||
|
||||
describe('First with canChangeDiscoverable true', () => {
|
||||
@@ -84,7 +84,7 @@ describe('SubmissionSectionAccessesComponent', () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
TranslateModule.forRoot()
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [SubmissionSectionAccessesComponent, FormComponent],
|
||||
providers: [
|
||||
@@ -99,8 +99,8 @@ describe('SubmissionSectionAccessesComponent', () => {
|
||||
{ provide: SubmissionJsonPatchOperationsService, useValue: SubmissionJsonPatchOperationsServiceStub },
|
||||
{ provide: 'sectionDataProvider', useValue: sectionData },
|
||||
{ provide: 'submissionIdProvider', useValue: '1508' },
|
||||
FormBuilderService
|
||||
]
|
||||
FormBuilderService,
|
||||
],
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
@@ -175,7 +175,7 @@ describe('SubmissionSectionAccessesComponent', () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
TranslateModule.forRoot()
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [SubmissionSectionAccessesComponent, FormComponent],
|
||||
providers: [
|
||||
@@ -191,7 +191,7 @@ describe('SubmissionSectionAccessesComponent', () => {
|
||||
{ provide: SubmissionJsonPatchOperationsService, useValue: SubmissionJsonPatchOperationsServiceStub },
|
||||
{ provide: 'sectionDataProvider', useValue: sectionData },
|
||||
{ provide: 'submissionIdProvider', useValue: '1508' },
|
||||
]
|
||||
],
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
@@ -22,7 +22,7 @@ import {
|
||||
DynamicFormGroupModel,
|
||||
DynamicSelectModel,
|
||||
MATCH_ENABLED,
|
||||
OR_OPERATOR
|
||||
OR_OPERATOR,
|
||||
} from '@ng-dynamic-forms/core';
|
||||
|
||||
import { FormBuilderService } from '../../../shared/form/builder/form-builder.service';
|
||||
@@ -38,11 +38,11 @@ import {
|
||||
FORM_ACCESS_CONDITION_START_DATE_CONFIG,
|
||||
FORM_ACCESS_CONDITION_START_DATE_LAYOUT,
|
||||
FORM_ACCESS_CONDITION_TYPE_CONFIG,
|
||||
FORM_ACCESS_CONDITION_TYPE_LAYOUT
|
||||
FORM_ACCESS_CONDITION_TYPE_LAYOUT,
|
||||
} from './section-accesses.model';
|
||||
import { hasValue, isNotEmpty, isNotNull } from '../../../shared/empty.util';
|
||||
import {
|
||||
WorkspaceitemSectionAccessesObject
|
||||
WorkspaceitemSectionAccessesObject,
|
||||
} from '../../../core/submission/models/workspaceitem-section-accesses.model';
|
||||
import { SubmissionAccessesConfigDataService } from '../../../core/config/submission-accesses-config-data.service';
|
||||
import { getFirstSucceededRemoteData } from '../../../core/shared/operators';
|
||||
@@ -53,7 +53,7 @@ import { SectionFormOperationsService } from '../form/section-form-operations.se
|
||||
import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder';
|
||||
import { AccessesConditionOption } from '../../../core/config/models/config-accesses-conditions-options.model';
|
||||
import {
|
||||
SubmissionJsonPatchOperationsService
|
||||
SubmissionJsonPatchOperationsService,
|
||||
} from '../../../core/submission/submission-json-patch-operations.service';
|
||||
import { dateToISOFormat } from '../../../shared/date.util';
|
||||
import { DynamicFormControlCondition } from '@ng-dynamic-forms/core/lib/model/misc/dynamic-form-control-relation.model';
|
||||
@@ -65,7 +65,7 @@ import { DynamicDateControlValue } from '@ng-dynamic-forms/core/lib/model/dynami
|
||||
@Component({
|
||||
selector: 'ds-section-accesses',
|
||||
templateUrl: './section-accesses.component.html',
|
||||
styleUrls: ['./section-accesses.component.scss']
|
||||
styleUrls: ['./section-accesses.component.scss'],
|
||||
})
|
||||
@renderSectionFor(SectionsType.AccessesCondition)
|
||||
export class SubmissionSectionAccessesComponent extends SectionModelComponent {
|
||||
@@ -163,7 +163,7 @@ export class SubmissionSectionAccessesComponent extends SectionModelComponent {
|
||||
metadataModel.value = {
|
||||
year: date.getUTCFullYear(),
|
||||
month: date.getUTCMonth() + 1,
|
||||
day: date.getUTCDate()
|
||||
day: date.getUTCDate(),
|
||||
};
|
||||
} else {
|
||||
metadataModel.value = accessCondition[key];
|
||||
@@ -203,7 +203,7 @@ export class SubmissionSectionAccessesComponent extends SectionModelComponent {
|
||||
take(1),
|
||||
filter((isValid) => isValid),
|
||||
mergeMap(() => this.formService.getFormData(this.formId)),
|
||||
take(1)
|
||||
take(1),
|
||||
).subscribe((formData: any) => {
|
||||
const accessConditionsToSave = [];
|
||||
formData.accessCondition
|
||||
@@ -307,10 +307,10 @@ export class SubmissionSectionAccessesComponent extends SectionModelComponent {
|
||||
const discoverableCheckboxConfig = Object.assign({}, ACCESS_FORM_CHECKBOX_CONFIG, {
|
||||
label: this.translate.instant('submission.sections.accesses.form.discoverable-label'),
|
||||
hint: this.translate.instant('submission.sections.accesses.form.discoverable-description'),
|
||||
value: this.accessesData.discoverable
|
||||
value: this.accessesData.discoverable,
|
||||
});
|
||||
formModel.push(
|
||||
new DynamicCheckboxModel(discoverableCheckboxConfig, ACCESS_FORM_CHECKBOX_LAYOUT)
|
||||
new DynamicCheckboxModel(discoverableCheckboxConfig, ACCESS_FORM_CHECKBOX_LAYOUT),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -322,8 +322,8 @@ export class SubmissionSectionAccessesComponent extends SectionModelComponent {
|
||||
accessConditionTypeOptions.push(
|
||||
{
|
||||
label: accessCondition.name,
|
||||
value: accessCondition.name
|
||||
}
|
||||
value: accessCondition.name,
|
||||
},
|
||||
);
|
||||
}
|
||||
accessConditionTypeModelConfig.options = accessConditionTypeOptions;
|
||||
@@ -342,7 +342,7 @@ export class SubmissionSectionAccessesComponent extends SectionModelComponent {
|
||||
maxStartDate = {
|
||||
year: min.getUTCFullYear(),
|
||||
month: min.getUTCMonth() + 1,
|
||||
day: min.getUTCDate()
|
||||
day: min.getUTCDate(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -353,7 +353,7 @@ export class SubmissionSectionAccessesComponent extends SectionModelComponent {
|
||||
maxEndDate = {
|
||||
year: max.getUTCFullYear(),
|
||||
month: max.getUTCMonth() + 1,
|
||||
day: max.getUTCDate()
|
||||
day: max.getUTCDate(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -391,7 +391,7 @@ export class SubmissionSectionAccessesComponent extends SectionModelComponent {
|
||||
// Number of access conditions blocks in form
|
||||
accessConditionsArrayConfig.initialCount = isNotEmpty(this.accessesData.accessConditions) ? this.accessesData.accessConditions.length : 1;
|
||||
formModel.push(
|
||||
new DynamicFormArrayModel(accessConditionsArrayConfig, ACCESS_CONDITIONS_FORM_ARRAY_LAYOUT)
|
||||
new DynamicFormArrayModel(accessConditionsArrayConfig, ACCESS_CONDITIONS_FORM_ARRAY_LAYOUT),
|
||||
);
|
||||
|
||||
this.initModelData(formModel);
|
||||
|
@@ -12,7 +12,7 @@ import { DynamicCheckboxModelConfig } from '@ng-dynamic-forms/core/lib/model/che
|
||||
|
||||
export const ACCESS_FORM_CHECKBOX_CONFIG: DynamicCheckboxModelConfig = {
|
||||
id: 'discoverable',
|
||||
name: 'discoverable'
|
||||
name: 'discoverable',
|
||||
};
|
||||
|
||||
export const ACCESS_FORM_CHECKBOX_LAYOUT = {
|
||||
@@ -20,21 +20,21 @@ export const ACCESS_FORM_CHECKBOX_LAYOUT = {
|
||||
element: {
|
||||
container: 'custom-control custom-checkbox pl-1',
|
||||
control: 'custom-control-input',
|
||||
label: 'custom-control-label pt-1'
|
||||
}
|
||||
label: 'custom-control-label pt-1',
|
||||
},
|
||||
};
|
||||
|
||||
export const ACCESS_CONDITION_GROUP_CONFIG: DynamicFormGroupModelConfig = {
|
||||
id: 'accessConditionGroup',
|
||||
group: []
|
||||
group: [],
|
||||
};
|
||||
|
||||
export const ACCESS_CONDITION_GROUP_LAYOUT: DynamicFormControlLayout = {
|
||||
element: {
|
||||
host: 'form-group access-condition-group col',
|
||||
container: 'pl-1 pr-1',
|
||||
control: 'form-row '
|
||||
}
|
||||
control: 'form-row ',
|
||||
},
|
||||
};
|
||||
|
||||
export const ACCESS_CONDITIONS_FORM_ARRAY_CONFIG: DynamicFormArrayModelConfig = {
|
||||
@@ -44,20 +44,20 @@ export const ACCESS_CONDITIONS_FORM_ARRAY_CONFIG: DynamicFormArrayModelConfig =
|
||||
export const ACCESS_CONDITIONS_FORM_ARRAY_LAYOUT: DynamicFormControlLayout = {
|
||||
grid: {
|
||||
group: 'form-row pt-4',
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const FORM_ACCESS_CONDITION_TYPE_CONFIG: DynamicSelectModelConfig<any> = {
|
||||
id: 'name',
|
||||
label: 'submission.sections.accesses.form.access-condition-label',
|
||||
hint: 'submission.sections.accesses.form.access-condition-hint',
|
||||
options: []
|
||||
options: [],
|
||||
};
|
||||
export const FORM_ACCESS_CONDITION_TYPE_LAYOUT: DynamicFormControlLayout = {
|
||||
element: {
|
||||
host: 'col-12',
|
||||
label: 'col-form-label name-label'
|
||||
}
|
||||
label: 'col-form-label name-label',
|
||||
},
|
||||
};
|
||||
|
||||
export const FORM_ACCESS_CONDITION_START_DATE_CONFIG: DynamicDatePickerModelConfig = {
|
||||
@@ -71,24 +71,24 @@ export const FORM_ACCESS_CONDITION_START_DATE_CONFIG: DynamicDatePickerModelConf
|
||||
{
|
||||
match: MATCH_ENABLED,
|
||||
operator: OR_OPERATOR,
|
||||
when: []
|
||||
}
|
||||
when: [],
|
||||
},
|
||||
],
|
||||
required: true,
|
||||
validators: {
|
||||
required: null
|
||||
required: null,
|
||||
},
|
||||
errorMessages: {
|
||||
required: 'submission.sections.accesses.form.date-required-from'
|
||||
}
|
||||
required: 'submission.sections.accesses.form.date-required-from',
|
||||
},
|
||||
};
|
||||
export const FORM_ACCESS_CONDITION_START_DATE_LAYOUT: DynamicFormControlLayout = {
|
||||
element: {
|
||||
label: 'col-form-label'
|
||||
label: 'col-form-label',
|
||||
},
|
||||
grid: {
|
||||
host: 'col-6'
|
||||
}
|
||||
host: 'col-6',
|
||||
},
|
||||
};
|
||||
|
||||
export const FORM_ACCESS_CONDITION_END_DATE_CONFIG: DynamicDatePickerModelConfig = {
|
||||
@@ -102,22 +102,22 @@ export const FORM_ACCESS_CONDITION_END_DATE_CONFIG: DynamicDatePickerModelConfig
|
||||
{
|
||||
match: MATCH_ENABLED,
|
||||
operator: OR_OPERATOR,
|
||||
when: []
|
||||
}
|
||||
when: [],
|
||||
},
|
||||
],
|
||||
required: true,
|
||||
validators: {
|
||||
required: null
|
||||
required: null,
|
||||
},
|
||||
errorMessages: {
|
||||
required: 'submission.sections.accesses.form.date-required-until'
|
||||
}
|
||||
required: 'submission.sections.accesses.form.date-required-until',
|
||||
},
|
||||
};
|
||||
export const FORM_ACCESS_CONDITION_END_DATE_LAYOUT: DynamicFormControlLayout = {
|
||||
element: {
|
||||
label: 'col-form-label'
|
||||
label: 'col-form-label',
|
||||
},
|
||||
grid: {
|
||||
host: 'col-6'
|
||||
}
|
||||
host: 'col-6',
|
||||
},
|
||||
};
|
||||
|
@@ -33,7 +33,7 @@ describe('SubmissionSectionCcLicensesComponent', () => {
|
||||
serverValidationErrors: [],
|
||||
header: 'test header',
|
||||
id: 'test section id',
|
||||
sectionType: SectionsType.SubmissionForm
|
||||
sectionType: SectionsType.SubmissionForm,
|
||||
};
|
||||
|
||||
const submissionCcLicenses: SubmissionCcLicence[] = [
|
||||
@@ -96,12 +96,12 @@ describe('SubmissionSectionCcLicensesComponent', () => {
|
||||
{
|
||||
id: 'test enum id 2a I',
|
||||
label: 'test enum label 2a I',
|
||||
description: 'test enum description 2a I'
|
||||
description: 'test enum description 2a I',
|
||||
},
|
||||
{
|
||||
id: 'test enum id 2a II',
|
||||
label: 'test enum label 2a II',
|
||||
description: 'test enum description 2a II'
|
||||
description: 'test enum description 2a II',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -113,12 +113,12 @@ describe('SubmissionSectionCcLicensesComponent', () => {
|
||||
{
|
||||
id: 'test enum id 2b I',
|
||||
label: 'test enum label 2b I',
|
||||
description: 'test enum description 2b I'
|
||||
description: 'test enum description 2b I',
|
||||
},
|
||||
{
|
||||
id: 'test enum id 2b II',
|
||||
label: 'test enum label 2b II',
|
||||
description: 'test enum description 2b II'
|
||||
description: 'test enum description 2b II',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -139,7 +139,7 @@ describe('SubmissionSectionCcLicensesComponent', () => {
|
||||
getCcLicenseLink: createSuccessfulRemoteDataObject$(
|
||||
{
|
||||
url: 'test cc license link',
|
||||
}
|
||||
},
|
||||
),
|
||||
});
|
||||
|
||||
@@ -150,7 +150,7 @@ describe('SubmissionSectionCcLicensesComponent', () => {
|
||||
setSectionStatus: () => undefined,
|
||||
updateSectionData: (submissionId, sectionId, updatedData) => {
|
||||
component.sectionData.data = updatedData;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const operationsBuilder = jasmine.createSpyObj('operationsBuilder', {
|
||||
@@ -198,10 +198,10 @@ describe('SubmissionSectionCcLicensesComponent', () => {
|
||||
|
||||
it('should display a dropdown with the different cc licenses', () => {
|
||||
expect(
|
||||
de.query(By.css('.ccLicense-select ds-select .dropdown-menu button:nth-child(1)')).nativeElement.innerText
|
||||
de.query(By.css('.ccLicense-select ds-select .dropdown-menu button:nth-child(1)')).nativeElement.innerText,
|
||||
).toContain('test license name 1');
|
||||
expect(
|
||||
de.query(By.css('.ccLicense-select ds-select .dropdown-menu button:nth-child(2)')).nativeElement.innerText
|
||||
de.query(By.css('.ccLicense-select ds-select .dropdown-menu button:nth-child(2)')).nativeElement.innerText,
|
||||
).toContain('test license name 2');
|
||||
});
|
||||
|
||||
@@ -216,7 +216,7 @@ describe('SubmissionSectionCcLicensesComponent', () => {
|
||||
|
||||
it('should display the selected cc license', () => {
|
||||
expect(
|
||||
de.query(By.css('.ccLicense-select ds-select button.selection')).nativeElement.innerText
|
||||
de.query(By.css('.ccLicense-select ds-select button.selection')).nativeElement.innerText,
|
||||
).toContain('test license name 2');
|
||||
});
|
||||
|
||||
@@ -249,7 +249,7 @@ describe('SubmissionSectionCcLicensesComponent', () => {
|
||||
new Map([
|
||||
[ccLicence.fields[0], ccLicence.fields[0].enums[1]],
|
||||
[ccLicence.fields[1], ccLicence.fields[1].enums[0]],
|
||||
])
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
|
@@ -4,7 +4,7 @@ import { Field, Option, SubmissionCcLicence } from '../../../core/submission/mod
|
||||
import {
|
||||
getFirstCompletedRemoteData,
|
||||
getFirstSucceededRemoteData,
|
||||
getRemoteDataPayload
|
||||
getRemoteDataPayload,
|
||||
} from '../../../core/shared/operators';
|
||||
import { distinctUntilChanged, filter, map, take } from 'rxjs/operators';
|
||||
import { SubmissionCcLicenseDataService } from '../../../core/submission/submission-cc-license-data.service';
|
||||
@@ -27,7 +27,7 @@ import {ConfigurationDataService} from '../../../core/data/configuration-data.se
|
||||
@Component({
|
||||
selector: 'ds-submission-section-cc-licenses',
|
||||
templateUrl: './submission-section-cc-licenses.component.html',
|
||||
styleUrls: ['./submission-section-cc-licenses.component.scss']
|
||||
styleUrls: ['./submission-section-cc-licenses.component.scss'],
|
||||
})
|
||||
@renderSectionFor(SectionsType.CcLicense)
|
||||
export class SubmissionSectionCcLicensesComponent extends SectionModelComponent {
|
||||
@@ -96,7 +96,7 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent
|
||||
protected configService: ConfigurationDataService,
|
||||
@Inject('collectionIdProvider') public injectedCollectionId: string,
|
||||
@Inject('sectionDataProvider') public injectedSectionData: SectionDataObject,
|
||||
@Inject('submissionIdProvider') public injectedSubmissionId: string
|
||||
@Inject('submissionIdProvider') public injectedSubmissionId: string,
|
||||
) {
|
||||
super(
|
||||
injectedCollectionId,
|
||||
@@ -154,7 +154,7 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent
|
||||
ccLicense: {
|
||||
id: ccLicense.id,
|
||||
fields: Object.assign({}, this.data.ccLicense.fields, {
|
||||
[field.id]: option
|
||||
[field.id]: option,
|
||||
}),
|
||||
},
|
||||
accepted: false,
|
||||
@@ -199,7 +199,7 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent
|
||||
return this.submissionCcLicenseUrlDataService.getCcLicenseLink(
|
||||
selectedCcLicense,
|
||||
new Map(selectedCcLicense.fields.map(
|
||||
(field) => [field, this.getSelectedOption(selectedCcLicense, field)]
|
||||
(field) => [field, this.getSelectedOption(selectedCcLicense, field)],
|
||||
)),
|
||||
);
|
||||
}
|
||||
@@ -268,11 +268,11 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent
|
||||
getRemoteDataPayload(),
|
||||
map((list) => list.page),
|
||||
).subscribe(
|
||||
(licenses) => this.submissionCcLicenses = licenses
|
||||
(licenses) => this.submissionCcLicenses = licenses,
|
||||
),
|
||||
this.configService.findByPropertyName('cc.license.jurisdiction').pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
getRemoteDataPayload()
|
||||
getRemoteDataPayload(),
|
||||
).subscribe((remoteData) => {
|
||||
if (remoteData === undefined || remoteData.values.length === 0) {
|
||||
// No value configured, use blank value (International jurisdiction)
|
||||
@@ -280,7 +280,7 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent
|
||||
} else {
|
||||
this.defaultJurisdiction = remoteData.values[0];
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent
|
||||
*/
|
||||
setAccepted(accepted: boolean) {
|
||||
this.updateSectionData({
|
||||
accepted
|
||||
accepted,
|
||||
});
|
||||
this.updateSectionStatus();
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Load the implementations that should be tested
|
||||
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { ComponentFixture, inject, TestBed, waitForAsync, } from '@angular/core/testing';
|
||||
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
import { of as observableOf } from 'rxjs';
|
||||
@@ -29,7 +29,7 @@ const sectionState = {
|
||||
errorsToShow: [],
|
||||
serverValidationErrors: [],
|
||||
isLoading: false,
|
||||
isValid: false
|
||||
isValid: false,
|
||||
} as any;
|
||||
|
||||
const sectionObject: SectionDataObject = {
|
||||
@@ -40,7 +40,7 @@ const sectionObject: SectionDataObject = {
|
||||
serverValidationErrors: [],
|
||||
header: 'submit.progressbar.describe.stepone',
|
||||
id: 'traditionalpageone',
|
||||
sectionType: SectionsType.SubmissionForm
|
||||
sectionType: SectionsType.SubmissionForm,
|
||||
};
|
||||
|
||||
describe('SubmissionSectionContainerComponent test suite', () => {
|
||||
@@ -68,7 +68,7 @@ describe('SubmissionSectionContainerComponent test suite', () => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
NgbModule,
|
||||
TranslateModule.forRoot()
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [
|
||||
SubmissionSectionContainerComponent,
|
||||
@@ -78,9 +78,9 @@ describe('SubmissionSectionContainerComponent test suite', () => {
|
||||
providers: [
|
||||
{ provide: SectionsService, useValue: sectionsServiceStub },
|
||||
{ provide: SubmissionService, useValue: submissionServiceStub },
|
||||
SubmissionSectionContainerComponent
|
||||
SubmissionSectionContainerComponent,
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
}).compileComponents();
|
||||
|
||||
}));
|
||||
@@ -226,7 +226,7 @@ describe('SubmissionSectionContainerComponent test suite', () => {
|
||||
@Component({
|
||||
// eslint-disable-next-line @angular-eslint/component-selector
|
||||
selector: '',
|
||||
template: ``
|
||||
template: ``,
|
||||
})
|
||||
class TestComponent {
|
||||
|
||||
|
@@ -11,7 +11,7 @@ import { AlertType } from '../../../shared/alert/aletr-type';
|
||||
@Component({
|
||||
selector: 'ds-submission-section-container',
|
||||
templateUrl: './section-container.component.html',
|
||||
styleUrls: ['./section-container.component.scss']
|
||||
styleUrls: ['./section-container.component.scss'],
|
||||
})
|
||||
export class SubmissionSectionContainerComponent implements OnInit {
|
||||
|
||||
@@ -68,7 +68,7 @@ export class SubmissionSectionContainerComponent implements OnInit {
|
||||
{ provide: 'sectionDataProvider', useFactory: () => (this.sectionData), deps: [] },
|
||||
{ provide: 'submissionIdProvider', useFactory: () => (this.submissionId), deps: [] },
|
||||
],
|
||||
parent: this.injector
|
||||
parent: this.injector,
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,7 @@ import {
|
||||
DYNAMIC_FORM_CONTROL_TYPE_ARRAY,
|
||||
DYNAMIC_FORM_CONTROL_TYPE_GROUP,
|
||||
DynamicFormControlEvent,
|
||||
DynamicInputModel
|
||||
DynamicInputModel,
|
||||
} from '@ng-dynamic-forms/core';
|
||||
|
||||
import { FormBuilderService } from '../../../shared/form/builder/form-builder.service';
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
mockQualdropInputModel,
|
||||
MockQualdropModel,
|
||||
MockRelationModel,
|
||||
mockRowGroupModel
|
||||
mockRowGroupModel,
|
||||
} from '../../../shared/mocks/form-models.mock';
|
||||
import { FormFieldMetadataValueObject } from '../../../shared/form/builder/models/form-field-metadata-value.model';
|
||||
import { VocabularyEntry } from '../../../core/submission/vocabularies/models/vocabulary-entry.model';
|
||||
@@ -49,7 +49,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
control: null,
|
||||
group: null,
|
||||
model: null,
|
||||
type: 'change'
|
||||
type: 'change',
|
||||
};
|
||||
|
||||
const dynamicFormControlRemoveEvent: DynamicFormControlEvent = {
|
||||
@@ -58,7 +58,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
control: null,
|
||||
group: null,
|
||||
model: null,
|
||||
type: 'remove'
|
||||
type: 'remove',
|
||||
};
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
@@ -67,15 +67,15 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: TranslateLoaderMock
|
||||
}
|
||||
})
|
||||
useClass: TranslateLoaderMock,
|
||||
},
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
{ provide: FormBuilderService, useValue: getMockFormBuilderService() },
|
||||
{ provide: JsonPatchOperationsBuilder, useValue: jsonPatchOpBuilder },
|
||||
SectionFormOperationsService
|
||||
]
|
||||
SectionFormOperationsService,
|
||||
],
|
||||
}).compileComponents().then();
|
||||
}));
|
||||
|
||||
@@ -114,8 +114,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
it('should return the index of the array to which the element belongs', () => {
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
context: {
|
||||
index: 1
|
||||
}
|
||||
index: 1,
|
||||
},
|
||||
});
|
||||
|
||||
expect(service.getArrayIndexFromEvent(event)).toBe(1);
|
||||
@@ -126,10 +126,10 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
model: {
|
||||
parent: {
|
||||
parent: {
|
||||
index: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
index: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
spyOn(serviceAsAny, 'isPartOfArrayOfGroup').and.returnValue(true);
|
||||
|
||||
@@ -157,10 +157,10 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
type: DYNAMIC_FORM_CONTROL_TYPE_GROUP,
|
||||
parent: {
|
||||
context: {
|
||||
type: DYNAMIC_FORM_CONTROL_TYPE_ARRAY
|
||||
}
|
||||
}
|
||||
}
|
||||
type: DYNAMIC_FORM_CONTROL_TYPE_ARRAY,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(service.isPartOfArrayOfGroup(model as any)).toBeTruthy();
|
||||
@@ -168,7 +168,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
|
||||
it('should return false when parent element doesn\'t belong to an array group element', () => {
|
||||
const model = {
|
||||
parent: null
|
||||
parent: null,
|
||||
};
|
||||
|
||||
expect(service.isPartOfArrayOfGroup(model as any)).toBeFalsy();
|
||||
@@ -181,19 +181,19 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const context = {
|
||||
groups: [
|
||||
{
|
||||
group: [MockQualdropModel]
|
||||
}
|
||||
]
|
||||
group: [MockQualdropModel],
|
||||
},
|
||||
],
|
||||
};
|
||||
const model = {
|
||||
parent: {
|
||||
parent: {
|
||||
context: context
|
||||
}
|
||||
}
|
||||
context: context,
|
||||
},
|
||||
},
|
||||
};
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: model
|
||||
model: model,
|
||||
});
|
||||
const expectMap = new Map();
|
||||
expectMap.set(MockQualdropModel.qualdropId, [MockQualdropModel.value]);
|
||||
@@ -207,17 +207,17 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const context = {
|
||||
groups: [
|
||||
{
|
||||
group: [MockQualdropModel]
|
||||
}
|
||||
]
|
||||
group: [MockQualdropModel],
|
||||
},
|
||||
],
|
||||
};
|
||||
const model = {
|
||||
parent: {
|
||||
context: context
|
||||
}
|
||||
context: context,
|
||||
},
|
||||
};
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: model
|
||||
model: model,
|
||||
});
|
||||
const expectMap = new Map();
|
||||
expectMap.set(MockQualdropModel.qualdropId, [MockQualdropModel.value]);
|
||||
@@ -247,19 +247,19 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const context = {
|
||||
groups: [
|
||||
{
|
||||
group: [MockQualdropModel]
|
||||
}
|
||||
]
|
||||
group: [MockQualdropModel],
|
||||
},
|
||||
],
|
||||
};
|
||||
const model = {
|
||||
parent: {
|
||||
parent: {
|
||||
context: context
|
||||
}
|
||||
}
|
||||
context: context,
|
||||
},
|
||||
},
|
||||
};
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: model
|
||||
model: model,
|
||||
});
|
||||
const expectPath = 'dc.identifier.issn/0';
|
||||
spyOn(serviceAsAny, 'getArrayIndexFromEvent').and.returnValue(0);
|
||||
@@ -273,17 +273,17 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const context = {
|
||||
groups: [
|
||||
{
|
||||
group: [MockQualdropModel]
|
||||
}
|
||||
]
|
||||
group: [MockQualdropModel],
|
||||
},
|
||||
],
|
||||
};
|
||||
const model = {
|
||||
parent: {
|
||||
context: context
|
||||
}
|
||||
context: context,
|
||||
},
|
||||
};
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: model
|
||||
model: model,
|
||||
});
|
||||
const expectPath = 'dc.identifier.issn/0';
|
||||
spyOn(serviceAsAny, 'getArrayIndexFromEvent').and.returnValue(0);
|
||||
@@ -297,7 +297,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
describe('getFieldPathSegmentedFromChangeEvent', () => {
|
||||
it('should return field segmented path properly', () => {
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: mockQualdropInputModel
|
||||
model: mockQualdropInputModel,
|
||||
});
|
||||
formBuilderService.isQualdropGroup.and.returnValues(false, false);
|
||||
|
||||
@@ -306,7 +306,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
|
||||
it('should return field segmented path properly when model is DynamicQualdropModel', () => {
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: MockQualdropModel
|
||||
model: MockQualdropModel,
|
||||
});
|
||||
formBuilderService.isQualdropGroup.and.returnValue(true);
|
||||
|
||||
@@ -316,8 +316,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
it('should return field segmented path properly when model belongs to a DynamicQualdropModel', () => {
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: MockQualdropModel
|
||||
}
|
||||
parent: MockQualdropModel,
|
||||
},
|
||||
});
|
||||
formBuilderService.isQualdropGroup.and.returnValues(false, true);
|
||||
|
||||
@@ -330,8 +330,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
it('should return field value properly when model belongs to a DynamicQualdropModel', () => {
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: MockQualdropModel
|
||||
}
|
||||
parent: MockQualdropModel,
|
||||
},
|
||||
});
|
||||
formBuilderService.isModelInCustomGroup.and.returnValue(true);
|
||||
const expectedValue = 'test';
|
||||
@@ -341,18 +341,18 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
|
||||
it('should return field value properly when model is DynamicRelationGroupModel', () => {
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: MockRelationModel
|
||||
model: MockRelationModel,
|
||||
});
|
||||
formBuilderService.isModelInCustomGroup.and.returnValue(false);
|
||||
formBuilderService.isRelationGroup.and.returnValue(true);
|
||||
const expectedValue = {
|
||||
journal: [
|
||||
'journal test 1',
|
||||
'journal test 2'
|
||||
'journal test 2',
|
||||
],
|
||||
issue: [
|
||||
'issue test 1',
|
||||
'issue test 2'
|
||||
'issue test 2',
|
||||
],
|
||||
};
|
||||
|
||||
@@ -361,7 +361,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
|
||||
it('should return field value properly when model has language', () => {
|
||||
let event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: mockInputWithLanguageModel
|
||||
model: mockInputWithLanguageModel,
|
||||
});
|
||||
formBuilderService.isModelInCustomGroup.and.returnValue(false);
|
||||
formBuilderService.isRelationGroup.and.returnValue(false);
|
||||
@@ -370,19 +370,19 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
expect(service.getFieldValueFromChangeEvent(event)).toEqual(expectedValue);
|
||||
|
||||
event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: mockInputWithLanguageAndAuthorityModel
|
||||
model: mockInputWithLanguageAndAuthorityModel,
|
||||
});
|
||||
expectedValue = Object.assign(new VocabularyEntry(), mockInputWithLanguageAndAuthorityModel.value, {language: mockInputWithLanguageAndAuthorityModel.language});
|
||||
|
||||
expect(service.getFieldValueFromChangeEvent(event)).toEqual(expectedValue);
|
||||
|
||||
event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: mockInputWithLanguageAndAuthorityArrayModel
|
||||
model: mockInputWithLanguageAndAuthorityArrayModel,
|
||||
});
|
||||
expectedValue = [
|
||||
Object.assign(new VocabularyEntry(), mockInputWithLanguageAndAuthorityArrayModel.value[0],
|
||||
{ language: mockInputWithLanguageAndAuthorityArrayModel.language }
|
||||
)
|
||||
{ language: mockInputWithLanguageAndAuthorityArrayModel.language },
|
||||
),
|
||||
];
|
||||
|
||||
expect(service.getFieldValueFromChangeEvent(event)).toEqual(expectedValue);
|
||||
@@ -390,7 +390,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
|
||||
it('should return field value properly when model has an object as value', () => {
|
||||
let event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: mockInputWithFormFieldValueModel
|
||||
model: mockInputWithFormFieldValueModel,
|
||||
});
|
||||
formBuilderService.isModelInCustomGroup.and.returnValue(false);
|
||||
formBuilderService.isRelationGroup.and.returnValue(false);
|
||||
@@ -399,14 +399,14 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
expect(service.getFieldValueFromChangeEvent(event)).toEqual(expectedValue);
|
||||
|
||||
event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: mockInputWithAuthorityValueModel
|
||||
model: mockInputWithAuthorityValueModel,
|
||||
});
|
||||
expectedValue = mockInputWithAuthorityValueModel.value;
|
||||
|
||||
expect(service.getFieldValueFromChangeEvent(event)).toEqual(expectedValue);
|
||||
|
||||
event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: mockInputWithObjectValueModel
|
||||
model: mockInputWithObjectValueModel,
|
||||
});
|
||||
expectedValue = mockInputWithObjectValueModel.value;
|
||||
|
||||
@@ -461,8 +461,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: MockQualdropModel
|
||||
}
|
||||
parent: MockQualdropModel,
|
||||
},
|
||||
});
|
||||
spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -481,8 +481,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: MockRelationModel
|
||||
}
|
||||
parent: MockRelationModel,
|
||||
},
|
||||
});
|
||||
spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -502,8 +502,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -523,8 +523,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
const spyPath = spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -552,8 +552,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -577,8 +577,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
let previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
const spyPath = spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -607,8 +607,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -632,8 +632,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], null);
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -658,8 +658,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
const spyPath = spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -693,8 +693,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/1');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -712,7 +712,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
expect(jsonPatchOpBuilder.add).toHaveBeenCalledWith(
|
||||
pathCombiner.getPath('path'),
|
||||
new FormFieldMetadataValueObject('test'),
|
||||
true
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -808,7 +808,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
isDraggable: true,
|
||||
groupFactory: () => {
|
||||
return [
|
||||
new DynamicInputModel({ id: 'testFormRowArrayGroupInput' })
|
||||
new DynamicInputModel({ id: 'testFormRowArrayGroupInput' }),
|
||||
];
|
||||
},
|
||||
required: false,
|
||||
@@ -816,8 +816,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
metadataFields: ['dc.contributor.author'],
|
||||
hasSelectableMetadata: true,
|
||||
showButtons: true,
|
||||
typeBindRelations: []
|
||||
}
|
||||
typeBindRelations: [],
|
||||
},
|
||||
);
|
||||
spyOn(serviceAsAny, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
previousValue = new FormFieldPreviousValueObject(['path'], null);
|
||||
@@ -831,7 +831,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
pathCombiner,
|
||||
dynamicFormControlChangeEvent,
|
||||
arrayModel,
|
||||
previousValue
|
||||
previousValue,
|
||||
);
|
||||
|
||||
expect(jsonPatchOpBuilder.add).not.toHaveBeenCalled();
|
||||
@@ -841,10 +841,10 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
it('should dispatch a json-path add operation when a array value is not empty', () => {
|
||||
const pathValue = [
|
||||
new FormFieldMetadataValueObject('test'),
|
||||
new FormFieldMetadataValueObject('test two')
|
||||
new FormFieldMetadataValueObject('test two'),
|
||||
];
|
||||
formBuilderService.getValueFromModel.and.returnValue({
|
||||
path:pathValue
|
||||
path:pathValue,
|
||||
});
|
||||
spyOn(previousValue, 'isPathEqual').and.returnValue(false);
|
||||
|
||||
@@ -852,13 +852,13 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
pathCombiner,
|
||||
dynamicFormControlChangeEvent,
|
||||
arrayModel,
|
||||
previousValue
|
||||
previousValue,
|
||||
);
|
||||
|
||||
expect(jsonPatchOpBuilder.add).toHaveBeenCalledWith(
|
||||
pathCombiner.getPath('path'),
|
||||
pathValue,
|
||||
false
|
||||
false,
|
||||
);
|
||||
expect(jsonPatchOpBuilder.remove).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -871,7 +871,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
pathCombiner,
|
||||
dynamicFormControlChangeEvent,
|
||||
arrayModel,
|
||||
previousValue
|
||||
previousValue,
|
||||
);
|
||||
|
||||
expect(jsonPatchOpBuilder.add).not.toHaveBeenCalled();
|
||||
|
@@ -8,7 +8,7 @@ import {
|
||||
DynamicFormArrayGroupModel,
|
||||
DynamicFormControlEvent,
|
||||
DynamicFormControlModel,
|
||||
isDynamicFormControlEvent
|
||||
isDynamicFormControlEvent,
|
||||
} from '@ng-dynamic-forms/core';
|
||||
|
||||
import { hasValue, isNotEmpty, isNotNull, isNotUndefined, isNull, isUndefined } from '../../../shared/empty.util';
|
||||
@@ -321,7 +321,7 @@ export class SectionFormOperationsService {
|
||||
*/
|
||||
protected dispatchOperationsFromAddEvent(
|
||||
pathCombiner: JsonPatchOperationPathCombiner,
|
||||
event: DynamicFormControlEvent
|
||||
event: DynamicFormControlEvent,
|
||||
): void {
|
||||
const path = this.getFieldPathSegmentedFromChangeEvent(event);
|
||||
const value = deepClone(this.getFieldValueFromChangeEvent(event));
|
||||
@@ -399,7 +399,7 @@ export class SectionFormOperationsService {
|
||||
if (isNotEmpty(moveFrom.path) && isNotEmpty(moveTo.path) && moveFrom.path !== moveTo.path) {
|
||||
this.operationsBuilder.move(
|
||||
moveTo,
|
||||
moveFrom.path
|
||||
moveFrom.path,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -522,7 +522,7 @@ export class SectionFormOperationsService {
|
||||
this.operationsBuilder.add(
|
||||
pathCombiner.getPath(segmentedPath),
|
||||
arrayValue[segmentedPath],
|
||||
false
|
||||
false,
|
||||
);
|
||||
} else if (previousValue.isPathEqual(this.formBuilder.getPath(event.model))) {
|
||||
this.operationsBuilder.remove(pathCombiner.getPath(segmentedPath));
|
||||
|
@@ -63,7 +63,7 @@ const sectionObject: SectionDataObject = {
|
||||
serverValidationErrors: [],
|
||||
header: 'submit.progressbar.describe.stepone',
|
||||
id: 'traditionalpageone',
|
||||
sectionType: SectionsType.SubmissionForm
|
||||
sectionType: SectionsType.SubmissionForm,
|
||||
};
|
||||
|
||||
const testFormConfiguration = {
|
||||
@@ -73,7 +73,7 @@ const testFormConfiguration = {
|
||||
fields: [
|
||||
{
|
||||
input: {
|
||||
type: 'onebox'
|
||||
type: 'onebox',
|
||||
},
|
||||
label: 'Title',
|
||||
mandatory: 'true',
|
||||
@@ -81,18 +81,18 @@ const testFormConfiguration = {
|
||||
hints: ' Enter Title.',
|
||||
selectableMetadata: [
|
||||
{
|
||||
metadata: 'dc.title'
|
||||
}
|
||||
metadata: 'dc.title',
|
||||
},
|
||||
],
|
||||
languageCodes: []
|
||||
} as FormFieldModel
|
||||
]
|
||||
languageCodes: [],
|
||||
} as FormFieldModel,
|
||||
],
|
||||
} as FormRowModel,
|
||||
{
|
||||
fields: [
|
||||
{
|
||||
input: {
|
||||
type: 'onebox'
|
||||
type: 'onebox',
|
||||
},
|
||||
label: 'Author',
|
||||
mandatory: 'false',
|
||||
@@ -100,20 +100,20 @@ const testFormConfiguration = {
|
||||
hints: ' Enter Author.',
|
||||
selectableMetadata: [
|
||||
{
|
||||
metadata: 'dc.contributor'
|
||||
}
|
||||
metadata: 'dc.contributor',
|
||||
},
|
||||
],
|
||||
languageCodes: []
|
||||
} as FormFieldModel
|
||||
]
|
||||
languageCodes: [],
|
||||
} as FormFieldModel,
|
||||
],
|
||||
} as FormRowModel,
|
||||
],
|
||||
type: 'submissionform',
|
||||
_links: {
|
||||
self: {
|
||||
href: 'testFormConfiguration.url'
|
||||
}
|
||||
}
|
||||
href: 'testFormConfiguration.url',
|
||||
},
|
||||
},
|
||||
} as any;
|
||||
|
||||
const testFormModel = [
|
||||
@@ -124,7 +124,7 @@ const testFormModel = [
|
||||
new DynamicRowGroupModel({
|
||||
id: 'df-row-group-config-2',
|
||||
group: [new DsDynamicInputModel({ id: 'dc.contributor', metadataFields: [], repeatable: false, submissionId: '1234', hasSelectableMetadata: false })],
|
||||
})
|
||||
}),
|
||||
];
|
||||
|
||||
const dynamicFormControlEvent: DynamicFormControlEvent = {
|
||||
@@ -133,7 +133,7 @@ const dynamicFormControlEvent: DynamicFormControlEvent = {
|
||||
control: null,
|
||||
group: testFormModel[0] as any,
|
||||
model: testFormModel[0].group[0],
|
||||
type: DynamicFormControlEventType.Change
|
||||
type: DynamicFormControlEventType.Change,
|
||||
};
|
||||
|
||||
describe('SubmissionSectionFormComponent test suite', () => {
|
||||
@@ -162,12 +162,12 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
TranslateModule.forRoot()
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [
|
||||
FormComponent,
|
||||
SubmissionSectionFormComponent,
|
||||
TestComponent
|
||||
TestComponent,
|
||||
],
|
||||
providers: [
|
||||
{ provide: FormBuilderService, useValue: getMockFormBuilderService() },
|
||||
@@ -185,9 +185,9 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
{ provide: 'submissionIdProvider', useValue: submissionId },
|
||||
{ provide: SubmissionObjectDataService, useValue: { getHrefByID: () => observableOf('testUrl'), findById: () => createSuccessfulRemoteDataObject$(new WorkspaceItem()) } },
|
||||
ChangeDetectorRef,
|
||||
SubmissionSectionFormComponent
|
||||
SubmissionSectionFormComponent,
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
}).compileComponents().then();
|
||||
}));
|
||||
|
||||
@@ -281,7 +281,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
const sectionData = {};
|
||||
const sectionError: SubmissionSectionError = {
|
||||
message: 'test' + 'Error: test',
|
||||
path: '/sections/' + sectionObject.id
|
||||
path: '/sections/' + sectionObject.id,
|
||||
};
|
||||
|
||||
comp.initForm(sectionData);
|
||||
@@ -293,11 +293,11 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
|
||||
it('should return true when has Metadata Enrichment', () => {
|
||||
const newSectionData = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
compAsAny.formData = {};
|
||||
compAsAny.sectionData.data = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
spyOn(compAsAny, 'inCurrentSubmissionScope').and.callThrough();
|
||||
|
||||
@@ -307,11 +307,11 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
|
||||
it('should return false when has not Metadata Enrichment', () => {
|
||||
const newSectionData = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
compAsAny.formData = newSectionData;
|
||||
compAsAny.sectionData.data = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
spyOn(compAsAny, 'inCurrentSubmissionScope').and.callThrough();
|
||||
|
||||
@@ -321,7 +321,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
|
||||
it('should return false when metadata has Metadata Enrichment but not belonging to sectionMetadata', () => {
|
||||
const newSectionData = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
compAsAny.formData = newSectionData;
|
||||
compAsAny.sectionMetadata = [];
|
||||
@@ -338,16 +338,16 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
{
|
||||
selectableMetadata: [{ metadata: 'scoped.workflow' }],
|
||||
scope: 'WORKFLOW',
|
||||
} as FormFieldModel
|
||||
]
|
||||
} as FormFieldModel,
|
||||
],
|
||||
},
|
||||
{
|
||||
fields: [
|
||||
{
|
||||
selectableMetadata: [{ metadata: 'scoped.workspace' }],
|
||||
scope: 'WORKSPACE',
|
||||
} as FormFieldModel
|
||||
]
|
||||
} as FormFieldModel,
|
||||
],
|
||||
},
|
||||
{
|
||||
fields: [
|
||||
@@ -369,10 +369,10 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
fields: [
|
||||
{
|
||||
selectableMetadata: [{ metadata: 'dc.title' }],
|
||||
} as FormFieldModel
|
||||
]
|
||||
}
|
||||
]
|
||||
} as FormFieldModel,
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
|
||||
@@ -435,7 +435,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
spyOn(comp, 'initForm');
|
||||
spyOn(comp, 'checksForErrors');
|
||||
const sectionData: any = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
const sectionError = [];
|
||||
comp.sectionData.data = {};
|
||||
@@ -456,7 +456,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
spyOn(comp, 'initForm');
|
||||
spyOn(comp, 'checksForErrors');
|
||||
const sectionData: any = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
comp.sectionData.data = {};
|
||||
comp.sectionData.errorsToShow = [];
|
||||
@@ -495,7 +495,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
sectionObject.id,
|
||||
'test',
|
||||
parsedSectionErrors,
|
||||
[]
|
||||
[],
|
||||
);
|
||||
expect(comp.sectionData.errorsToShow).toEqual(parsedSectionErrors);
|
||||
});
|
||||
@@ -504,7 +504,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
formService.isValid.and.returnValue(observableOf(true));
|
||||
sectionsServiceStub.getSectionServerErrors.and.returnValue(observableOf([]));
|
||||
const expected = cold('(b|)', {
|
||||
b: true
|
||||
b: true,
|
||||
});
|
||||
|
||||
expect(compAsAny.getSectionStatus()).toBeObservable(expected);
|
||||
@@ -514,7 +514,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
formService.isValid.and.returnValue(observableOf(true));
|
||||
sectionsServiceStub.getSectionServerErrors.and.returnValue(observableOf(parsedSectionErrors));
|
||||
const expected = cold('(b|)', {
|
||||
b: false
|
||||
b: false,
|
||||
});
|
||||
|
||||
expect(compAsAny.getSectionStatus()).toBeObservable(expected);
|
||||
@@ -524,7 +524,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
formService.isValid.and.returnValue(observableOf(false));
|
||||
sectionsServiceStub.getSectionServerErrors.and.returnValue(observableOf([]));
|
||||
const expected = cold('(b|)', {
|
||||
b: false
|
||||
b: false,
|
||||
});
|
||||
|
||||
expect(compAsAny.getSectionStatus()).toBeObservable(expected);
|
||||
@@ -533,14 +533,14 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
it('should subscribe to state properly', () => {
|
||||
spyOn(comp, 'updateForm');
|
||||
const formData = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
const sectionData: any = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
const sectionState = {
|
||||
data: sectionData,
|
||||
errorsToShow: parsedSectionErrors
|
||||
errorsToShow: parsedSectionErrors,
|
||||
};
|
||||
|
||||
formService.getFormData.and.returnValue(observableOf(formData));
|
||||
@@ -617,7 +617,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
|
||||
it('should check if has stored value in the section state', () => {
|
||||
comp.sectionData.data = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
} as any;
|
||||
|
||||
expect(comp.hasStoredValue('dc.title', 0)).toBeTruthy();
|
||||
@@ -631,7 +631,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
// declare a test component
|
||||
@Component({
|
||||
selector: 'ds-test-cmp',
|
||||
template: ``
|
||||
template: ``,
|
||||
})
|
||||
class TestComponent {
|
||||
|
||||
|
@@ -183,7 +183,7 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
|
||||
this.submissionObjectService.findById(this.submissionId, true, false, followLink('item')).pipe(
|
||||
getFirstSucceededRemoteData(),
|
||||
getRemoteDataPayload()),
|
||||
this.sectionService.isSectionReadOnly(this.submissionId, this.sectionData.id, this.submissionService.getSubmissionScope())
|
||||
this.sectionService.isSectionReadOnly(this.submissionId, this.sectionData.id, this.submissionService.getSubmissionScope()),
|
||||
])),
|
||||
take(1))
|
||||
.subscribe(([sectionData, submissionObject, isSectionReadOnly]: [WorkspaceitemSectionFormObject, SubmissionObject, boolean]) => {
|
||||
@@ -219,11 +219,11 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
|
||||
protected getSectionStatus(): Observable<boolean> {
|
||||
const formStatus$ = this.formService.isValid(this.formId);
|
||||
const serverValidationStatus$ = this.sectionService.getSectionServerErrors(this.submissionId, this.sectionData.id).pipe(
|
||||
map((validationErrors) => isEmpty(validationErrors))
|
||||
map((validationErrors) => isEmpty(validationErrors)),
|
||||
);
|
||||
|
||||
return observableCombineLatest([formStatus$, serverValidationStatus$]).pipe(
|
||||
map(([formValidation, serverSideValidation]: [boolean, boolean]) => formValidation && serverSideValidation)
|
||||
map(([formValidation, serverSideValidation]: [boolean, boolean]) => formValidation && serverSideValidation),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
|
||||
this.collectionId,
|
||||
sectionData,
|
||||
this.submissionService.getSubmissionScope(),
|
||||
this.isSectionReadonly
|
||||
this.isSectionReadonly,
|
||||
);
|
||||
const sectionMetadata = this.sectionService.computeSectionConfiguredMetadata(this.formConfig);
|
||||
this.sectionService.updateSectionData(this.submissionId, this.sectionData.id, sectionData, this.sectionData.errorsToShow, this.sectionData.serverValidationErrors, sectionMetadata);
|
||||
@@ -312,7 +312,7 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
|
||||
const msg: string = this.translate.instant('error.submission.sections.init-form-error') + e.toString();
|
||||
const sectionError: SubmissionSectionError = {
|
||||
message: msg,
|
||||
path: '/sections/' + this.sectionData.id
|
||||
path: '/sections/' + this.sectionData.id,
|
||||
};
|
||||
console.error(e.stack);
|
||||
this.sectionService.setSectionError(this.submissionId, this.sectionData.id, sectionError);
|
||||
@@ -390,7 +390,7 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
|
||||
this.fieldsOnTheirWayToBeRemoved = new Map();
|
||||
this.sectionMetadata = sectionState.metadata;
|
||||
this.updateForm(sectionState.data as WorkspaceitemSectionFormObject, sectionState.errorsToShow);
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -46,14 +46,14 @@ function getMockSubmissionFormsConfigService(): SubmissionFormsConfigDataService
|
||||
getConfigAll: jasmine.createSpy('getConfigAll'),
|
||||
getConfigByHref: jasmine.createSpy('getConfigByHref'),
|
||||
getConfigByName: jasmine.createSpy('getConfigByName'),
|
||||
getConfigBySearch: jasmine.createSpy('getConfigBySearch')
|
||||
getConfigBySearch: jasmine.createSpy('getConfigBySearch'),
|
||||
});
|
||||
}
|
||||
|
||||
function getMockCollectionDataService(): CollectionDataService {
|
||||
return jasmine.createSpyObj('CollectionDataService', {
|
||||
findById: jasmine.createSpy('findById'),
|
||||
findByHref: jasmine.createSpy('findByHref')
|
||||
findByHref: jasmine.createSpy('findByHref'),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,9 +64,9 @@ const mockItem = Object.assign(new Item(), {
|
||||
'dc.title': [
|
||||
{
|
||||
language: null,
|
||||
value: 'mockmatch'
|
||||
}
|
||||
]
|
||||
value: 'mockmatch',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -76,16 +76,16 @@ const identifierData: WorkspaceitemSectionIdentifiersObject = {
|
||||
value: 'https://doi.org/10.33515/dspace-61',
|
||||
identifierType: 'doi',
|
||||
identifierStatus: 'TO_BE_REGISTERED',
|
||||
type: 'identifier'
|
||||
type: 'identifier',
|
||||
},
|
||||
{
|
||||
value: '123456789/418',
|
||||
identifierType: 'handle',
|
||||
identifierStatus: null,
|
||||
type: 'identifier'
|
||||
}
|
||||
type: 'identifier',
|
||||
},
|
||||
],
|
||||
displayTypes: ['doi', 'handle']
|
||||
displayTypes: ['doi', 'handle'],
|
||||
};
|
||||
|
||||
// Mock section object to use with tests
|
||||
@@ -99,7 +99,7 @@ const sectionObject: SectionDataObject = {
|
||||
header: 'submission.sections.submit.progressbar.identifiers',
|
||||
id: 'identifiers',
|
||||
sectionType: SectionsType.Identifiers,
|
||||
sectionVisibility: null
|
||||
sectionVisibility: null,
|
||||
};
|
||||
|
||||
describe('SubmissionSectionIdentifiersComponent test suite', () => {
|
||||
@@ -129,9 +129,9 @@ describe('SubmissionSectionIdentifiersComponent test suite', () => {
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'Community 1-Collection 1'
|
||||
value: 'Community 1-Collection 1',
|
||||
}],
|
||||
license: createSuccessfulRemoteDataObject$(Object.assign(new License(), { text: licenseText }))
|
||||
license: createSuccessfulRemoteDataObject$(Object.assign(new License(), { text: licenseText })),
|
||||
});
|
||||
const paginationService = new PaginationServiceStub();
|
||||
|
||||
@@ -167,9 +167,9 @@ describe('SubmissionSectionIdentifiersComponent test suite', () => {
|
||||
{ provide: PaginationService, useValue: paginationService },
|
||||
ChangeDetectorRef,
|
||||
FormBuilderService,
|
||||
SubmissionSectionIdentifiersComponent
|
||||
SubmissionSectionIdentifiersComponent,
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
}).compileComponents().then();
|
||||
}));
|
||||
|
||||
@@ -235,13 +235,13 @@ describe('SubmissionSectionIdentifiersComponent test suite', () => {
|
||||
it('Should return TRUE if the isLoading is FALSE', () => {
|
||||
compAsAny.isLoading = false;
|
||||
expect(compAsAny.getSectionStatus()).toBeObservable(cold('(a|)', {
|
||||
a: true
|
||||
a: true,
|
||||
}));
|
||||
});
|
||||
it('Should return FALSE if the identifier data is missing handle', () => {
|
||||
compAsAny.isLoadin = true;
|
||||
expect(compAsAny.getSectionStatus()).toBeObservable(cold('(a|)', {
|
||||
a: false
|
||||
a: false,
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -251,7 +251,7 @@ describe('SubmissionSectionIdentifiersComponent test suite', () => {
|
||||
// declare a test component
|
||||
@Component({
|
||||
selector: 'ds-test-cmp',
|
||||
template: ``
|
||||
template: ``,
|
||||
})
|
||||
class TestComponent {
|
||||
|
||||
|
@@ -21,7 +21,7 @@ import { WorkspaceitemSectionIdentifiersObject } from '../../../core/submission/
|
||||
@Component({
|
||||
selector: 'ds-submission-section-identifiers',
|
||||
templateUrl: './section-identifiers.component.html',
|
||||
changeDetection: ChangeDetectionStrategy.Default
|
||||
changeDetection: ChangeDetectionStrategy.Default,
|
||||
})
|
||||
|
||||
@renderSectionFor(SectionsType.Identifiers)
|
||||
|
@@ -26,7 +26,7 @@ import { SectionsType } from '../sections-type';
|
||||
import {
|
||||
mockLicenseParsedErrors,
|
||||
mockSubmissionCollectionId,
|
||||
mockSubmissionId
|
||||
mockSubmissionId,
|
||||
} from '../../../shared/mocks/submission.mock';
|
||||
import { FormComponent } from '../../../shared/form/form.component';
|
||||
import { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder/json-patch-operation-path-combiner';
|
||||
@@ -48,9 +48,9 @@ const mockCollection = Object.assign(new Collection(), {
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'Community 1-Collection 1'
|
||||
value: 'Community 1-Collection 1',
|
||||
}],
|
||||
license: createSuccessfulRemoteDataObject$(Object.assign(new License(), { text: licenseText }))
|
||||
license: createSuccessfulRemoteDataObject$(Object.assign(new License(), { text: licenseText })),
|
||||
});
|
||||
|
||||
function getMockSubmissionFormsConfigService(): SubmissionFormsConfigDataService {
|
||||
@@ -58,7 +58,7 @@ function getMockSubmissionFormsConfigService(): SubmissionFormsConfigDataService
|
||||
getConfigAll: jasmine.createSpy('getConfigAll'),
|
||||
getConfigByHref: jasmine.createSpy('getConfigByHref'),
|
||||
getConfigByName: jasmine.createSpy('getConfigByName'),
|
||||
getConfigBySearch: jasmine.createSpy('getConfigBySearch')
|
||||
getConfigBySearch: jasmine.createSpy('getConfigBySearch'),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -68,13 +68,13 @@ const sectionObject: SectionDataObject = {
|
||||
data: {
|
||||
url: null,
|
||||
acceptanceDate: null,
|
||||
granted: false
|
||||
granted: false,
|
||||
},
|
||||
errorsToShow: [],
|
||||
serverValidationErrors: [],
|
||||
header: 'submit.progressbar.describe.license',
|
||||
id: 'license',
|
||||
sectionType: SectionsType.License
|
||||
sectionType: SectionsType.License,
|
||||
};
|
||||
|
||||
const dynamicFormControlEvent: DynamicFormControlEvent = {
|
||||
@@ -83,7 +83,7 @@ const dynamicFormControlEvent: DynamicFormControlEvent = {
|
||||
control: null,
|
||||
group: null,
|
||||
model: null,
|
||||
type: DynamicFormControlEventType.Change
|
||||
type: DynamicFormControlEventType.Change,
|
||||
};
|
||||
|
||||
describe('SubmissionSectionLicenseComponent test suite', () => {
|
||||
@@ -108,7 +108,7 @@ describe('SubmissionSectionLicenseComponent test suite', () => {
|
||||
|
||||
const mockCollectionDataService = jasmine.createSpyObj('CollectionDataService', {
|
||||
findById: jasmine.createSpy('findById'),
|
||||
findByHref: jasmine.createSpy('findByHref')
|
||||
findByHref: jasmine.createSpy('findByHref'),
|
||||
});
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
@@ -118,12 +118,12 @@ describe('SubmissionSectionLicenseComponent test suite', () => {
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
TranslateModule.forRoot()
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [
|
||||
FormComponent,
|
||||
SubmissionSectionLicenseComponent,
|
||||
TestComponent
|
||||
TestComponent,
|
||||
],
|
||||
providers: [
|
||||
{ provide: CollectionDataService, useValue: mockCollectionDataService },
|
||||
@@ -139,9 +139,9 @@ describe('SubmissionSectionLicenseComponent test suite', () => {
|
||||
{ provide: 'submissionIdProvider', useValue: submissionId },
|
||||
ChangeDetectorRef,
|
||||
FormBuilderService,
|
||||
SubmissionSectionLicenseComponent
|
||||
SubmissionSectionLicenseComponent,
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
}).compileComponents().then();
|
||||
}));
|
||||
|
||||
@@ -213,7 +213,7 @@ describe('SubmissionSectionLicenseComponent test suite', () => {
|
||||
expect(model.value).toBeFalsy();
|
||||
expect(comp.licenseText$).toBeObservable(cold('(ab|)', {
|
||||
a: '',
|
||||
b: licenseText
|
||||
b: licenseText,
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -221,7 +221,7 @@ describe('SubmissionSectionLicenseComponent test suite', () => {
|
||||
comp.sectionData.data = {
|
||||
url: 'url',
|
||||
acceptanceDate: Date.now(),
|
||||
granted: true
|
||||
granted: true,
|
||||
} as any;
|
||||
|
||||
spyOn(compAsAny, 'getSectionStatus');
|
||||
@@ -235,7 +235,7 @@ describe('SubmissionSectionLicenseComponent test suite', () => {
|
||||
expect(model.value).toBeTruthy();
|
||||
expect(comp.licenseText$).toBeObservable(cold('(ab|)', {
|
||||
a: '',
|
||||
b: licenseText
|
||||
b: licenseText,
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -283,7 +283,7 @@ describe('SubmissionSectionLicenseComponent test suite', () => {
|
||||
comp.sectionData.data = {
|
||||
url: 'url',
|
||||
acceptanceDate: Date.now(),
|
||||
granted: true
|
||||
granted: true,
|
||||
} as any;
|
||||
|
||||
comp.onSectionInit();
|
||||
@@ -325,7 +325,7 @@ describe('SubmissionSectionLicenseComponent test suite', () => {
|
||||
// declare a test component
|
||||
@Component({
|
||||
selector: 'ds-test-cmp',
|
||||
template: ``
|
||||
template: ``,
|
||||
})
|
||||
class TestComponent {
|
||||
|
||||
|
@@ -3,7 +3,7 @@ import {
|
||||
DynamicCheckboxModel,
|
||||
DynamicFormControlEvent,
|
||||
DynamicFormControlModel,
|
||||
DynamicFormLayout
|
||||
DynamicFormLayout,
|
||||
} from '@ng-dynamic-forms/core';
|
||||
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
@@ -182,7 +182,7 @@ export class SubmissionSectionLicenseComponent extends SectionModelComponent {
|
||||
this.sectionService.dispatchRemoveSectionErrors(this.submissionId, this.sectionData.id);
|
||||
}
|
||||
this.changeDetectorRef.detectChanges();
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -5,9 +5,9 @@ export const SECTION_LICENSE_FORM_LAYOUT = {
|
||||
element: {
|
||||
container: 'custom-control custom-checkbox pl-1',
|
||||
control: 'custom-control-input',
|
||||
label: 'custom-control-label pt-1'
|
||||
}
|
||||
}
|
||||
label: 'custom-control-label pt-1',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const SECTION_LICENSE_FORM_MODEL = [
|
||||
@@ -17,12 +17,12 @@ export const SECTION_LICENSE_FORM_MODEL = [
|
||||
required: true,
|
||||
value: false,
|
||||
validators: {
|
||||
required: null
|
||||
required: null,
|
||||
},
|
||||
errorMessages: {
|
||||
required: 'submission.sections.license.required',
|
||||
notgranted: 'submission.sections.license.notgranted'
|
||||
notgranted: 'submission.sections.license.notgranted',
|
||||
},
|
||||
type: 'CHECKBOX',
|
||||
}
|
||||
},
|
||||
];
|
||||
|
@@ -16,7 +16,7 @@ export interface SectionDataModel {
|
||||
*/
|
||||
@Component({
|
||||
selector: 'ds-section-model',
|
||||
template: ''
|
||||
template: '',
|
||||
})
|
||||
export abstract class SectionModelComponent implements OnDestroy, OnInit, SectionDataModel {
|
||||
protected abstract sectionService: SectionsService;
|
||||
|
@@ -16,7 +16,7 @@ import { SubmissionSectionError } from '../objects/submission-section-error.mode
|
||||
*/
|
||||
@Directive({
|
||||
selector: '[dsSection]',
|
||||
exportAs: 'sectionRef'
|
||||
exportAs: 'sectionRef',
|
||||
})
|
||||
export class SectionsDirective implements OnDestroy, OnInit {
|
||||
|
||||
@@ -140,7 +140,7 @@ export class SectionsDirective implements OnDestroy, OnInit {
|
||||
this.submissionService.dispatchSave(this.submissionId);
|
||||
}
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
this.enabled = this.sectionService.isSectionEnabled(this.submissionId, this.sectionId);
|
||||
|
@@ -18,7 +18,7 @@ import {
|
||||
mockSectionsData,
|
||||
mockSectionsErrors,
|
||||
mockSubmissionState,
|
||||
mockSubmissionStateWithoutUpload
|
||||
mockSubmissionStateWithoutUpload,
|
||||
} from '../../shared/mocks/submission.mock';
|
||||
import {
|
||||
DisableSectionAction,
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
InertSectionErrorsAction,
|
||||
RemoveSectionErrorsAction,
|
||||
SectionStatusChangeAction,
|
||||
UpdateSectionDataAction
|
||||
UpdateSectionDataAction,
|
||||
} from '../objects/submission-objects.actions';
|
||||
import { FormClearErrorsAction } from '../../shared/form/form.actions';
|
||||
import parseSectionErrors from '../utils/parseSectionErrors';
|
||||
@@ -56,7 +56,7 @@ describe('SectionsService test suite', () => {
|
||||
|
||||
const store: any = jasmine.createSpyObj('store', {
|
||||
dispatch: jasmine.createSpy('dispatch'),
|
||||
select: jasmine.createSpy('select')
|
||||
select: jasmine.createSpy('select'),
|
||||
});
|
||||
|
||||
const formService: any = getMockFormService();
|
||||
@@ -68,9 +68,9 @@ describe('SectionsService test suite', () => {
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: TranslateLoaderMock
|
||||
}
|
||||
})
|
||||
useClass: TranslateLoaderMock,
|
||||
},
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
{ provide: NotificationsService, useClass: NotificationsServiceStub },
|
||||
@@ -79,8 +79,8 @@ describe('SectionsService test suite', () => {
|
||||
{ provide: TranslateService, useValue: getMockTranslateService() },
|
||||
{ provide: Store, useValue: store },
|
||||
{ provide: FormService, useValue: formService },
|
||||
SectionsService
|
||||
]
|
||||
SectionsService,
|
||||
],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
@@ -161,7 +161,7 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf(sectionData[sectionId]));
|
||||
|
||||
const expected = cold('(b|)', {
|
||||
b: sectionData[sectionId]
|
||||
b: sectionData[sectionId],
|
||||
});
|
||||
|
||||
expect(service.getSectionData(submissionId, sectionId, SectionsType.SubmissionForm)).toBeObservable(expected);
|
||||
@@ -173,7 +173,7 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf(sectionErrors[sectionId]));
|
||||
|
||||
const expected = cold('(b|)', {
|
||||
b: sectionErrors[sectionId]
|
||||
b: sectionErrors[sectionId],
|
||||
});
|
||||
|
||||
expect(service.getSectionErrors(submissionId, sectionId)).toBeObservable(expected);
|
||||
@@ -185,7 +185,7 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf(sectionState));
|
||||
|
||||
const expected = cold('(b|)', {
|
||||
b: sectionState
|
||||
b: sectionState,
|
||||
});
|
||||
|
||||
expect(service.getSectionState(submissionId, sectionId, SectionsType.SubmissionForm)).toBeObservable(expected);
|
||||
@@ -197,7 +197,7 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf({ isValid: false }));
|
||||
|
||||
let expected = cold('(b|)', {
|
||||
b: false
|
||||
b: false,
|
||||
});
|
||||
|
||||
expect(service.isSectionValid(submissionId, sectionId)).toBeObservable(expected);
|
||||
@@ -205,7 +205,7 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf({ isValid: true }));
|
||||
|
||||
expected = cold('(b|)', {
|
||||
b: true
|
||||
b: true,
|
||||
});
|
||||
|
||||
expect(service.isSectionValid(submissionId, sectionId)).toBeObservable(expected);
|
||||
@@ -217,7 +217,7 @@ describe('SectionsService test suite', () => {
|
||||
submissionServiceStub.getActiveSectionId.and.returnValue(observableOf(sectionId));
|
||||
|
||||
let expected = cold('(b|)', {
|
||||
b: true
|
||||
b: true,
|
||||
});
|
||||
|
||||
expect(service.isSectionActive(submissionId, sectionId)).toBeObservable(expected);
|
||||
@@ -225,7 +225,7 @@ describe('SectionsService test suite', () => {
|
||||
submissionServiceStub.getActiveSectionId.and.returnValue(observableOf('test'));
|
||||
|
||||
expected = cold('(b|)', {
|
||||
b: false
|
||||
b: false,
|
||||
});
|
||||
|
||||
expect(service.isSectionActive(submissionId, sectionId)).toBeObservable(expected);
|
||||
@@ -237,7 +237,7 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf({ enabled: false }));
|
||||
|
||||
let expected = cold('(b|)', {
|
||||
b: false
|
||||
b: false,
|
||||
});
|
||||
|
||||
expect(service.isSectionEnabled(submissionId, sectionId)).toBeObservable(expected);
|
||||
@@ -245,7 +245,7 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf({ enabled: true }));
|
||||
|
||||
expected = cold('(b|)', {
|
||||
b: true
|
||||
b: true,
|
||||
});
|
||||
|
||||
expect(service.isSectionEnabled(submissionId, sectionId)).toBeObservable(expected);
|
||||
@@ -257,12 +257,12 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf({
|
||||
visibility: {
|
||||
main: null,
|
||||
other: 'READONLY'
|
||||
}
|
||||
other: 'READONLY',
|
||||
},
|
||||
}));
|
||||
|
||||
const expected = cold('(b|)', {
|
||||
b: true
|
||||
b: true,
|
||||
});
|
||||
|
||||
expect(service.isSectionReadOnly(submissionId, sectionId, SubmissionScopeType.WorkflowItem)).toBeObservable(expected);
|
||||
@@ -272,12 +272,12 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf({
|
||||
visibility: {
|
||||
main: null,
|
||||
other: 'READONLY'
|
||||
}
|
||||
other: 'READONLY',
|
||||
},
|
||||
}));
|
||||
|
||||
const expected = cold('(b|)', {
|
||||
b: false
|
||||
b: false,
|
||||
});
|
||||
|
||||
expect(service.isSectionReadOnly(submissionId, sectionId, SubmissionScopeType.WorkspaceItem)).toBeObservable(expected);
|
||||
@@ -285,11 +285,11 @@ describe('SectionsService test suite', () => {
|
||||
|
||||
it('should return an observable of false when it\'s not a readonly section', () => {
|
||||
store.select.and.returnValue(observableOf({
|
||||
visibility: null
|
||||
visibility: null,
|
||||
}));
|
||||
|
||||
const expected = cold('(b|)', {
|
||||
b: false
|
||||
b: false,
|
||||
});
|
||||
|
||||
expect(service.isSectionReadOnly(submissionId, sectionId, SubmissionScopeType.WorkflowItem)).toBeObservable(expected);
|
||||
@@ -301,7 +301,7 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf(submissionState));
|
||||
|
||||
const expected = cold('(b|)', {
|
||||
b: true
|
||||
b: true,
|
||||
});
|
||||
|
||||
expect(service.isSectionAvailable(submissionId, sectionId)).toBeObservable(expected);
|
||||
@@ -311,7 +311,7 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf(submissionState));
|
||||
|
||||
const expected = cold('(b|)', {
|
||||
b: false
|
||||
b: false,
|
||||
});
|
||||
|
||||
expect(service.isSectionAvailable(submissionId, 'test')).toBeObservable(expected);
|
||||
@@ -323,7 +323,7 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf(submissionState));
|
||||
|
||||
const expected = cold('(b|)', {
|
||||
b: true
|
||||
b: true,
|
||||
});
|
||||
|
||||
expect(service.isSectionTypeAvailable(submissionId, SectionsType.Upload)).toBeObservable(expected);
|
||||
@@ -333,7 +333,7 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf(submissionStateWithoutUpload));
|
||||
|
||||
const expected = cold('(b|)', {
|
||||
b: false
|
||||
b: false,
|
||||
});
|
||||
|
||||
expect(service.isSectionAvailable(submissionId, SectionsType.Upload)).toBeObservable(expected);
|
||||
@@ -345,7 +345,7 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf(submissionState));
|
||||
|
||||
const expected = cold('(b|)', {
|
||||
b: true
|
||||
b: true,
|
||||
});
|
||||
|
||||
expect(service.isSectionType(submissionId, 'upload', SectionsType.Upload)).toBeObservable(expected);
|
||||
@@ -355,7 +355,7 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf(submissionState));
|
||||
|
||||
const expected = cold('(b|)', {
|
||||
b: false
|
||||
b: false,
|
||||
});
|
||||
|
||||
expect(service.isSectionType(submissionId, sectionId, SectionsType.Upload)).toBeObservable(expected);
|
||||
@@ -365,7 +365,7 @@ describe('SectionsService test suite', () => {
|
||||
store.select.and.returnValue(observableOf(submissionState));
|
||||
|
||||
const expected = cold('(b|)', {
|
||||
b: false
|
||||
b: false,
|
||||
});
|
||||
|
||||
expect(service.isSectionType(submissionId, 'no-such-id', SectionsType.Upload)).toBeObservable(expected);
|
||||
@@ -396,7 +396,7 @@ describe('SectionsService test suite', () => {
|
||||
|
||||
const error: SubmissionSectionError = {
|
||||
path: 'test',
|
||||
message: 'message test'
|
||||
message: 'message test',
|
||||
};
|
||||
service.setSectionError(submissionId, sectionId, error);
|
||||
|
||||
@@ -446,10 +446,10 @@ describe('SectionsService test suite', () => {
|
||||
rows: [{
|
||||
fields: [{
|
||||
selectableMetadata: [{
|
||||
metadata: 'dc.contributor.author'
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
metadata: 'dc.contributor.author',
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
};
|
||||
|
||||
const expectedConfiguredMetadata = [ 'dc.contributor.author' ];
|
||||
|
@@ -18,17 +18,17 @@ import {
|
||||
RemoveSectionErrorsAction,
|
||||
SectionStatusChangeAction,
|
||||
SetSectionFormId,
|
||||
UpdateSectionDataAction
|
||||
UpdateSectionDataAction,
|
||||
} from '../objects/submission-objects.actions';
|
||||
import {
|
||||
SubmissionObjectEntry
|
||||
SubmissionObjectEntry,
|
||||
} from '../objects/submission-objects.reducer';
|
||||
import {
|
||||
submissionObjectFromIdSelector,
|
||||
submissionSectionDataFromIdSelector,
|
||||
submissionSectionErrorsFromIdSelector,
|
||||
submissionSectionFromIdSelector,
|
||||
submissionSectionServerErrorsFromIdSelector
|
||||
submissionSectionServerErrorsFromIdSelector,
|
||||
} from '../selectors';
|
||||
import { SubmissionScopeType } from '../../core/submission/submission-scope-type';
|
||||
import parseSectionErrorPaths, { SectionErrorPath } from '../utils/parseSectionErrorPaths';
|
||||
@@ -197,12 +197,12 @@ export class SectionsService {
|
||||
const sectionErrors = formErrors
|
||||
.map((error) => ({
|
||||
path: pathCombiner.getPath(error.fieldId.replace(/\_/g, '.')).path,
|
||||
message: error.message
|
||||
message: error.message,
|
||||
} as SubmissionSectionError))
|
||||
.filter((sectionError: SubmissionSectionError) => findIndex(state.errorsToShow, { path: sectionError.path }) === -1);
|
||||
return [...state.errorsToShow, ...sectionErrors];
|
||||
})
|
||||
))
|
||||
}),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -257,13 +257,13 @@ export class SectionsService {
|
||||
map((sectionState: SubmissionSectionObject) => {
|
||||
if (hasValue(sectionState.data) && sectionType === SectionsType.SubmissionForm) {
|
||||
return Object.assign({}, sectionState, {
|
||||
data: normalizeSectionData(sectionState.data)
|
||||
data: normalizeSectionData(sectionState.data),
|
||||
});
|
||||
} else {
|
||||
return sectionState;
|
||||
}
|
||||
}),
|
||||
distinctUntilChanged()
|
||||
distinctUntilChanged(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ export class SectionsService {
|
||||
this.store.dispatch(new EnableSectionAction(submissionId, sectionId));
|
||||
const config: ScrollToConfigOptions = {
|
||||
target: sectionId,
|
||||
offset: -70
|
||||
offset: -70,
|
||||
};
|
||||
|
||||
this.scrollToService.scrollTo(config);
|
||||
@@ -449,7 +449,7 @@ export class SectionsService {
|
||||
data: WorkspaceitemSectionDataType,
|
||||
errorsToShow: SubmissionSectionError[] = [],
|
||||
serverValidationErrors: SubmissionSectionError[] = [],
|
||||
metadata?: string[]
|
||||
metadata?: string[],
|
||||
) {
|
||||
if (isNotEmpty(data)) {
|
||||
const isAvailable$ = this.isSectionAvailable(submissionId, sectionId);
|
||||
|
@@ -20,12 +20,12 @@ describe('ContentAccordionComponent', () => {
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: TranslateLoaderMock
|
||||
}
|
||||
useClass: TranslateLoaderMock,
|
||||
},
|
||||
}),
|
||||
NgbCollapseModule
|
||||
NgbCollapseModule,
|
||||
],
|
||||
declarations: [ContentAccordionComponent]
|
||||
declarations: [ContentAccordionComponent],
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
@@ -8,7 +8,7 @@ import { PermittedVersions } from '../../../../core/submission/models/sherpa-pol
|
||||
@Component({
|
||||
selector: 'ds-content-accordion',
|
||||
templateUrl: './content-accordion.component.html',
|
||||
styleUrls: ['./content-accordion.component.scss']
|
||||
styleUrls: ['./content-accordion.component.scss'],
|
||||
})
|
||||
export class ContentAccordionComponent {
|
||||
/**
|
||||
|
@@ -19,11 +19,11 @@ describe('MetadataInformationComponent', () => {
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: TranslateLoaderMock
|
||||
}
|
||||
useClass: TranslateLoaderMock,
|
||||
},
|
||||
}),
|
||||
],
|
||||
declarations: [MetadataInformationComponent]
|
||||
declarations: [MetadataInformationComponent],
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
@@ -8,7 +8,7 @@ import { Metadata } from '../../../../core/submission/models/sherpa-policies-det
|
||||
@Component({
|
||||
selector: 'ds-metadata-information',
|
||||
templateUrl: './metadata-information.component.html',
|
||||
styleUrls: ['./metadata-information.component.scss']
|
||||
styleUrls: ['./metadata-information.component.scss'],
|
||||
})
|
||||
export class MetadataInformationComponent {
|
||||
/**
|
||||
|
@@ -19,11 +19,11 @@ describe('PublicationInformationComponent', () => {
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: TranslateLoaderMock
|
||||
}
|
||||
useClass: TranslateLoaderMock,
|
||||
},
|
||||
}),
|
||||
],
|
||||
declarations: [PublicationInformationComponent]
|
||||
declarations: [PublicationInformationComponent],
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
@@ -8,7 +8,7 @@ import { Journal } from '../../../../core/submission/models/sherpa-policies-deta
|
||||
@Component({
|
||||
selector: 'ds-publication-information',
|
||||
templateUrl: './publication-information.component.html',
|
||||
styleUrls: ['./publication-information.component.scss']
|
||||
styleUrls: ['./publication-information.component.scss'],
|
||||
})
|
||||
export class PublicationInformationComponent {
|
||||
/**
|
||||
|
@@ -18,8 +18,8 @@ describe('PublisherPolicyComponent', () => {
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: TranslateLoaderMock
|
||||
}
|
||||
useClass: TranslateLoaderMock,
|
||||
},
|
||||
}),
|
||||
],
|
||||
declarations: [PublisherPolicyComponent],
|
||||
|
@@ -9,7 +9,7 @@ import { AlertType } from '../../../../shared/alert/aletr-type';
|
||||
@Component({
|
||||
selector: 'ds-publisher-policy',
|
||||
templateUrl: './publisher-policy.component.html',
|
||||
styleUrls: ['./publisher-policy.component.scss']
|
||||
styleUrls: ['./publisher-policy.component.scss'],
|
||||
})
|
||||
export class PublisherPolicyComponent {
|
||||
|
||||
|
@@ -45,7 +45,7 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => {
|
||||
errorsToShow: [],
|
||||
serverValidationErrors: [],
|
||||
isLoading: false,
|
||||
isValid: true
|
||||
isValid: true,
|
||||
};
|
||||
|
||||
describe('SubmissionSectionSherpaPoliciesComponent', () => {
|
||||
@@ -58,11 +58,11 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => {
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: TranslateLoaderMock
|
||||
}
|
||||
useClass: TranslateLoaderMock,
|
||||
},
|
||||
}),
|
||||
NgbCollapseModule,
|
||||
SharedModule
|
||||
SharedModule,
|
||||
],
|
||||
declarations: [SubmissionSectionSherpaPoliciesComponent],
|
||||
providers: [
|
||||
@@ -72,7 +72,7 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => {
|
||||
{ provide: Store, useValue: storeStub },
|
||||
{ provide: 'sectionDataProvider', useValue: sectionData },
|
||||
{ provide: 'submissionIdProvider', useValue: '1508' },
|
||||
]
|
||||
],
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
@@ -6,7 +6,7 @@ import { BehaviorSubject, Observable, of, Subscription } from 'rxjs';
|
||||
import { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder/json-patch-operation-path-combiner';
|
||||
import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder';
|
||||
import {
|
||||
WorkspaceitemSectionSherpaPoliciesObject
|
||||
WorkspaceitemSectionSherpaPoliciesObject,
|
||||
} from '../../../core/submission/models/workspaceitem-section-sherpa-policies.model';
|
||||
import { renderSectionFor } from '../sections-decorator';
|
||||
import { SectionsType } from '../sections-type';
|
||||
@@ -22,7 +22,7 @@ import { hasValue, isEmpty } from '../../../shared/empty.util';
|
||||
@Component({
|
||||
selector: 'ds-section-sherpa-policies',
|
||||
templateUrl: './section-sherpa-policies.component.html',
|
||||
styleUrls: ['./section-sherpa-policies.component.scss']
|
||||
styleUrls: ['./section-sherpa-policies.component.scss'],
|
||||
})
|
||||
@renderSectionFor(SectionsType.SherpaPolicies)
|
||||
export class SubmissionSectionSherpaPoliciesComponent extends SectionModelComponent {
|
||||
@@ -95,7 +95,7 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon
|
||||
this.sectionService.getSectionData(this.submissionId, this.sectionData.id, this.sectionData.sectionType)
|
||||
.subscribe((sherpaPolicies: WorkspaceitemSectionSherpaPoliciesObject) => {
|
||||
this.sherpaPoliciesData$.next(sherpaPolicies);
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,7 @@ import {
|
||||
DynamicFormArrayModel,
|
||||
DynamicFormControlEvent,
|
||||
DynamicFormGroupModel,
|
||||
DynamicSelectModel
|
||||
DynamicSelectModel,
|
||||
} from '@ng-dynamic-forms/core';
|
||||
|
||||
import { FormBuilderService } from '../../../../../shared/form/builder/form-builder.service';
|
||||
@@ -32,18 +32,18 @@ import { createTestComponent } from '../../../../../shared/testing/utils.test';
|
||||
import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { JsonPatchOperationsBuilder } from '../../../../../core/json-patch/builder/json-patch-operations-builder';
|
||||
import {
|
||||
SubmissionJsonPatchOperationsServiceStub
|
||||
SubmissionJsonPatchOperationsServiceStub,
|
||||
} from '../../../../../shared/testing/submission-json-patch-operations-service.stub';
|
||||
import {
|
||||
SubmissionJsonPatchOperationsService
|
||||
SubmissionJsonPatchOperationsService,
|
||||
} from '../../../../../core/submission/submission-json-patch-operations.service';
|
||||
import { SectionUploadService } from '../../section-upload.service';
|
||||
import { getMockSectionUploadService } from '../../../../../shared/mocks/section-upload.service.mock';
|
||||
import {
|
||||
FormFieldMetadataValueObject
|
||||
FormFieldMetadataValueObject,
|
||||
} from '../../../../../shared/form/builder/models/form-field-metadata-value.model';
|
||||
import {
|
||||
JsonPatchOperationPathCombiner
|
||||
JsonPatchOperationPathCombiner,
|
||||
} from '../../../../../core/json-patch/builder/json-patch-operation-path-combiner';
|
||||
import { dateToISOFormat } from '../../../../../shared/date.util';
|
||||
import { of } from 'rxjs';
|
||||
@@ -87,12 +87,12 @@ describe('SubmissionSectionUploadFileEditComponent test suite', () => {
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
TranslateModule.forRoot()
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [
|
||||
FormComponent,
|
||||
SubmissionSectionUploadFileEditComponent,
|
||||
TestComponent
|
||||
TestComponent,
|
||||
],
|
||||
providers: [
|
||||
{ provide: FormService, useValue: getMockFormService() },
|
||||
@@ -107,7 +107,7 @@ describe('SubmissionSectionUploadFileEditComponent test suite', () => {
|
||||
NgbActiveModal,
|
||||
FormComponent,
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
}).compileComponents().then();
|
||||
}));
|
||||
|
||||
@@ -201,7 +201,7 @@ describe('SubmissionSectionUploadFileEditComponent test suite', () => {
|
||||
control: null,
|
||||
group: null,
|
||||
model: {id: 'name'} as any,
|
||||
type: 'change'
|
||||
type: 'change',
|
||||
};
|
||||
spyOn(comp, 'setOptions');
|
||||
|
||||
@@ -259,10 +259,10 @@ describe('SubmissionSectionUploadFileEditComponent test suite', () => {
|
||||
Object.assign(mockSubmissionObject, {
|
||||
sections: {
|
||||
upload: {
|
||||
files: mockUploadFiles
|
||||
}
|
||||
}
|
||||
})
|
||||
files: mockUploadFiles,
|
||||
},
|
||||
},
|
||||
}),
|
||||
];
|
||||
operationsService.jsonPatchByResourceID.and.returnValue(of(response));
|
||||
|
||||
@@ -278,21 +278,21 @@ describe('SubmissionSectionUploadFileEditComponent test suite', () => {
|
||||
expect(operationsBuilder.add).toHaveBeenCalledWith(
|
||||
pathCombiner.getPath(path),
|
||||
mockFileFormData.metadata['dc.title'],
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
path = 'metadata/dc.description';
|
||||
expect(operationsBuilder.add).toHaveBeenCalledWith(
|
||||
pathCombiner.getPath(path),
|
||||
mockFileFormData.metadata['dc.description'],
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
path = 'accessConditions';
|
||||
expect(operationsBuilder.add).toHaveBeenCalledWith(
|
||||
pathCombiner.getPath(path),
|
||||
accessConditionsToSave,
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
expect(uploadService.updateFileData).toHaveBeenCalledWith(submissionId, sectionId, mockUploadFiles[0].uuid, mockUploadFiles[0]);
|
||||
@@ -317,7 +317,7 @@ describe('SubmissionSectionUploadFileEditComponent test suite', () => {
|
||||
// declare a test component
|
||||
@Component({
|
||||
selector: 'ds-test-cmp',
|
||||
template: ``
|
||||
template: ``,
|
||||
})
|
||||
class TestComponent {
|
||||
|
||||
|
@@ -10,11 +10,11 @@ import {
|
||||
DynamicFormGroupModel,
|
||||
DynamicSelectModel,
|
||||
MATCH_ENABLED,
|
||||
OR_OPERATOR
|
||||
OR_OPERATOR,
|
||||
} from '@ng-dynamic-forms/core';
|
||||
|
||||
import {
|
||||
WorkspaceitemSectionUploadFileObject
|
||||
WorkspaceitemSectionUploadFileObject,
|
||||
} from '../../../../../core/submission/models/workspaceitem-section-upload-file.model';
|
||||
import { FormBuilderService } from '../../../../../shared/form/builder/form-builder.service';
|
||||
import {
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
BITSTREAM_FORM_ACCESS_CONDITION_TYPE_CONFIG,
|
||||
BITSTREAM_FORM_ACCESS_CONDITION_TYPE_LAYOUT,
|
||||
BITSTREAM_METADATA_FORM_GROUP_CONFIG,
|
||||
BITSTREAM_METADATA_FORM_GROUP_LAYOUT
|
||||
BITSTREAM_METADATA_FORM_GROUP_LAYOUT,
|
||||
} from './section-upload-file-edit.model';
|
||||
import { POLICY_DEFAULT_WITH_LIST } from '../../section-upload.component';
|
||||
import { hasNoValue, hasValue, isNotEmpty, isNotNull } from '../../../../../shared/empty.util';
|
||||
@@ -44,14 +44,14 @@ import { filter, mergeMap, take } from 'rxjs/operators';
|
||||
import { dateToISOFormat } from '../../../../../shared/date.util';
|
||||
import { SubmissionObject } from '../../../../../core/submission/models/submission-object.model';
|
||||
import {
|
||||
WorkspaceitemSectionUploadObject
|
||||
WorkspaceitemSectionUploadObject,
|
||||
} from '../../../../../core/submission/models/workspaceitem-section-upload.model';
|
||||
import { JsonPatchOperationsBuilder } from '../../../../../core/json-patch/builder/json-patch-operations-builder';
|
||||
import {
|
||||
SubmissionJsonPatchOperationsService
|
||||
SubmissionJsonPatchOperationsService,
|
||||
} from '../../../../../core/submission/submission-json-patch-operations.service';
|
||||
import {
|
||||
JsonPatchOperationPathCombiner
|
||||
JsonPatchOperationPathCombiner,
|
||||
} from '../../../../../core/json-patch/builder/json-patch-operation-path-combiner';
|
||||
import { SectionUploadService } from '../../section-upload.service';
|
||||
import { Subscription } from 'rxjs';
|
||||
@@ -202,7 +202,7 @@ implements OnInit, OnDestroy {
|
||||
metadataModel.value = {
|
||||
year: date.getUTCFullYear(),
|
||||
month: date.getUTCMonth() + 1,
|
||||
day: date.getUTCDate()
|
||||
day: date.getUTCDate(),
|
||||
};
|
||||
} else {
|
||||
metadataModel.value = accessCondition[key];
|
||||
@@ -287,8 +287,8 @@ implements OnInit, OnDestroy {
|
||||
const configForm = Object.assign({}, this.configMetadataForm, {
|
||||
fields: Object.assign([], this.configMetadataForm.rows[0].fields[0], [
|
||||
this.configMetadataForm.rows[0].fields[0],
|
||||
configDescr
|
||||
])
|
||||
configDescr,
|
||||
]),
|
||||
});
|
||||
const formModel: DynamicFormControlModel[] = [];
|
||||
const metadataGroupModelConfig = Object.assign({}, BITSTREAM_METADATA_FORM_GROUP_CONFIG);
|
||||
@@ -297,7 +297,7 @@ implements OnInit, OnDestroy {
|
||||
configForm,
|
||||
this.collectionId,
|
||||
this.fileData.metadata,
|
||||
this.submissionService.getSubmissionScope()
|
||||
this.submissionService.getSubmissionScope(),
|
||||
);
|
||||
formModel.push(new DynamicFormGroupModel(metadataGroupModelConfig, BITSTREAM_METADATA_FORM_GROUP_LAYOUT));
|
||||
const accessConditionTypeModelConfig = Object.assign({}, BITSTREAM_FORM_ACCESS_CONDITION_TYPE_CONFIG);
|
||||
@@ -309,8 +309,8 @@ implements OnInit, OnDestroy {
|
||||
accessConditionTypeOptions.push(
|
||||
{
|
||||
label: accessCondition.name,
|
||||
value: accessCondition.name
|
||||
}
|
||||
value: accessCondition.name,
|
||||
},
|
||||
);
|
||||
}
|
||||
accessConditionTypeModelConfig.options = accessConditionTypeOptions;
|
||||
@@ -329,7 +329,7 @@ implements OnInit, OnDestroy {
|
||||
maxStartDate = {
|
||||
year: min.getUTCFullYear(),
|
||||
month: min.getUTCMonth() + 1,
|
||||
day: min.getUTCDate()
|
||||
day: min.getUTCDate(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -340,7 +340,7 @@ implements OnInit, OnDestroy {
|
||||
maxEndDate = {
|
||||
year: max.getUTCFullYear(),
|
||||
month: max.getUTCMonth() + 1,
|
||||
day: max.getUTCDate()
|
||||
day: max.getUTCDate(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -378,7 +378,7 @@ implements OnInit, OnDestroy {
|
||||
// Number of access conditions blocks in form
|
||||
accessConditionsArrayConfig.initialCount = isNotEmpty(this.fileData.accessConditions) ? this.fileData.accessConditions.length : 1;
|
||||
formModel.push(
|
||||
new DynamicFormArrayModel(accessConditionsArrayConfig, BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_LAYOUT)
|
||||
new DynamicFormArrayModel(accessConditionsArrayConfig, BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_LAYOUT),
|
||||
);
|
||||
|
||||
}
|
||||
@@ -476,14 +476,14 @@ implements OnInit, OnDestroy {
|
||||
this.submissionId,
|
||||
this.pathCombiner.rootElement,
|
||||
this.pathCombiner.subRootElement);
|
||||
})
|
||||
}),
|
||||
).subscribe((result: SubmissionObject[]) => {
|
||||
if (result[0].sections[this.sectionId]) {
|
||||
const uploadSection = (result[0].sections[this.sectionId] as WorkspaceitemSectionUploadObject);
|
||||
Object.keys(uploadSection.files)
|
||||
.filter((key) => uploadSection.files[key].uuid === this.fileId)
|
||||
.forEach((key) => this.uploadService.updateFileData(
|
||||
this.submissionId, this.sectionId, this.fileId, uploadSection.files[key])
|
||||
this.submissionId, this.sectionId, this.fileId, uploadSection.files[key]),
|
||||
);
|
||||
}
|
||||
this.isSaving = false;
|
||||
|
@@ -10,28 +10,28 @@ import {
|
||||
|
||||
export const BITSTREAM_METADATA_FORM_GROUP_CONFIG: DynamicFormGroupModelConfig = {
|
||||
id: 'metadata',
|
||||
group: []
|
||||
group: [],
|
||||
};
|
||||
export const BITSTREAM_METADATA_FORM_GROUP_LAYOUT: DynamicFormControlLayout = {
|
||||
element: {
|
||||
container: 'form-group',
|
||||
label: 'col-form-label'
|
||||
label: 'col-form-label',
|
||||
},
|
||||
grid: {
|
||||
label: 'col-sm-3'
|
||||
}
|
||||
label: 'col-sm-3',
|
||||
},
|
||||
};
|
||||
export const BITSTREAM_ACCESS_CONDITION_GROUP_CONFIG: DynamicFormGroupModelConfig = {
|
||||
id: 'accessConditionGroup',
|
||||
group: []
|
||||
group: [],
|
||||
};
|
||||
|
||||
export const BITSTREAM_ACCESS_CONDITION_GROUP_LAYOUT: DynamicFormControlLayout = {
|
||||
element: {
|
||||
host: 'form-group access-condition-group col',
|
||||
container: 'pl-1 pr-1',
|
||||
control: 'form-row '
|
||||
}
|
||||
control: 'form-row ',
|
||||
},
|
||||
};
|
||||
|
||||
export const BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_CONFIG: DynamicFormArrayModelConfig = {
|
||||
@@ -41,20 +41,20 @@ export const BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_CONFIG: DynamicFormArrayMode
|
||||
export const BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_LAYOUT: DynamicFormControlLayout = {
|
||||
grid: {
|
||||
group: 'form-row pt-4',
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const BITSTREAM_FORM_ACCESS_CONDITION_TYPE_CONFIG: DynamicSelectModelConfig<any> = {
|
||||
id: 'name',
|
||||
label: 'submission.sections.upload.form.access-condition-label',
|
||||
hint: 'submission.sections.upload.form.access-condition-hint',
|
||||
options: []
|
||||
options: [],
|
||||
};
|
||||
export const BITSTREAM_FORM_ACCESS_CONDITION_TYPE_LAYOUT: DynamicFormControlLayout = {
|
||||
element: {
|
||||
host: 'col-12',
|
||||
label: 'col-form-label name-label'
|
||||
}
|
||||
label: 'col-form-label name-label',
|
||||
},
|
||||
};
|
||||
|
||||
export const BITSTREAM_FORM_ACCESS_CONDITION_START_DATE_CONFIG: DynamicDatePickerModelConfig = {
|
||||
@@ -68,24 +68,24 @@ export const BITSTREAM_FORM_ACCESS_CONDITION_START_DATE_CONFIG: DynamicDatePicke
|
||||
{
|
||||
match: MATCH_ENABLED,
|
||||
operator: OR_OPERATOR,
|
||||
when: []
|
||||
}
|
||||
when: [],
|
||||
},
|
||||
],
|
||||
required: true,
|
||||
validators: {
|
||||
required: null
|
||||
required: null,
|
||||
},
|
||||
errorMessages: {
|
||||
required: 'submission.sections.upload.form.date-required-from'
|
||||
}
|
||||
required: 'submission.sections.upload.form.date-required-from',
|
||||
},
|
||||
};
|
||||
export const BITSTREAM_FORM_ACCESS_CONDITION_START_DATE_LAYOUT: DynamicFormControlLayout = {
|
||||
element: {
|
||||
label: 'col-form-label'
|
||||
label: 'col-form-label',
|
||||
},
|
||||
grid: {
|
||||
host: 'col-6'
|
||||
}
|
||||
host: 'col-6',
|
||||
},
|
||||
};
|
||||
|
||||
export const BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_CONFIG: DynamicDatePickerModelConfig = {
|
||||
@@ -99,22 +99,22 @@ export const BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_CONFIG: DynamicDatePickerM
|
||||
{
|
||||
match: MATCH_ENABLED,
|
||||
operator: OR_OPERATOR,
|
||||
when: []
|
||||
}
|
||||
when: [],
|
||||
},
|
||||
],
|
||||
required: true,
|
||||
validators: {
|
||||
required: null
|
||||
required: null,
|
||||
},
|
||||
errorMessages: {
|
||||
required: 'submission.sections.upload.form.date-required-until'
|
||||
}
|
||||
required: 'submission.sections.upload.form.date-required-until',
|
||||
},
|
||||
};
|
||||
export const BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_LAYOUT: DynamicFormControlLayout = {
|
||||
element: {
|
||||
label: 'col-form-label'
|
||||
label: 'col-form-label',
|
||||
},
|
||||
grid: {
|
||||
host: 'col-6'
|
||||
}
|
||||
host: 'col-6',
|
||||
},
|
||||
};
|
||||
|
@@ -20,7 +20,7 @@ import {
|
||||
mockSubmissionCollectionId,
|
||||
mockSubmissionId,
|
||||
mockUploadConfigResponse,
|
||||
mockUploadFiles
|
||||
mockUploadFiles,
|
||||
} from '../../../../shared/mocks/submission.mock';
|
||||
|
||||
import { SubmissionService } from '../../../submission.service';
|
||||
@@ -38,10 +38,10 @@ const configMetadataFormMock = {
|
||||
fields: [{
|
||||
selectableMetadata: [
|
||||
{metadata: 'dc.title', label: null, closed: false},
|
||||
{metadata: 'dc.description', label: null, closed: false}
|
||||
]
|
||||
}]
|
||||
}]
|
||||
{metadata: 'dc.description', label: null, closed: false},
|
||||
],
|
||||
}],
|
||||
}],
|
||||
};
|
||||
|
||||
describe('SubmissionSectionUploadFileComponent test suite', () => {
|
||||
@@ -80,12 +80,12 @@ describe('SubmissionSectionUploadFileComponent test suite', () => {
|
||||
BrowserModule,
|
||||
CommonModule,
|
||||
NgbModule,
|
||||
TranslateModule.forRoot()
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [
|
||||
FileSizePipe,
|
||||
SubmissionSectionUploadFileComponent,
|
||||
TestComponent
|
||||
TestComponent,
|
||||
],
|
||||
providers: [
|
||||
{ provide: FormService, useValue: getMockFormService() },
|
||||
@@ -98,9 +98,9 @@ describe('SubmissionSectionUploadFileComponent test suite', () => {
|
||||
NgbModal,
|
||||
SubmissionSectionUploadFileComponent,
|
||||
SubmissionSectionUploadFileEditComponent,
|
||||
FormBuilderService
|
||||
FormBuilderService,
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
}).compileComponents().then();
|
||||
}));
|
||||
|
||||
@@ -237,7 +237,7 @@ describe('SubmissionSectionUploadFileComponent test suite', () => {
|
||||
// declare a test component
|
||||
@Component({
|
||||
selector: 'ds-test-cmp',
|
||||
template: ``
|
||||
template: ``,
|
||||
})
|
||||
class TestComponent {
|
||||
|
||||
|
@@ -6,12 +6,12 @@ import {
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
SimpleChanges,
|
||||
ViewChild
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
|
||||
import { BehaviorSubject, Subscription } from 'rxjs';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { DynamicFormControlModel, } from '@ng-dynamic-forms/core';
|
||||
import { DynamicFormControlModel } from '@ng-dynamic-forms/core';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
import { SectionUploadService } from '../section-upload.service';
|
||||
@@ -186,8 +186,8 @@ export class SubmissionSectionUploadFileComponent implements OnChanges, OnInit,
|
||||
.pipe(filter((bitstream) => isNotUndefined(bitstream)))
|
||||
.subscribe((bitstream) => {
|
||||
this.fileData = bitstream;
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ export class SubmissionSectionUploadFileComponent implements OnChanges, OnInit,
|
||||
this.processingDelete$.next(true);
|
||||
this.deleteFile();
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ export class SubmissionSectionUploadFileComponent implements OnChanges, OnInit,
|
||||
*/
|
||||
public getBitstream(): Bitstream {
|
||||
return Object.assign(new Bitstream(), {
|
||||
uuid: this.fileData.uuid
|
||||
uuid: this.fileData.uuid,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ export class SubmissionSectionUploadFileComponent implements OnChanges, OnInit,
|
||||
this.formMetadata.push(metadatum.metadata);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,7 @@ import { SubmissionSectionUploadFileComponent } from './section-upload-file.comp
|
||||
@Component({
|
||||
selector: 'ds-themed-submission-upload-section-file',
|
||||
styleUrls: [],
|
||||
templateUrl: '../../../../shared/theme-support/themed.component.html'
|
||||
templateUrl: '../../../../shared/theme-support/themed.component.html',
|
||||
})
|
||||
export class ThemedSubmissionSectionUploadFileComponent
|
||||
extends ThemedComponent<SubmissionSectionUploadFileComponent> {
|
||||
@@ -76,7 +76,7 @@ export class ThemedSubmissionSectionUploadFileComponent
|
||||
'fileIndex',
|
||||
'fileName',
|
||||
'sectionId',
|
||||
'submissionId'
|
||||
'submissionId',
|
||||
];
|
||||
|
||||
protected getComponentName(): string {
|
||||
|
@@ -21,18 +21,18 @@ describe('SubmissionSectionUploadFileViewComponent test suite', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot()
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [
|
||||
TruncatePipe,
|
||||
FormComponent,
|
||||
SubmissionSectionUploadFileViewComponent,
|
||||
TestComponent
|
||||
TestComponent,
|
||||
],
|
||||
providers: [
|
||||
SubmissionSectionUploadFileViewComponent
|
||||
SubmissionSectionUploadFileViewComponent,
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
}).compileComponents().then();
|
||||
}));
|
||||
|
||||
@@ -92,7 +92,7 @@ describe('SubmissionSectionUploadFileViewComponent test suite', () => {
|
||||
// declare a test component
|
||||
@Component({
|
||||
selector: 'ds-test-cmp',
|
||||
template: ``
|
||||
template: ``,
|
||||
})
|
||||
class TestComponent {
|
||||
|
||||
|
@@ -46,13 +46,13 @@ function getMockSubmissionUploadsConfigService(): SubmissionFormsConfigDataServi
|
||||
getConfigByHref: jasmine.createSpy('getConfigByHref'),
|
||||
getConfigByName: jasmine.createSpy('getConfigByName'),
|
||||
getConfigBySearch: jasmine.createSpy('getConfigBySearch'),
|
||||
findByHref: jasmine.createSpy('findByHref')
|
||||
findByHref: jasmine.createSpy('findByHref'),
|
||||
});
|
||||
}
|
||||
|
||||
function getMockCollectionDataService(): CollectionDataService {
|
||||
return jasmine.createSpyObj('CollectionDataService', {
|
||||
findById: jasmine.createSpy('findById')
|
||||
findById: jasmine.createSpy('findById'),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ function getMockGroupEpersonService(): GroupDataService {
|
||||
|
||||
function getMockResourcePolicyService(): ResourcePolicyDataService {
|
||||
return jasmine.createSpyObj('ResourcePolicyService', {
|
||||
findByHref: jasmine.createSpy('findByHref')
|
||||
findByHref: jasmine.createSpy('findByHref'),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -96,13 +96,13 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/upload',
|
||||
mandatory: true,
|
||||
data: {
|
||||
files: []
|
||||
files: [],
|
||||
},
|
||||
errorsToShow: [],
|
||||
serverValidationErrors: [],
|
||||
header: 'submit.progressbar.describe.upload',
|
||||
id: 'upload-id',
|
||||
sectionType: SectionsType.Upload
|
||||
sectionType: SectionsType.Upload,
|
||||
};
|
||||
submissionId = mockSubmissionId;
|
||||
collectionId = mockSubmissionCollectionId;
|
||||
@@ -114,18 +114,18 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'Community 1-Collection 1'
|
||||
value: 'Community 1-Collection 1',
|
||||
}],
|
||||
_links: {
|
||||
defaultAccessConditions: collectionId + '/defaultAccessConditions'
|
||||
}
|
||||
defaultAccessConditions: collectionId + '/defaultAccessConditions',
|
||||
},
|
||||
});
|
||||
|
||||
mockDefaultAccessCondition = Object.assign(new ResourcePolicy(), {
|
||||
name: null,
|
||||
groupUUID: '11cc35e5-a11d-4b64-b5b9-0052a5d15509',
|
||||
id: 20,
|
||||
uuid: 'resource-policy-20'
|
||||
uuid: 'resource-policy-20',
|
||||
});
|
||||
uploadsConfigService = getMockSubmissionUploadsConfigService();
|
||||
|
||||
@@ -145,18 +145,18 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
submissionServiceStub.getSubmissionObject.and.returnValue(observableOf(submissionState));
|
||||
|
||||
collectionDataService.findById.and.returnValue(createSuccessfulRemoteDataObject$(Object.assign(new Collection(), mockCollection, {
|
||||
defaultAccessConditions: createSuccessfulRemoteDataObject$(mockDefaultAccessCondition)
|
||||
defaultAccessConditions: createSuccessfulRemoteDataObject$(mockDefaultAccessCondition),
|
||||
})));
|
||||
|
||||
resourcePolicyService.findByHref.and.returnValue(createSuccessfulRemoteDataObject$(mockDefaultAccessCondition));
|
||||
|
||||
uploadsConfigService.findByHref.and.returnValue(createSuccessfulRemoteDataObject$(
|
||||
buildPaginatedList(new PageInfo(), [mockUploadConfigResponse as any]))
|
||||
buildPaginatedList(new PageInfo(), [mockUploadConfigResponse as any])),
|
||||
);
|
||||
|
||||
groupService.findById.and.returnValues(
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup)),
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup))
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup)),
|
||||
);
|
||||
|
||||
bitstreamService.getUploadedFileList.and.returnValue(observableOf([]));
|
||||
@@ -166,11 +166,11 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
imports: [
|
||||
BrowserModule,
|
||||
CommonModule,
|
||||
TranslateModule.forRoot()
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [
|
||||
SubmissionSectionUploadComponent,
|
||||
TestComponent
|
||||
TestComponent,
|
||||
],
|
||||
providers: [
|
||||
{ provide: CollectionDataService, useValue: collectionDataService },
|
||||
@@ -183,9 +183,9 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
{ provide: 'sectionDataProvider', useValue: sectionObject },
|
||||
{ provide: 'submissionIdProvider', useValue: submissionId },
|
||||
ChangeDetectorRef,
|
||||
SubmissionSectionUploadComponent
|
||||
SubmissionSectionUploadComponent,
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
}).compileComponents().then();
|
||||
}));
|
||||
|
||||
@@ -234,7 +234,7 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
submissionServiceStub.getSubmissionObject.and.returnValue(observableOf(submissionState));
|
||||
|
||||
collectionDataService.findById.and.returnValue(createSuccessfulRemoteDataObject$(Object.assign(new Collection(), mockCollection, {
|
||||
defaultAccessConditions: createSuccessfulRemoteDataObject$(mockDefaultAccessCondition)
|
||||
defaultAccessConditions: createSuccessfulRemoteDataObject$(mockDefaultAccessCondition),
|
||||
})));
|
||||
|
||||
resourcePolicyService.findByHref.and.returnValue(createSuccessfulRemoteDataObject$(mockDefaultAccessCondition));
|
||||
@@ -243,7 +243,7 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
|
||||
groupService.findById.and.returnValues(
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup)),
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup))
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup)),
|
||||
);
|
||||
|
||||
bitstreamService.getUploadedFileList.and.returnValue(observableOf([]));
|
||||
@@ -279,7 +279,7 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
|
||||
groupService.findById.and.returnValues(
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup)),
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup))
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup)),
|
||||
);
|
||||
|
||||
bitstreamService.getUploadedFileList.and.returnValue(observableOf(mockUploadFiles));
|
||||
@@ -314,12 +314,12 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
|
||||
groupService.findById.and.returnValues(
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup)),
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup))
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup)),
|
||||
);
|
||||
|
||||
bitstreamService.getUploadedFileList.and.returnValue(cold('-a-b', {
|
||||
a: [],
|
||||
b: mockUploadFiles
|
||||
b: mockUploadFiles,
|
||||
}));
|
||||
|
||||
comp.onSectionInit();
|
||||
@@ -328,7 +328,7 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
|
||||
expect(compAsAny.getSectionStatus()).toBeObservable(cold('-c-d', {
|
||||
c: false,
|
||||
d: true
|
||||
d: true,
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -343,12 +343,12 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
|
||||
groupService.findById.and.returnValues(
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup)),
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup))
|
||||
createSuccessfulRemoteDataObject$(Object.assign(new Group(), mockGroup)),
|
||||
);
|
||||
|
||||
bitstreamService.getUploadedFileList.and.returnValue(cold('-a-b', {
|
||||
a: [],
|
||||
b: mockUploadFiles
|
||||
b: mockUploadFiles,
|
||||
}));
|
||||
|
||||
comp.onSectionInit();
|
||||
@@ -357,7 +357,7 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
|
||||
expect(compAsAny.getSectionStatus()).toBeObservable(cold('-c-d', {
|
||||
c: true,
|
||||
d: true
|
||||
d: true,
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -366,7 +366,7 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
// declare a test component
|
||||
@Component({
|
||||
selector: 'ds-test-cmp',
|
||||
template: ``
|
||||
template: ``,
|
||||
})
|
||||
class TestComponent {
|
||||
|
||||
|
@@ -4,7 +4,7 @@ import {
|
||||
BehaviorSubject,
|
||||
combineLatest as observableCombineLatest,
|
||||
Observable,
|
||||
Subscription
|
||||
Subscription,
|
||||
} from 'rxjs';
|
||||
import { distinctUntilChanged, filter, map, mergeMap, switchMap, tap } from 'rxjs/operators';
|
||||
|
||||
@@ -158,8 +158,8 @@ export class SubmissionSectionUploadComponent extends SectionModelComponent {
|
||||
switchMap((config: SubmissionUploadsModel) =>
|
||||
config.metadata.pipe(
|
||||
getFirstSucceededRemoteData(),
|
||||
map((remoteData: RemoteData<SubmissionFormsModel>) => remoteData.payload)
|
||||
)
|
||||
map((remoteData: RemoteData<SubmissionFormsModel>) => remoteData.payload),
|
||||
),
|
||||
));
|
||||
|
||||
this.subs.push(
|
||||
@@ -215,8 +215,8 @@ export class SubmissionSectionUploadComponent extends SectionModelComponent {
|
||||
}
|
||||
|
||||
this.changeDetectorRef.detectChanges();
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,7 @@ import { SubmissionState } from '../../submission.reducers';
|
||||
import {
|
||||
DeleteUploadedFileAction,
|
||||
EditFileDataAction,
|
||||
NewUploadedFileAction
|
||||
NewUploadedFileAction,
|
||||
} from '../../objects/submission-objects.actions';
|
||||
import { submissionUploadedFileFromUuidSelector, submissionUploadedFilesFromIdSelector } from '../../selectors';
|
||||
import { isUndefined } from '../../../shared/empty.util';
|
||||
@@ -100,7 +100,7 @@ export class SectionUploadService {
|
||||
*/
|
||||
public addUploadedFile(submissionId: string, sectionId: string, fileUUID: string, data: WorkspaceitemSectionUploadFileObject) {
|
||||
this.store.dispatch(
|
||||
new NewUploadedFileAction(submissionId, sectionId, fileUUID, data)
|
||||
new NewUploadedFileAction(submissionId, sectionId, fileUUID, data),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ export class SectionUploadService {
|
||||
*/
|
||||
public updateFileData(submissionId: string, sectionId: string, fileUUID: string, data: WorkspaceitemSectionUploadFileObject) {
|
||||
this.store.dispatch(
|
||||
new EditFileDataAction(submissionId, sectionId, fileUUID, data)
|
||||
new EditFileDataAction(submissionId, sectionId, fileUUID, data),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ export class SectionUploadService {
|
||||
*/
|
||||
public removeUploadedFile(submissionId: string, sectionId: string, fileUUID: string) {
|
||||
this.store.dispatch(
|
||||
new DeleteUploadedFileAction(submissionId, sectionId, fileUUID)
|
||||
new DeleteUploadedFileAction(submissionId, sectionId, fileUUID),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user