ngx-iso-form 3.1.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +149 -87
- package/fesm2022/ngx-iso-form.mjs +108 -20
- package/fesm2022/ngx-iso-form.mjs.map +1 -1
- package/lib/Models/IsoForm.d.ts +3 -1
- package/lib/ngx-iso-form.component.d.ts +2 -1
- package/lib/ngx-iso-form.service.d.ts +2 -2
- package/package.json +3 -1
- package/lib/styles/index.scss +0 -34
- package/lib/styles/ngx-iso-form.component.scss +0 -16
|
@@ -462,12 +462,16 @@ class NgxIsoService {
|
|
|
462
462
|
maxOccurs(maxOccurs) {
|
|
463
463
|
return maxOccurs === 'unbounded' || parseInt(maxOccurs, 10) > 1;
|
|
464
464
|
}
|
|
465
|
-
initFormModel(model, form, prev_key) {
|
|
465
|
+
initFormModel(model, form, prev_key, choiceKey = false, index = -1) {
|
|
466
466
|
if (typeof model === 'object') {
|
|
467
467
|
for (const key in model) {
|
|
468
468
|
const __key = !prev_key ? key : `${prev_key}_${key}`;
|
|
469
|
-
|
|
470
|
-
|
|
469
|
+
const parentNode = this.getFormModel(this._formModel[0], __key);
|
|
470
|
+
if (!choiceKey &&
|
|
471
|
+
((parentNode && parentNode.multi) || Array.isArray(model[key]))) {
|
|
472
|
+
if (!Array.isArray(model[key]) && parentNode && parentNode.multi) {
|
|
473
|
+
model[key] = [model[key]];
|
|
474
|
+
}
|
|
471
475
|
const item = model[key];
|
|
472
476
|
const formArray = form.get(__key);
|
|
473
477
|
if (formArray && formArray.length !== item.length) {
|
|
@@ -489,22 +493,26 @@ class NgxIsoService {
|
|
|
489
493
|
for (let i = 0; i < item.length; i++) {
|
|
490
494
|
parentNode.elements[i].expanded = true;
|
|
491
495
|
const formArray = form.get(__key);
|
|
496
|
+
const choiceKey = parentNode.elements[i].dataType === 'choice';
|
|
492
497
|
if (formArray) {
|
|
493
498
|
const frmGroup = formArray.at(i);
|
|
494
499
|
if (frmGroup) {
|
|
495
|
-
this.initFormModel(item[i], frmGroup, __key);
|
|
500
|
+
this.initFormModel(item[i], frmGroup, __key, choiceKey, i);
|
|
496
501
|
}
|
|
497
502
|
}
|
|
498
503
|
}
|
|
499
504
|
}
|
|
500
505
|
else if (typeof model[key] === 'object') {
|
|
501
|
-
|
|
506
|
+
let node = this.getFormModel(this._formModel[0], __key);
|
|
502
507
|
node.expanded = true;
|
|
503
508
|
if (node && (!node.minOccurs || parseInt(node.minOccurs, 10) === 0)) {
|
|
504
509
|
node.minOccurs = '1';
|
|
505
510
|
}
|
|
506
511
|
const _form = form.get(__key);
|
|
507
512
|
if (_form) {
|
|
513
|
+
if (node.elements.length === 1 && node.elements[0].dataType === 'choice') {
|
|
514
|
+
node = node.elements[0];
|
|
515
|
+
}
|
|
508
516
|
if (node.dataType === 'choice') {
|
|
509
517
|
const choiceKey = Object.keys(model[key])[0];
|
|
510
518
|
const _choiceKey = `${__key}_${choiceKey}`;
|
|
@@ -525,6 +533,23 @@ class NgxIsoService {
|
|
|
525
533
|
this.initFormModel(model[key], _form, __key);
|
|
526
534
|
}
|
|
527
535
|
}
|
|
536
|
+
else if (choiceKey) {
|
|
537
|
+
let node = this.getFormModel(this._formModel[0], prev_key);
|
|
538
|
+
if (node.multi) {
|
|
539
|
+
node = node.elements[index];
|
|
540
|
+
}
|
|
541
|
+
node.expanded = true;
|
|
542
|
+
if (node && (!node.minOccurs || parseInt(node.minOccurs, 10) === 0)) {
|
|
543
|
+
node.minOccurs = '1';
|
|
544
|
+
}
|
|
545
|
+
const choiceEle = node.elements.find((item) => item.id === __key);
|
|
546
|
+
node.choiceKey = __key;
|
|
547
|
+
choiceEle.hidden = false;
|
|
548
|
+
choiceEle.expanded = true;
|
|
549
|
+
const newNode = structuredClone(choiceEle);
|
|
550
|
+
const _formCtrl = form.get(__key);
|
|
551
|
+
_formCtrl.setValue(model[key]);
|
|
552
|
+
}
|
|
528
553
|
else {
|
|
529
554
|
const _form = form.get(__key);
|
|
530
555
|
_form.setValue(model[key]);
|
|
@@ -534,17 +559,20 @@ class NgxIsoService {
|
|
|
534
559
|
else if (Array.isArray(model)) {
|
|
535
560
|
for (let i = 0; i < model.length; i++) {
|
|
536
561
|
const frmGroup = form.at(i);
|
|
537
|
-
this.initFormModel(model[i], frmGroup,
|
|
562
|
+
this.initFormModel(model[i], frmGroup, '');
|
|
538
563
|
}
|
|
539
564
|
}
|
|
540
565
|
}
|
|
541
|
-
getFormGroupControls(json, keys, index = 0, choiceEle = false) {
|
|
566
|
+
getFormGroupControls(json, keys, index = 0, choiceEle = false, prev_key = '') {
|
|
542
567
|
let control = {};
|
|
543
568
|
let controls;
|
|
544
569
|
let value = {};
|
|
545
570
|
json.forEach((item) => {
|
|
546
571
|
if ((this.excludes.length > 0 && !this.excludes.includes(item.id)) ||
|
|
547
572
|
this.excludes.length == 0) {
|
|
573
|
+
if (item.id === null) {
|
|
574
|
+
item.id = prev_key;
|
|
575
|
+
}
|
|
548
576
|
item.hidden = choiceEle;
|
|
549
577
|
value = item.elements;
|
|
550
578
|
const id = item.id;
|
|
@@ -562,11 +590,9 @@ class NgxIsoService {
|
|
|
562
590
|
xpath: element.xpath,
|
|
563
591
|
elements: [element],
|
|
564
592
|
});
|
|
565
|
-
const data = this.getFormGroupControls(item.elements, element.elements, index, choice);
|
|
593
|
+
const data = this.getFormGroupControls(item.elements, element.elements, index, choice, id);
|
|
566
594
|
controls = this.fb.array([]);
|
|
567
|
-
|
|
568
|
-
controls.push(data);
|
|
569
|
-
}
|
|
595
|
+
controls.push(data);
|
|
570
596
|
control[id] = controls;
|
|
571
597
|
}
|
|
572
598
|
else if (item.multi && !item.isFormControls) {
|
|
@@ -576,7 +602,7 @@ class NgxIsoService {
|
|
|
576
602
|
xpath: element.xpath,
|
|
577
603
|
elements: element.elements,
|
|
578
604
|
});
|
|
579
|
-
const data = this.getFormGroupControls(item.elements[item.elements.length - 1].elements, element.elements, index, choice);
|
|
605
|
+
const data = this.getFormGroupControls(item.elements[item.elements.length - 1].elements, element.elements, index, choice, id);
|
|
580
606
|
controls = this.fb.array([]);
|
|
581
607
|
if (!choice) {
|
|
582
608
|
controls.push(data);
|
|
@@ -594,7 +620,7 @@ class NgxIsoService {
|
|
|
594
620
|
}
|
|
595
621
|
else {
|
|
596
622
|
keys.push(element);
|
|
597
|
-
const data = this.getFormGroupControls(item.elements, element.elements, index, choice);
|
|
623
|
+
const data = this.getFormGroupControls(item.elements, element.elements, index, choice, id);
|
|
598
624
|
if (!choice) {
|
|
599
625
|
control[id] = data;
|
|
600
626
|
}
|
|
@@ -616,7 +642,7 @@ class NgxIsoService {
|
|
|
616
642
|
else if (item.isCurrency) {
|
|
617
643
|
const _amountCurrency = this.getAmountCurrency(item);
|
|
618
644
|
keys.push(element);
|
|
619
|
-
const data = this.getFormGroupControls(_amountCurrency, element.elements, 0, false);
|
|
645
|
+
const data = this.getFormGroupControls(_amountCurrency, element.elements, 0, false, item.id);
|
|
620
646
|
control[item.id] = data;
|
|
621
647
|
}
|
|
622
648
|
else {
|
|
@@ -752,7 +778,13 @@ class NgxIsoFormComponent {
|
|
|
752
778
|
}
|
|
753
779
|
const newEle = this.structuredClone(parentNode.elements[0]);
|
|
754
780
|
const newKeys = [];
|
|
755
|
-
|
|
781
|
+
let groupControls;
|
|
782
|
+
if (newEle.dataType === 'choice') {
|
|
783
|
+
groupControls = this.service.getFormGroupControls([newEle], newKeys, parentNode.elements.length - 1);
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
groupControls = this.service.getFormGroupControls(newEle.elements, newKeys, parentNode.elements.length - 1);
|
|
787
|
+
}
|
|
756
788
|
parentNode.elements.push(newEle);
|
|
757
789
|
control.push(groupControls);
|
|
758
790
|
this.changeDetection.detectChanges();
|
|
@@ -817,11 +849,13 @@ class NgxIsoFormComponent {
|
|
|
817
849
|
return ctrl.indexOf(element.id) > -1;
|
|
818
850
|
});
|
|
819
851
|
});
|
|
820
|
-
|
|
821
|
-
return formControl.at(formControl.length - 1);
|
|
852
|
+
formGroup;
|
|
822
853
|
}
|
|
823
854
|
return formControl;
|
|
824
855
|
}
|
|
856
|
+
getFormGroupByIndex(formArray, _index) {
|
|
857
|
+
return formArray.controls[_index];
|
|
858
|
+
}
|
|
825
859
|
getFormControl(node) {
|
|
826
860
|
return this.service.getFormControl('');
|
|
827
861
|
}
|
|
@@ -831,11 +865,11 @@ class NgxIsoFormComponent {
|
|
|
831
865
|
return formControl;
|
|
832
866
|
}
|
|
833
867
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxIsoFormComponent, deps: [{ token: NgxIsoService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
834
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.3", type: NgxIsoFormComponent, isStandalone: false, selector: "ngx-iso-form", inputs: { form: "form", schema: "schema", excludes: "excludes" }, usesOnChanges: true, ngImport: i0, template: "<form *ngIf=\"_form && schema\" [formGroup]=\"_form\">\r\n <div class=\"form-group\">\r\n <ng-template #nodeTemplateRef let-node=\"node\" let-formElement=\"formElement\" let-
|
|
868
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.3", type: NgxIsoFormComponent, isStandalone: false, selector: "ngx-iso-form", inputs: { form: "form", schema: "schema", excludes: "excludes" }, usesOnChanges: true, ngImport: i0, template: "<form *ngIf=\"_form && schema\" [formGroup]=\"_form\">\r\n <div class=\"form-group\">\r\n <ng-template #nodeTemplateRef let-node=\"node\" let-formElement=\"formElement\" let-_index=\"index\"\r\n let-parentNode=\"parentNode\" let-parentFormElement=\"parentFormElement\">\r\n <ng-container *ngIf=\"node.multi then arr else obj\"></ng-container>\r\n <ng-template #arr>\r\n <ng-template *ngFor=\"let model of node.elements;let i = index\" [ngTemplateOutlet]=\"nodeTemplateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n node: model,\r\n formElement: getFormGroupByIndex(formElement, i),\r\n parentFormElement: parentFormElement,\r\n parentNode: node,\r\n index: i\r\n }\">\r\n </ng-template>\r\n </ng-template>\r\n <ng-template #obj>\r\n <ng-container *ngIf=\"node.elements.length\">\r\n <mat-accordion [formGroup]=\"formElement\" *ngIf=\"!node.hidden\">\r\n <mat-expansion-panel multi [expanded]=\"expand(node.minOccurs) || node.expanded\" #expan>\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>\r\n {{ node.name | trans: node.id : node.name }}\r\n </mat-panel-title>\r\n <mat-panel-description *ngIf=\"maxOccurs(node.maxOccurs)\">\r\n \r\n <button *ngIf=\"_index < 1\" mat-icon-button (click)=\"addSection($event, node,parentNode, parentFormElement)\">\r\n <mat-icon>add</mat-icon>\r\n </button>\r\n <button *ngIf=\"_index > 0\" mat-icon-button (click)=\"removeSection($event,parentNode,parentFormElement,_index)\">\r\n <mat-icon>remove</mat-icon>\r\n </button>\r\n </mat-panel-description>\r\n </mat-expansion-panel-header>\r\n <ng-container *ngIf=\"expan.expanded\">\r\n <mat-form-field *ngIf=\"node.dataType === 'choice'\">\r\n <mat-label>{{ node.name | trans: node.id : node.name }}</mat-label>\r\n <mat-select (selectionChange)=\"onChoiceSelectionChange($event.value,formElement, node)\" [formControl]=\"getChoiceFormControl(node.choiceKey)\">\r\n <mat-option *ngFor=\"let item of node.elements\" [value]=\"item.id\">\r\n {{item.name}}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n <ng-container *ngIf=\"!isEmpty(formElement)\">\r\n <ng-template *ngFor=\"let model of node.elements; let i = index\" [ngTemplateOutlet]=\"nodeTemplateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n node: model,\r\n formElement: getElement(formElement,model),\r\n parentFormElement: formElement,\r\n index: _index\r\n }\">\r\n </ng-template>\r\n </ng-container>\r\n <div *ngIf=\"node.elements.length === 0\">\r\n <ngx-iso-control *ngIf=\"!node.hidden\" [formControl]=\"formElement\" [control]=\"node\"></ngx-iso-control>\r\n </div>\r\n </ng-container>\r\n </mat-expansion-panel>\r\n </mat-accordion>\r\n </ng-container>\r\n <ng-container *ngIf=\"!node.elements.length && !node.hidden\">\r\n <div *ngIf=\"maxOccurs(node.maxOccurs)\" class=\"form-add-section\">\r\n \r\n <button *ngIf=\"_index < 1\" mat-icon-button (click)=\"addNewControl($event, node,parentNode,parentFormElement)\">\r\n <mat-icon>add</mat-icon>\r\n </button>\r\n <button *ngIf=\"_index > 0\" mat-icon-button (click)=\"removeNewControl($event,parentNode,parentFormElement,_index)\">\r\n <mat-icon>remove</mat-icon>\r\n </button>\r\n </div>\r\n <ngx-iso-control [formControl]=\"formElement\" [control]=\"node\"></ngx-iso-control>\r\n </ng-container>\r\n </ng-template>\r\n </ng-template>\r\n <ng-container *ngFor=\"let model of getFormModel; let i = index\">\r\n <ng-container *ngIf=\"isArray(model);then formArray else formObject\">\r\n </ng-container>\r\n <ng-template #formArray>\r\n <ng-template *ngFor=\"let key of model;let j = index\" [ngTemplateOutlet]=\"nodeTemplateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n node: key,\r\n formElement: getElement(_form,key),\r\n parentFormElement: _form,\r\n index:j\r\n }\">\r\n </ng-template>\r\n </ng-template>\r\n <ng-template #formObject>\r\n <ng-template [ngTemplateOutlet]=\"nodeTemplateRef\" [ngTemplateOutletContext]=\"{\r\n node: model,\r\n formElement: getElement(_form,model),\r\n parentFormElement: _form,\r\n index: i,\r\n }\">\r\n </ng-template>\r\n </ng-template>\r\n </ng-container>\r\n </div>\r\n</form>", styles: [":host .mat-expansion-panel-header-description{justify-content:space-between;align-items:center}:host .mat-expansion-panel{width:100%;margin:5px 0}.mat-mdc-form-field-hint{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n"], dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i4$2.MatAccordion, selector: "mat-accordion", inputs: ["hideToggle", "displayMode", "togglePosition"], exportAs: ["matAccordion"] }, { kind: "component", type: i4$2.MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["hideToggle", "togglePosition"], outputs: ["afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { kind: "component", type: i4$2.MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["expandedHeight", "collapsedHeight", "tabIndex"] }, { kind: "directive", type: i4$2.MatExpansionPanelTitle, selector: "mat-panel-title" }, { kind: "directive", type: i4$2.MatExpansionPanelDescription, selector: "mat-panel-description" }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "component", type: i6.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "component", type: i4$1.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i5$1.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: i9.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: NgxIsoControlComponent, selector: "ngx-iso-control", inputs: ["formControl", "control"] }, { kind: "pipe", type: IsoTranslatePipe, name: "trans" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
835
869
|
}
|
|
836
870
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxIsoFormComponent, decorators: [{
|
|
837
871
|
type: Component,
|
|
838
|
-
args: [{ selector: 'ngx-iso-form', changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, template: "<form *ngIf=\"_form && schema\" [formGroup]=\"_form\">\r\n <div class=\"form-group\">\r\n <ng-template #nodeTemplateRef let-node=\"node\" let-formElement=\"formElement\" let-
|
|
872
|
+
args: [{ selector: 'ngx-iso-form', changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, template: "<form *ngIf=\"_form && schema\" [formGroup]=\"_form\">\r\n <div class=\"form-group\">\r\n <ng-template #nodeTemplateRef let-node=\"node\" let-formElement=\"formElement\" let-_index=\"index\"\r\n let-parentNode=\"parentNode\" let-parentFormElement=\"parentFormElement\">\r\n <ng-container *ngIf=\"node.multi then arr else obj\"></ng-container>\r\n <ng-template #arr>\r\n <ng-template *ngFor=\"let model of node.elements;let i = index\" [ngTemplateOutlet]=\"nodeTemplateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n node: model,\r\n formElement: getFormGroupByIndex(formElement, i),\r\n parentFormElement: parentFormElement,\r\n parentNode: node,\r\n index: i\r\n }\">\r\n </ng-template>\r\n </ng-template>\r\n <ng-template #obj>\r\n <ng-container *ngIf=\"node.elements.length\">\r\n <mat-accordion [formGroup]=\"formElement\" *ngIf=\"!node.hidden\">\r\n <mat-expansion-panel multi [expanded]=\"expand(node.minOccurs) || node.expanded\" #expan>\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>\r\n {{ node.name | trans: node.id : node.name }}\r\n </mat-panel-title>\r\n <mat-panel-description *ngIf=\"maxOccurs(node.maxOccurs)\">\r\n \r\n <button *ngIf=\"_index < 1\" mat-icon-button (click)=\"addSection($event, node,parentNode, parentFormElement)\">\r\n <mat-icon>add</mat-icon>\r\n </button>\r\n <button *ngIf=\"_index > 0\" mat-icon-button (click)=\"removeSection($event,parentNode,parentFormElement,_index)\">\r\n <mat-icon>remove</mat-icon>\r\n </button>\r\n </mat-panel-description>\r\n </mat-expansion-panel-header>\r\n <ng-container *ngIf=\"expan.expanded\">\r\n <mat-form-field *ngIf=\"node.dataType === 'choice'\">\r\n <mat-label>{{ node.name | trans: node.id : node.name }}</mat-label>\r\n <mat-select (selectionChange)=\"onChoiceSelectionChange($event.value,formElement, node)\" [formControl]=\"getChoiceFormControl(node.choiceKey)\">\r\n <mat-option *ngFor=\"let item of node.elements\" [value]=\"item.id\">\r\n {{item.name}}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n <ng-container *ngIf=\"!isEmpty(formElement)\">\r\n <ng-template *ngFor=\"let model of node.elements; let i = index\" [ngTemplateOutlet]=\"nodeTemplateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n node: model,\r\n formElement: getElement(formElement,model),\r\n parentFormElement: formElement,\r\n index: _index\r\n }\">\r\n </ng-template>\r\n </ng-container>\r\n <div *ngIf=\"node.elements.length === 0\">\r\n <ngx-iso-control *ngIf=\"!node.hidden\" [formControl]=\"formElement\" [control]=\"node\"></ngx-iso-control>\r\n </div>\r\n </ng-container>\r\n </mat-expansion-panel>\r\n </mat-accordion>\r\n </ng-container>\r\n <ng-container *ngIf=\"!node.elements.length && !node.hidden\">\r\n <div *ngIf=\"maxOccurs(node.maxOccurs)\" class=\"form-add-section\">\r\n \r\n <button *ngIf=\"_index < 1\" mat-icon-button (click)=\"addNewControl($event, node,parentNode,parentFormElement)\">\r\n <mat-icon>add</mat-icon>\r\n </button>\r\n <button *ngIf=\"_index > 0\" mat-icon-button (click)=\"removeNewControl($event,parentNode,parentFormElement,_index)\">\r\n <mat-icon>remove</mat-icon>\r\n </button>\r\n </div>\r\n <ngx-iso-control [formControl]=\"formElement\" [control]=\"node\"></ngx-iso-control>\r\n </ng-container>\r\n </ng-template>\r\n </ng-template>\r\n <ng-container *ngFor=\"let model of getFormModel; let i = index\">\r\n <ng-container *ngIf=\"isArray(model);then formArray else formObject\">\r\n </ng-container>\r\n <ng-template #formArray>\r\n <ng-template *ngFor=\"let key of model;let j = index\" [ngTemplateOutlet]=\"nodeTemplateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n node: key,\r\n formElement: getElement(_form,key),\r\n parentFormElement: _form,\r\n index:j\r\n }\">\r\n </ng-template>\r\n </ng-template>\r\n <ng-template #formObject>\r\n <ng-template [ngTemplateOutlet]=\"nodeTemplateRef\" [ngTemplateOutletContext]=\"{\r\n node: model,\r\n formElement: getElement(_form,model),\r\n parentFormElement: _form,\r\n index: i,\r\n }\">\r\n </ng-template>\r\n </ng-template>\r\n </ng-container>\r\n </div>\r\n</form>", styles: [":host .mat-expansion-panel-header-description{justify-content:space-between;align-items:center}:host .mat-expansion-panel{width:100%;margin:5px 0}.mat-mdc-form-field-hint{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n"] }]
|
|
839
873
|
}], ctorParameters: () => [{ type: NgxIsoService }, { type: i0.ChangeDetectorRef }], propDecorators: { form: [{
|
|
840
874
|
type: Input,
|
|
841
875
|
args: [{ required: true }]
|
|
@@ -956,16 +990,70 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
|
|
|
956
990
|
}] });
|
|
957
991
|
|
|
958
992
|
class IsoForm {
|
|
959
|
-
constructor(model) {
|
|
993
|
+
constructor(model, xmlMessage = '') {
|
|
994
|
+
this._namespace = {};
|
|
960
995
|
/**
|
|
961
996
|
* @deprecated This method is deprecated use `#isoForm.getFormModel` instead
|
|
962
997
|
*/
|
|
963
998
|
this.getFormModel = () => { };
|
|
999
|
+
if (xmlMessage) {
|
|
1000
|
+
model = this.parseXML(new DOMParser().parseFromString(xmlMessage, 'text/xml').childNodes[0]);
|
|
1001
|
+
}
|
|
964
1002
|
this._model = model;
|
|
965
1003
|
}
|
|
966
1004
|
get isoFormModel() {
|
|
967
1005
|
return this._model;
|
|
968
1006
|
}
|
|
1007
|
+
parseXML(node) {
|
|
1008
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
1009
|
+
const obj = {};
|
|
1010
|
+
obj[node.nodeName] = {};
|
|
1011
|
+
if (node.hasChildNodes()) {
|
|
1012
|
+
for (let childNode of Array.from(node.childNodes)) {
|
|
1013
|
+
const childObj = this.parseXML(childNode);
|
|
1014
|
+
if (typeof childObj === 'object' &&
|
|
1015
|
+
childNode.nodeType !== Node.TEXT_NODE &&
|
|
1016
|
+
Object.keys(childObj).length > 0) {
|
|
1017
|
+
if (obj[node.nodeName][childNode.nodeName]) {
|
|
1018
|
+
obj[node.nodeName][childNode.nodeName] = [
|
|
1019
|
+
structuredClone(obj[node.nodeName][childNode.nodeName]),
|
|
1020
|
+
];
|
|
1021
|
+
obj[node.nodeName][childNode.nodeName].push(childObj[childNode.nodeName]);
|
|
1022
|
+
}
|
|
1023
|
+
else {
|
|
1024
|
+
obj[node.nodeName][childNode.nodeName] = {};
|
|
1025
|
+
obj[node.nodeName][childNode.nodeName] =
|
|
1026
|
+
childObj[childNode.nodeName];
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
else if (childObj && Object.keys(childObj).length > 0) {
|
|
1030
|
+
obj[node.nodeName] = childObj;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
if (node.attributes && node.attributes.length > 0) {
|
|
1035
|
+
for (const attribute of Array.from(node.attributes)) {
|
|
1036
|
+
if (attribute.nodeName === 'xmlns') {
|
|
1037
|
+
this._namespace[node.nodeName] = attribute.nodeValue;
|
|
1038
|
+
}
|
|
1039
|
+
else {
|
|
1040
|
+
if (attribute.nodeName === 'Ccy') {
|
|
1041
|
+
obj[node.nodeName] = {
|
|
1042
|
+
Amt: node.textContent,
|
|
1043
|
+
Ccy: attribute.nodeValue,
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
return obj;
|
|
1050
|
+
}
|
|
1051
|
+
else if (node.nodeType === Node.TEXT_NODE ||
|
|
1052
|
+
node.nodeType === Node.CDATA_SECTION_NODE) {
|
|
1053
|
+
return node.nodeValue.trim();
|
|
1054
|
+
}
|
|
1055
|
+
return {};
|
|
1056
|
+
}
|
|
969
1057
|
}
|
|
970
1058
|
|
|
971
1059
|
/*
|