Commits
Giuseppe Digilio authored 5d130156e86
8 8 | DynamicFormArrayGroupModel, |
9 9 | DynamicFormArrayModel, |
10 10 | DynamicFormControlEvent, |
11 11 | DynamicFormControlModel, |
12 12 | DynamicFormGroupModel, |
13 13 | DynamicSelectModel, |
14 14 | MATCH_ENABLED, |
15 15 | OR_OPERATOR |
16 16 | } from '@ng-dynamic-forms/core'; |
17 17 | |
18 - | import { WorkspaceitemSectionUploadFileObject } from '../../../../../core/submission/models/workspaceitem-section-upload-file.model'; |
18 + | import { |
19 + | WorkspaceitemSectionUploadFileObject |
20 + | } from '../../../../../core/submission/models/workspaceitem-section-upload-file.model'; |
19 21 | import { FormBuilderService } from '../../../../../shared/form/builder/form-builder.service'; |
20 22 | import { |
21 23 | BITSTREAM_ACCESS_CONDITION_GROUP_CONFIG, |
22 24 | BITSTREAM_ACCESS_CONDITION_GROUP_LAYOUT, |
23 25 | BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_CONFIG, |
24 26 | BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_LAYOUT, |
25 27 | BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_CONFIG, |
26 28 | BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_LAYOUT, |
27 29 | BITSTREAM_FORM_ACCESS_CONDITION_START_DATE_CONFIG, |
28 30 | BITSTREAM_FORM_ACCESS_CONDITION_START_DATE_LAYOUT, |
36 38 | import { SubmissionFormsModel } from '../../../../../core/config/models/config-submission-forms.model'; |
37 39 | import { FormFieldModel } from '../../../../../shared/form/builder/models/form-field.model'; |
38 40 | import { AccessConditionOption } from '../../../../../core/config/models/config-access-condition-option.model'; |
39 41 | import { SubmissionService } from '../../../../submission.service'; |
40 42 | import { FormService } from '../../../../../shared/form/form.service'; |
41 43 | import { FormComponent } from '../../../../../shared/form/form.component'; |
42 44 | import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; |
43 45 | import { filter, mergeMap, take } from 'rxjs/operators'; |
44 46 | import { dateToISOFormat } from '../../../../../shared/date.util'; |
45 47 | import { SubmissionObject } from '../../../../../core/submission/models/submission-object.model'; |
46 - | import { WorkspaceitemSectionUploadObject } from '../../../../../core/submission/models/workspaceitem-section-upload.model'; |
48 + | import { |
49 + | WorkspaceitemSectionUploadObject |
50 + | } from '../../../../../core/submission/models/workspaceitem-section-upload.model'; |
47 51 | import { JsonPatchOperationsBuilder } from '../../../../../core/json-patch/builder/json-patch-operations-builder'; |
48 - | import { SubmissionJsonPatchOperationsService } from '../../../../../core/submission/submission-json-patch-operations.service'; |
49 - | import { JsonPatchOperationPathCombiner } from '../../../../../core/json-patch/builder/json-patch-operation-path-combiner'; |
52 + | import { |
53 + | SubmissionJsonPatchOperationsService |
54 + | } from '../../../../../core/submission/submission-json-patch-operations.service'; |
55 + | import { |
56 + | JsonPatchOperationPathCombiner |
57 + | } from '../../../../../core/json-patch/builder/json-patch-operation-path-combiner'; |
50 58 | import { SectionUploadService } from '../../section-upload.service'; |
51 59 | import { Subscription } from 'rxjs'; |
52 60 | |
53 61 | /** |
54 62 | * This component represents the edit form for bitstream |
55 63 | */ |
56 64 | @Component({ |
57 65 | selector: 'ds-submission-section-upload-file-edit', |
58 66 | styleUrls: ['./section-upload-file-edit.component.scss'], |
59 67 | templateUrl: './section-upload-file-edit.component.html', |
244 252 | |
245 253 | // Clear previous state |
246 254 | startDateControl?.markAsUntouched(); |
247 255 | endDateControl?.markAsUntouched(); |
248 256 | |
249 257 | startDateControl?.setValue(null); |
250 258 | control.parent.markAsDirty(); |
251 259 | endDateControl?.setValue(null); |
252 260 | |
253 261 | if (showGroups) { |
254 - | if (accessCondition.hasStartDate) { |
262 + | if (accessCondition.hasStartDate && accessCondition.maxStartDate) { |
255 263 | const startDateModel = this.formBuilderService.findById( |
256 264 | 'startDate', |
257 265 | (model.parent as DynamicFormArrayGroupModel).group) as DynamicDateControlModel; |
258 266 | |
259 267 | const min = new Date(accessCondition.maxStartDate); |
260 268 | startDateModel.max = { |
261 269 | year: min.getUTCFullYear(), |
262 270 | month: min.getUTCMonth() + 1, |
263 271 | day: min.getUTCDate() |
264 272 | }; |
265 273 | } |
266 - | if (accessCondition.hasEndDate) { |
274 + | if (accessCondition.hasEndDate && accessCondition.maxEndDate) { |
267 275 | const endDateModel = this.formBuilderService.findById( |
268 276 | 'endDate', |
269 277 | (model.parent as DynamicFormArrayGroupModel).group) as DynamicDateControlModel; |
270 278 | |
271 279 | const max = new Date(accessCondition.maxEndDate); |
272 280 | endDateModel.max = { |
273 281 | year: max.getUTCFullYear(), |
274 282 | month: max.getUTCMonth() + 1, |
275 283 | day: max.getUTCDate() |
276 284 | }; |
285 + | |
277 286 | } |
278 287 | } |
279 288 | } |
280 289 | } |
281 290 | |
282 291 | /** |
283 292 | * Dispatch form model init |
284 293 | */ |
285 294 | ngOnInit() { |
286 295 | if (this.fileData && this.formId) { |