= {};
+ localKey: string;
+
+ localSubmition: Record;
+
constructor(private _form: FormService) {}
ngOnInit(): void {
@@ -62,5 +66,73 @@ export class FormComponentComponent implements OnInit {
this.field[field.name] = field.value;
}
}
+
+ this.localSubmition = this.submition;
+
+ const keys = (this.component.key || '')?.split('.');
+
+ while (keys.length > 1) {
+ let key = keys.shift() as string;
+
+ if (key.endsWith('[]')) {
+ key = key.replace('[]', '');
+
+ const index = this._getIndex();
+
+ this.localSubmition[key] = (this.localSubmition[key] ||
+ []) as Record[];
+
+ while (
+ index + 1 >
+ (this.localSubmition[key] as Record[])
+ .length
+ ) {
+ (
+ this.localSubmition[key] as Record[]
+ ).push({});
+ }
+
+ this.localSubmition = (
+ this.localSubmition[key] as Record[]
+ )[index];
+ } else {
+ this.localSubmition = this.localSubmition[
+ this.localKey
+ ] as Record;
+ }
+ }
+
+ this.localKey = keys[0];
+ }
+
+ private _getIndex(components = this.config.components): number {
+ for (const component of components) {
+ if (component.components) {
+ const localIndex = this._getIndex(component.components);
+
+ if (localIndex >= 0) {
+ for (let i = 0; i < component.components.length; i++) {
+ for (const comp of component.components[i]
+ .components as Record[]) {
+ if (comp === this.component) {
+ return i;
+ }
+ }
+ }
+ }
+
+ if (
+ component?.components?.indexOf(
+ this.component as unknown as any
+ ) >= 0
+ ) {
+ return component.components.indexOf(
+ this.component as unknown as any
+ );
+ }
+ }
+ }
+
+ return -1;
}
}
diff --git a/src/app/core/modules/form/form.service.ts b/src/app/core/modules/form/form.service.ts
index a336a6c..a566b53 100644
--- a/src/app/core/modules/form/form.service.ts
+++ b/src/app/core/modules/form/form.service.ts
@@ -6,16 +6,15 @@ import {
Injector,
Type
} from '@angular/core';
-import { StoreService } from 'wacom';
+import { ModalService, StoreService } from 'wacom';
import { TemplateFieldInterface } from './interfaces/component.interface';
-import { ModalService } from 'src/app/core/modules/modal/modal.service';
import { FormInterface } from './interfaces/form.interface';
import { ModalFormComponent } from './modals/modal-form/modal-form.component';
import { TranslateService } from '../translate/translate.service';
import { ModalUniqueComponent } from './modals/modal-unique/modal-unique.component';
-import { Modal } from '../modal/modal.interface';
import { environment } from 'src/environments/environment';
import { CustomformService } from 'src/app/modules/customform/services/customform.service';
+import { Modal } from 'wacom/lib/interfaces/modal.interface';
export interface FormModalButton {
/** Function to execute on button click */
diff --git a/src/app/core/modules/form/module.json b/src/app/core/modules/form/module.json
new file mode 100644
index 0000000..1dd6c63
--- /dev/null
+++ b/src/app/core/modules/form/module.json
@@ -0,0 +1,3 @@
+{
+ "repo": "git@github.com:WebArtWork/ngx-form.git"
+}