Fix wrong visualization of bitstream access condition form within submission form

This commit is contained in:
Giuseppe Digilio
2021-05-19 15:35:37 +02:00
parent 91137a216f
commit e0edcd64d2
5 changed files with 110 additions and 88 deletions

View File

@@ -1519,83 +1519,87 @@ export const mockFileFormData = {
}, },
accessConditions: [ accessConditions: [
{ {
name: [ accessConditionGroup: {
{ name: [
value: 'openaccess', {
language: null, value: 'openaccess',
authority: null, language: null,
display: 'openaccess', authority: null,
confidence: -1, display: 'openaccess',
place: 0, confidence: -1,
otherInformation: null place: 0,
} otherInformation: null
], }
} ],
, },
},
{ {
name: [ accessConditionGroup:{
{ name: [
value: 'lease', {
language: null, value: 'lease',
authority: null, language: null,
display: 'lease', authority: null,
confidence: -1, display: 'lease',
place: 0, confidence: -1,
otherInformation: null place: 0,
} otherInformation: null
], }
endDate: [ ],
{ endDate: [
value: { {
year: 2019, value: {
month: 1, year: 2019,
day: 16 month: 1,
}, day: 16
language: null, },
authority: null, language: null,
display: { authority: null,
year: 2019, display: {
month: 1, year: 2019,
day: 16 month: 1,
}, day: 16
confidence: -1, },
place: 0, confidence: -1,
otherInformation: null place: 0,
} otherInformation: null
], }
} ],
, }
},
{ {
name: [ accessConditionGroup: {
{ name: [
value: 'embargo', {
language: null, value: 'embargo',
authority: null, language: null,
display: 'lease', authority: null,
confidence: -1, display: 'lease',
place: 0, confidence: -1,
otherInformation: null place: 0,
} otherInformation: null
], }
startDate: [ ],
{ startDate: [
value: { {
year: 2019, value: {
month: 1, year: 2019,
day: 16 month: 1,
}, day: 16
language: null, },
authority: null, language: null,
display: { authority: null,
year: 2019, display: {
month: 1, year: 2019,
day: 16 month: 1,
}, day: 16
confidence: -1, },
place: 0, confidence: -1,
otherInformation: null place: 0,
} otherInformation: null
], }
],
}
} }
] ]
}; };

View File

@@ -0,0 +1,6 @@
::ng-deep .access-condition-group {
position: relative;
top: -2.3rem;
margin-bottom: -2.3rem;
}

View File

