diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.html index 2992abe8ec..5f3e451945 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.html @@ -49,54 +49,13 @@ - - -
-
- - - - - -
- {{ message | translate:model.validators }} -
- -
- -
- -
- -
- -
-
- - - + diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts index f8a06f72f1..409b438449 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts @@ -228,9 +228,6 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo } ngOnInit(): void { - if (this.model.type === 'ARRAY') { - console.log((this.model as DynamicRowArrayModel).get(1)); - } this.hasRelationLookup = hasValue(this.model.relationship); if (this.hasRelationLookup) { @@ -360,26 +357,6 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo modalComp.item = this.item; } - // moveSelection(event: CdkDragDrop) { - // this.zone.runOutsideAngular(() => { - // moveItemInArray(this.reorderables, event.previousIndex, event.currentIndex); - // const reorderables = this.reorderables.map((reo: Reorderable, index: number) => { - // reo.oldIndex = reo.getPlace(); - // reo.newIndex = index; - // return reo; - // } - // ); - // return observableCombineLatest(reorderables.map((rel: ReorderableRelationship) => { - // if (rel.oldIndex !== rel.newIndex) { - // return this.relationshipService.updatePlace(rel); - // } else { - // return observableOf(undefined); - // } - // }) - // ).pipe(getSucceededRemoteData()).subscribe(); - // }) - // } - /** * Unsubscribe from all subscriptions */ @@ -388,11 +365,4 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo .filter((sub) => hasValue(sub)) .forEach((sub) => sub.unsubscribe()); } - - /** - * Prevent unnecessary rerendering so fields don't lose focus - */ - trackReorderable(index, reorderable: Reorderable) { - return hasValue(reorderable) ? reorderable.getId() : undefined; - } } diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html index 607443c551..247bf20a8c 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html @@ -1,14 +1,13 @@
+ [ngClass]="getClass('element', 'control')" cdkDropList (cdkDropListDropped)="moveSelection($event)">
+ [formGroupName]="idx" [ngClass]="[getClass('element', 'group'), getClass('grid', 'group')]" cdkDrag> - = new EventEmitter(); @Output('dfFocus') focus: EventEmitter = new EventEmitter(); @Output('ngbEvent') customEvent: EventEmitter = new EventEmitter(); + /* tslint:enable:no-output-rename */ constructor(protected layoutService: DynamicFormLayoutService, - protected validationService: DynamicFormValidationService) { - + protected validationService: DynamicFormValidationService, + protected relationshipService: RelationshipService, + protected zone: NgZone, + protected formService: DynamicFormService + ) { super(layoutService, validationService); } - - test(event) { - console.log(event); + moveSelection(event: CdkDragDrop) { + this.zone.runOutsideAngular(() => { + this.model.moveGroup(event.previousIndex,event.currentIndex - event.previousIndex); + this.model.groups.forEach( + (group: DynamicFormArrayGroupModel) => { + console.log(group.group[0]); + } + ) + // return observableCombineLatest(reorderables.map((rel: ReorderableRelationship) => { + // if (rel.oldIndex !== rel.newIndex) { + // return this.relationshipService.updatePlace(rel); + // } else { + // return observableOf(undefined); + // } + // }) + // ).pipe(getSucceededRemoteData()).subscribe(); + }) } + } diff --git a/src/app/shared/form/builder/parsers/field-parser.ts b/src/app/shared/form/builder/parsers/field-parser.ts index 5c03d266d3..3215f68cd6 100644 --- a/src/app/shared/form/builder/parsers/field-parser.ts +++ b/src/app/shared/form/builder/parsers/field-parser.ts @@ -41,18 +41,18 @@ export abstract class FieldParser { && (this.configData.input.type !== 'tag') && (this.configData.input.type !== 'group') ) { + let hideHints = false; let arrayCounter = 0; let fieldArrayCounter = 0; const config = { id: uniqueId() + '_array', label: this.configData.label, - initialCount: this.getInitArrayIndex(), + initialCount: this.getInitArrayIndex() + 1, notRepeatable: !this.configData.repeatable || hasValue(this.configData.selectableRelationship), required: isNotEmpty(this.configData.mandatory), groupFactory: () => { let model; - console.log(arrayCounter); if ((arrayCounter === 0)) { model = this.modelFactory(); arrayCounter++; @@ -60,8 +60,13 @@ export abstract class FieldParser { const fieldArrayOfValueLenght = this.getInitValueCount(arrayCounter - 1); let fieldValue = null; if (fieldArrayOfValueLenght > 0) { - fieldValue = this.getInitFieldValue(arrayCounter - 1, fieldArrayCounter++); - if (fieldArrayCounter === fieldArrayOfValueLenght) { + if (fieldArrayCounter === 0) { + fieldValue = ''; + } else { + fieldValue = this.getInitFieldValue(arrayCounter - 1, fieldArrayCounter - 1); + } + fieldArrayCounter++; + if (fieldArrayCounter === fieldArrayOfValueLenght + 1) { fieldArrayCounter = 0; arrayCounter++; } @@ -72,6 +77,9 @@ export abstract class FieldParser { if (model.hasLanguages) { setLayout(model, 'grid', 'control', 'col'); } + if (hideHints) { + model.hint = undefined; + } return [model]; } } as DynamicRowArrayModelConfig;