@@ -18,6 +18,8 @@ import {
import { WorkspaceitemSectionUploadFileObject } from '../../../../../core/submission/models/workspaceitem-section-upload-file.model'; import { WorkspaceitemSectionUploadFileObject } from '../../../../../core/submission/models/workspaceitem-section-upload-file.model';
import { FormBuilderService } from '../../../../../shared/form/builder/form-builder.service'; import { FormBuilderService } from '../../../../../shared/form/builder/form-builder.service';
import { import {
BITSTREAM_ACCESS_CONDITION_GROUP_CONFIG,
BITSTREAM_ACCESS_CONDITION_GROUP_LAYOUT,
BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_CONFIG, BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_CONFIG,
BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_LAYOUT, BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_LAYOUT,
BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_CONFIG, BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_CONFIG,
@@ -43,6 +45,7 @@ import { FormComponent } from '../../../../../shared/form/form.component';
*/ */
@Component({ @Component({
selector: 'ds-submission-section-upload-file-edit', selector: 'ds-submission-section-upload-file-edit',
styleUrls: ['./section-upload-file-edit.component.scss'],
templateUrl: './section-upload-file-edit.component.html', templateUrl: './section-upload-file-edit.component.html',
}) })
export class SubmissionSectionUploadFileEditComponent implements OnChanges { export class SubmissionSectionUploadFileEditComponent implements OnChanges {
@@ -209,8 +212,9 @@ export class SubmissionSectionUploadFileEditComponent implements OnChanges {
const startDate = new DynamicDatePickerModel(startDateConfig, BITSTREAM_FORM_ACCESS_CONDITION_START_DATE_LAYOUT); const startDate = new DynamicDatePickerModel(startDateConfig, BITSTREAM_FORM_ACCESS_CONDITION_START_DATE_LAYOUT);
const endDate = new DynamicDatePickerModel(endDateConfig, BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_LAYOUT); const endDate = new DynamicDatePickerModel(endDateConfig, BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_LAYOUT);
const accessConditionGroupConfig = Object.assign({}, BITSTREAM_ACCESS_CONDITION_GROUP_CONFIG);
return [type, startDate, endDate]; accessConditionGroupConfig.group = [type, startDate, endDate];
return [new DynamicFormGroupModel(accessConditionGroupConfig, BITSTREAM_ACCESS_CONDITION_GROUP_LAYOUT)];
}; };
// Number of access conditions blocks in form // Number of access conditions blocks in form

View File

@@ -15,12 +15,24 @@ export const BITSTREAM_METADATA_FORM_GROUP_CONFIG: DynamicFormGroupModelConfig =
export const BITSTREAM_METADATA_FORM_GROUP_LAYOUT: DynamicFormControlLayout = { export const BITSTREAM_METADATA_FORM_GROUP_LAYOUT: DynamicFormControlLayout = {
element: { element: {
container: 'form-group', container: 'form-group',
label: 'col-form-label' label: 'col-form-label'
}, },
grid: { grid: {
label: 'col-sm-3' label: 'col-sm-3'
} }
}; };
export const BITSTREAM_ACCESS_CONDITION_GROUP_CONFIG: DynamicFormGroupModelConfig = {
id: 'accessConditionGroup',
group: []
};
export const BITSTREAM_ACCESS_CONDITION_GROUP_LAYOUT: DynamicFormControlLayout = {
element: {
host: 'form-group flex-fill access-condition-group',
container: 'pl-1 pr-1',
control: 'form-row '
}
};
export const BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_CONFIG: DynamicFormArrayModelConfig = { export const BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_CONFIG: DynamicFormArrayModelConfig = {
id: 'accessConditions', id: 'accessConditions',
@@ -28,7 +40,7 @@ export const BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_CONFIG: DynamicFormArrayMode
}; };
export const BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_LAYOUT: DynamicFormControlLayout = { export const BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_LAYOUT: DynamicFormControlLayout = {
grid: { grid: {
group: 'form-row' group: 'form-row pt-4',
} }
}; };
@@ -39,11 +51,8 @@ export const BITSTREAM_FORM_ACCESS_CONDITION_TYPE_CONFIG: DynamicSelectModelConf
}; };
export const BITSTREAM_FORM_ACCESS_CONDITION_TYPE_LAYOUT: DynamicFormControlLayout = { export const BITSTREAM_FORM_ACCESS_CONDITION_TYPE_LAYOUT: DynamicFormControlLayout = {
element: { element: {
container: 'p-0', host: 'col-12',
label: 'col-form-label' label: 'col-form-label name-label'
},
grid: {
host: 'col-md-10'
} }
}; };
@@ -70,11 +79,10 @@ export const BITSTREAM_FORM_ACCESS_CONDITION_START_DATE_CONFIG: DynamicDatePicke
}; };
export const BITSTREAM_FORM_ACCESS_CONDITION_START_DATE_LAYOUT: DynamicFormControlLayout = { export const BITSTREAM_FORM_ACCESS_CONDITION_START_DATE_LAYOUT: DynamicFormControlLayout = {
element: { element: {
container: 'p-0',
label: 'col-form-label' label: 'col-form-label'
}, },
grid: { grid: {
host: 'col-md-4' host: 'col-6'
} }
}; };
@@ -101,10 +109,9 @@ export const BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_CONFIG: DynamicDatePickerM
}; };
export const BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_LAYOUT: DynamicFormControlLayout = { export const BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_LAYOUT: DynamicFormControlLayout = {
element: { element: {
container: 'p-0',
label: 'col-form-label' label: 'col-form-label'
}, },
grid: { grid: {
host: 'col-md-4' host: 'col-6'
} }
}; };

View File

@@ -255,6 +255,7 @@ export class SubmissionSectionUploadFileComponent implements OnChanges, OnInit {
}); });
const accessConditionsToSave = []; const accessConditionsToSave = [];
formData.accessConditions formData.accessConditions
.map((accessConditions) => accessConditions.accessConditionGroup)
.filter((accessCondition) => isNotEmpty(accessCondition)) .filter((accessCondition) => isNotEmpty(accessCondition))
.forEach((accessCondition) => { .forEach((accessCondition) => {
let accessConditionOpt; let accessConditionOpt;