fx-form-builder-wrapper 0.0.53 → 0.0.55
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/esm2022/fx-form-builder-wrapper.mjs +5 -0
- package/esm2022/lib/components/dynamic-table/dynamic-table.component.mjs +235 -0
- package/esm2022/lib/components/fx-form-component/fx-form-component.component.mjs +103 -0
- package/esm2022/lib/components/toggle/toggle.component.mjs +33 -0
- package/esm2022/lib/components/toggle-button/toggle-button.component.mjs +38 -0
- package/esm2022/lib/components/uploader/uploader.component.mjs +58 -0
- package/esm2022/lib/custom-controls/dispatch-to-clinic/dispatch-to-clinic.component.mjs +42 -0
- package/esm2022/lib/fx-builder-wrapper.component.mjs +79 -0
- package/esm2022/lib/fx-builder-wrapper.service.mjs +44 -0
- package/esm2022/lib/panel/configuration-panel/configuration-panel.component.mjs +117 -0
- package/esm2022/lib/panel/settings-panel/settings-panel.component.mjs +24 -0
- package/esm2022/public-api.mjs +7 -0
- package/fesm2022/fx-form-builder-wrapper.mjs +718 -0
- package/fesm2022/fx-form-builder-wrapper.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/components/dynamic-table/dynamic-table.component.d.ts +52 -0
- package/lib/components/fx-form-component/fx-form-component.component.d.ts +19 -0
- package/lib/components/toggle/toggle.component.d.ts +13 -0
- package/lib/components/toggle-button/toggle-button.component.d.ts +15 -0
- package/lib/components/uploader/uploader.component.d.ts +16 -0
- package/lib/custom-controls/dispatch-to-clinic/dispatch-to-clinic.component.d.ts +17 -0
- package/lib/fx-builder-wrapper.component.d.ts +19 -0
- package/lib/fx-builder-wrapper.service.d.ts +14 -0
- package/lib/panel/configuration-panel/configuration-panel.component.d.ts +27 -0
- package/lib/panel/settings-panel/settings-panel.component.d.ts +10 -0
- package/package.json +29 -16
- package/public-api.d.ts +3 -0
- package/ng-package.json +0 -9
- package/src/lib/components/button/button.component.css +0 -0
- package/src/lib/components/button/button.component.html +0 -1
- package/src/lib/components/button/button.component.ts +0 -24
- package/src/lib/components/dynamic-table/dynamic-table.component.css +0 -31
- package/src/lib/components/dynamic-table/dynamic-table.component.html +0 -69
- package/src/lib/components/dynamic-table/dynamic-table.component.ts +0 -258
- package/src/lib/components/fx-form-component/fx-form-component.component.ts +0 -86
- package/src/lib/components/toggle/toggle.component.css +0 -51
- package/src/lib/components/toggle/toggle.component.html +0 -12
- package/src/lib/components/toggle/toggle.component.ts +0 -33
- package/src/lib/components/toggle-button/toggle-button.component.css +0 -22
- package/src/lib/components/toggle-button/toggle-button.component.html +0 -10
- package/src/lib/components/toggle-button/toggle-button.component.ts +0 -40
- package/src/lib/components/uploader/uploader.component.css +0 -49
- package/src/lib/components/uploader/uploader.component.html +0 -23
- package/src/lib/components/uploader/uploader.component.ts +0 -59
- package/src/lib/custom-controls/dispatch-to-clinic/dispatch-to-clinic.component.html +0 -78
- package/src/lib/custom-controls/dispatch-to-clinic/dispatch-to-clinic.component.ts +0 -44
- package/src/lib/form-builder.css +0 -9
- package/src/lib/fx-builder-wrapper.component.ts +0 -68
- package/src/lib/fx-builder-wrapper.service.ts +0 -38
- package/src/lib/panel/configuration-panel/configuration-panel.component.css +0 -154
- package/src/lib/panel/configuration-panel/configuration-panel.component.html +0 -162
- package/src/lib/panel/configuration-panel/configuration-panel.component.ts +0 -120
- package/src/lib/panel/settings-panel/settings-panel.component.css +0 -30
- package/src/lib/panel/settings-panel/settings-panel.component.html +0 -28
- package/src/lib/panel/settings-panel/settings-panel.component.ts +0 -23
- package/src/public-api.ts +0 -8
- package/tsconfig.lib.json +0 -15
- package/tsconfig.lib.prod.json +0 -13
- package/tsconfig.spec.json +0 -15
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
<fx-settings-panel [fxData]="fxData" (configuration)="onChangeConfiguration($event)">
|
|
2
|
-
<div *ngIf="fxData">
|
|
3
|
-
<table style="width: 100%;" class="formBuilder_dynamic_table">
|
|
4
|
-
<thead>
|
|
5
|
-
<tr>
|
|
6
|
-
<th *ngFor="let column of tableConfig.columns">{{ column.header }}</th>
|
|
7
|
-
</tr>
|
|
8
|
-
</thead>
|
|
9
|
-
<tbody>
|
|
10
|
-
<tr *ngFor="let row of tableConfig.rows; let rowIndex = index">
|
|
11
|
-
<td *ngFor="let column of tableConfig.columns">
|
|
12
|
-
<ng-container [ngSwitch]="column.cellType">
|
|
13
|
-
<span [class]="column?.className" *ngSwitchCase="'text'">{{row[column.header]}}</span>
|
|
14
|
-
|
|
15
|
-
<input [class]="column?.className" *ngSwitchCase="'input-text'" type="text"
|
|
16
|
-
[(ngModel)]="row[column.header]" />
|
|
17
|
-
|
|
18
|
-
<input [class]="column?.className" *ngSwitchCase="'input-number'" type="number"
|
|
19
|
-
[(ngModel)]="row[column.header]" />
|
|
20
|
-
|
|
21
|
-
<select [class]="column?.className" *ngSwitchCase="'dropdown'"
|
|
22
|
-
[(ngModel)]="row[column.header]">
|
|
23
|
-
<option *ngFor="let option of column?.options" [value]="option?.optionValue">
|
|
24
|
-
{{ option?.optionName }}
|
|
25
|
-
</option>
|
|
26
|
-
</select>
|
|
27
|
-
|
|
28
|
-
<select [class]="column?.className" style="width: 60%;" *ngSwitchCase="'smart-dropdown'"
|
|
29
|
-
[(ngModel)]="row[column.header]">
|
|
30
|
-
<option *ngFor="let option of smartDropdownOptions[column.header]" [value]="option?.value">
|
|
31
|
-
{{option?.name }}
|
|
32
|
-
</option>
|
|
33
|
-
</select>
|
|
34
|
-
|
|
35
|
-
<input [class]="column?.className" *ngSwitchCase="'checkbox'" type="checkbox"
|
|
36
|
-
[(ngModel)]="row[column.header]" />
|
|
37
|
-
|
|
38
|
-
<input name="radio-{{rowIndex}}" [class]="column?.className" *ngSwitchCase="'radio'" type="radio"
|
|
39
|
-
[(ngModel)]="row[column.header]" />
|
|
40
|
-
|
|
41
|
-
<div [class]="column?.className" style="display: flex; justify-content: center; gap: 10px;"
|
|
42
|
-
*ngSwitchCase="'radio-group'">
|
|
43
|
-
<label *ngFor="let option of column.options">
|
|
44
|
-
<input name="radio-group-{{rowIndex}}" type="radio" [value]="option?.optionName"
|
|
45
|
-
[(ngModel)]="row[column.header]" />
|
|
46
|
-
{{ option?.optionName }}
|
|
47
|
-
</label>
|
|
48
|
-
</div>
|
|
49
|
-
|
|
50
|
-
<ng-container *ngSwitchCase="'file-upload'">
|
|
51
|
-
<div style="display: flex; flex-direction: column; align-items: end;justify-content: end;">
|
|
52
|
-
<img width="100" *ngIf="uploadedImages?.[rowIndex]?.['result']" [src]="uploadedImages[rowIndex]?.['result']"
|
|
53
|
-
alt="Uploaded Image" (click)="deleteFile(uploadedImages[rowIndex], rowIndex)"/>
|
|
54
|
-
<input [class]="column?.className" type="file" name="file" #uploadFile hidden multiple
|
|
55
|
-
(change)="uploadImage($event, rowIndex)" />
|
|
56
|
-
<button (click)="uploadFile.click()">Upload</button>
|
|
57
|
-
</div>
|
|
58
|
-
</ng-container>
|
|
59
|
-
|
|
60
|
-
<ng-container *ngSwitchCase="'textarea'">
|
|
61
|
-
<textarea [class]="column?.className" name="" id="" cols="30" rows="2"></textarea>
|
|
62
|
-
</ng-container>
|
|
63
|
-
</ng-container>
|
|
64
|
-
</td>
|
|
65
|
-
</tr>
|
|
66
|
-
</tbody>
|
|
67
|
-
</table>
|
|
68
|
-
</div>
|
|
69
|
-
</fx-settings-panel>
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import { AfterViewInit, ChangeDetectorRef, Component, inject, Input, NgZone, OnDestroy, OnInit } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
4
|
-
import { HttpClient } from '@angular/common/http';
|
|
5
|
-
import { FxBaseComponent, FxMode, FxSetting, FxStringSetting, FxValidation, FxValidatorService } from '@instantsys-labs/fx';
|
|
6
|
-
import { SettingsPanelComponent } from '../../panel/settings-panel/settings-panel.component';
|
|
7
|
-
import { FxBuilderWrapperService } from '../../fx-builder-wrapper.service';
|
|
8
|
-
import {Subject, takeUntil } from 'rxjs';
|
|
9
|
-
|
|
10
|
-
export interface TableColumnConfig {
|
|
11
|
-
header: string;
|
|
12
|
-
cellType: 'text' | 'input-text' | 'input-number' | 'dropdown' | 'smart-dropdown' | 'checkbox' | 'radio' | 'radio-group' | 'file-upload' | 'textarea';
|
|
13
|
-
placeholder?: string;
|
|
14
|
-
options?: string[];
|
|
15
|
-
apiUrl?: string;
|
|
16
|
-
valueKey?: string;
|
|
17
|
-
labelKey?: string;
|
|
18
|
-
className?: string;
|
|
19
|
-
}
|
|
20
|
-
export interface TableConfig {
|
|
21
|
-
columns: TableColumnConfig[];
|
|
22
|
-
rows: any[];
|
|
23
|
-
}
|
|
24
|
-
@Component({
|
|
25
|
-
selector: 'fx-dynamic-table',
|
|
26
|
-
standalone: true,
|
|
27
|
-
imports: [CommonModule, FormsModule, SettingsPanelComponent, ReactiveFormsModule],
|
|
28
|
-
templateUrl: './dynamic-table.component.html',
|
|
29
|
-
styleUrl: './dynamic-table.component.css',
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
export class DynamicTableComponent extends FxBaseComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
33
|
-
@Input() tableRows: Array<any> = [];
|
|
34
|
-
@Input() previewType: FxMode = FxMode.VIEW;
|
|
35
|
-
@Input() tableConfig: any = {
|
|
36
|
-
columns: [
|
|
37
|
-
{ header: 'Column 1', cellType: 'text' },
|
|
38
|
-
{ header: 'Column 2', cellType: 'text' },
|
|
39
|
-
{ header: 'Column 3', cellType: 'text' },
|
|
40
|
-
{ header: 'Column 4', cellType: 'text' },
|
|
41
|
-
{ header: 'Column 5', cellType: 'text' },
|
|
42
|
-
],
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
private destroy$ = new Subject<Boolean>();
|
|
46
|
-
public uploadedImages: Array<Record<string, string | File | null> | null> = [];
|
|
47
|
-
|
|
48
|
-
public tableFormControl = new FormControl();
|
|
49
|
-
public smartDropdownOptions: { [key: string]: Array<{ name: string, value: string }> } = {};
|
|
50
|
-
private http = inject(HttpClient);
|
|
51
|
-
constructor(private cdr: ChangeDetectorRef, private fxBuilderWrapperService: FxBuilderWrapperService) {
|
|
52
|
-
super(cdr);
|
|
53
|
-
this.onInit.subscribe((fxData)=>{
|
|
54
|
-
this._register(this.tableFormControl);
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public ngOnInit(): void {
|
|
59
|
-
this.fxBuilderWrapperService.variables$.pipe(
|
|
60
|
-
takeUntil(this.destroy$)).subscribe((variables: any) => {
|
|
61
|
-
if (variables) {
|
|
62
|
-
let dynamicTableValues: any;
|
|
63
|
-
for (const [key, value] of Object.entries(variables)) {
|
|
64
|
-
if (key.includes('dynamic-table')) {
|
|
65
|
-
dynamicTableValues = value;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (Object.keys(dynamicTableValues).length) {
|
|
69
|
-
// const fileHeaderName = dynamicTableValues?.columns.find((f: any) => f.cellType === 'file-upload')?.header;
|
|
70
|
-
const fileHeaderName = dynamicTableValues?.columns.find((f: any) => f.cellType === 'file-upload')?.header;
|
|
71
|
-
dynamicTableValues?.rows?.forEach((item: any, index: number) => {
|
|
72
|
-
// // this.uploadedImages[index] = item[fileHeaderName] ? item[fileHeaderName]: null;
|
|
73
|
-
// const fileUrl = item[fileHeaderName]; // Get the file URL
|
|
74
|
-
|
|
75
|
-
// this.uploadedImages[index] = fileUrl
|
|
76
|
-
// ? { result: fileUrl, file: null } // Store the URL as 'result'
|
|
77
|
-
// : null;
|
|
78
|
-
|
|
79
|
-
if (item[fileHeaderName]) {
|
|
80
|
-
this.parseUrls(item[fileHeaderName], index);
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
console.log("uploadedImages", this.uploadedImages);
|
|
84
|
-
console.log("dynamictable", dynamicTableValues);
|
|
85
|
-
this.tableConfig = dynamicTableValues;
|
|
86
|
-
this.fxData.value = this.tableConfig;
|
|
87
|
-
// this.tableFormControl.reset();
|
|
88
|
-
// this.tableFormControl.setValue(this.tableConfig);
|
|
89
|
-
this.tableFormControl = new FormControl();
|
|
90
|
-
setTimeout(() => { // Delay to ensure proper patching
|
|
91
|
-
this.tableFormControl.patchValue(this.tableConfig, { emitEvent: true });
|
|
92
|
-
console.log("tableFormControl",this.tableFormControl);
|
|
93
|
-
this.cdr.detectChanges();
|
|
94
|
-
}, 50);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
public ngAfterViewInit(): void {
|
|
101
|
-
setTimeout(() => {
|
|
102
|
-
if(this.fxData?.value && Object.keys(this.fxData?.value)?.length != 0) {
|
|
103
|
-
this.tableConfig = this.fxData.value;
|
|
104
|
-
this.fetchSmartDropdownData();
|
|
105
|
-
}
|
|
106
|
-
}, 100)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
protected fetchSmartDropdownData(): void {
|
|
110
|
-
this.tableConfig.columns
|
|
111
|
-
.filter((column: TableColumnConfig) => column.cellType === 'smart-dropdown' && column?.apiUrl)
|
|
112
|
-
.forEach((column: TableColumnConfig) => {
|
|
113
|
-
this.http.get<any>(column.apiUrl!).subscribe((response: any) => {
|
|
114
|
-
this.smartDropdownOptions[column.header] = response.map((item: any) => ({
|
|
115
|
-
value: item[column.valueKey!],
|
|
116
|
-
name: item[column.labelKey!],
|
|
117
|
-
}));
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
public uploadImage(event: Event, rowIndex: number): void {
|
|
123
|
-
const file = (event.target as HTMLInputElement).files?.[0];
|
|
124
|
-
if (file) {
|
|
125
|
-
const reader = new FileReader();
|
|
126
|
-
reader.onload = () => {
|
|
127
|
-
this.uploadedImages[rowIndex] = {
|
|
128
|
-
result: reader.result as string,
|
|
129
|
-
file: file
|
|
130
|
-
}
|
|
131
|
-
this.tableConfig.rows[rowIndex][this.tableConfig.columns.find((f: any) => f.cellType === 'file-upload')?.header] = file;
|
|
132
|
-
console.log("tableConfig", this.tableConfig);
|
|
133
|
-
};
|
|
134
|
-
reader.readAsDataURL(file);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
protected settings(): FxSetting[] {
|
|
139
|
-
return [
|
|
140
|
-
new FxStringSetting({ key: 'column-size', $title: 'No. of columns', value: 1 }),
|
|
141
|
-
new FxStringSetting({ key: 'table-config', $title: 'Table Configuration', value: {} }),
|
|
142
|
-
];
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
protected validations(): FxValidation[] {
|
|
146
|
-
return [FxValidatorService.required];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
public getArray(count: number): number[] {
|
|
150
|
-
return Array.from({ length: count });
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
public onChangeConfiguration(event: any): void {
|
|
154
|
-
const columns = event.columns.map((col: any) => {
|
|
155
|
-
return {
|
|
156
|
-
header: col?.header,
|
|
157
|
-
cellType: col?.cellType,
|
|
158
|
-
placeholder: col?.placeholder,
|
|
159
|
-
options: col?.options,
|
|
160
|
-
apiUrl: col?.apiUrl,
|
|
161
|
-
valueKey: col?.valueKey,
|
|
162
|
-
labelKey: col?.labelKey,
|
|
163
|
-
className: col?.className,
|
|
164
|
-
apiKey: col?.apiKey
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
if(!event?.enableAPI) {
|
|
168
|
-
this.tableConfig.columns = columns;
|
|
169
|
-
// this.tableConfig.rows = Array.from({ length: +event?.rows }, (e, index) => ({ name: `SKU-${index + 1}`, age: index % 2 !== 0, gender: 'male' }))
|
|
170
|
-
// this.tableConfig.rows = Array.from({ length: +event?.rows }, (e, index) => {
|
|
171
|
-
// const rows = columns.map((c: any) => {
|
|
172
|
-
// return {
|
|
173
|
-
// c?.header: null
|
|
174
|
-
// }
|
|
175
|
-
// })
|
|
176
|
-
// return rows
|
|
177
|
-
// })
|
|
178
|
-
this.tableConfig.rows = Array.from({ length: +event?.rows }, (_, index) => {
|
|
179
|
-
return columns.reduce((acc: any, c: any) => {
|
|
180
|
-
acc[c?.header] = ''; // Initialize each column key with null
|
|
181
|
-
return acc;
|
|
182
|
-
}, {});
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
this.fetchSmartDropdownData();
|
|
186
|
-
}
|
|
187
|
-
if(event?.enableAPI) {
|
|
188
|
-
this.drawTable(event, columns)
|
|
189
|
-
this.tableConfig = {
|
|
190
|
-
columns: columns,
|
|
191
|
-
rows: []
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
this.fxData.value = this.tableConfig;
|
|
196
|
-
this.tableFormControl.reset();
|
|
197
|
-
this.tableFormControl.setValue(this.tableConfig);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
private updateSettings(): void{
|
|
201
|
-
if(this.fxData.settings){
|
|
202
|
-
for(let setting of this.fxData.settings){
|
|
203
|
-
if(setting.key === 'table-config'){
|
|
204
|
-
setting.value = this.tableConfig;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
public drawTable(event: any, columns: any): void {
|
|
211
|
-
let rows;
|
|
212
|
-
this.http.get(event.api).subscribe((res: any) => {
|
|
213
|
-
if(res) {
|
|
214
|
-
rows = res.map((item: any) => {
|
|
215
|
-
const newObj: Record<string, any> = {};
|
|
216
|
-
columns.forEach((col: any) => {
|
|
217
|
-
newObj[col.header] = item[col.apiKey];
|
|
218
|
-
});
|
|
219
|
-
return newObj;
|
|
220
|
-
});
|
|
221
|
-
this.tableConfig = {
|
|
222
|
-
columns,
|
|
223
|
-
rows
|
|
224
|
-
}
|
|
225
|
-
this.fxData.value = this.tableConfig;
|
|
226
|
-
this.tableFormControl.reset();
|
|
227
|
-
this.tableFormControl.setValue(this.tableConfig);
|
|
228
|
-
}
|
|
229
|
-
})
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
public deleteFile(file: any, index: number): void {
|
|
233
|
-
this.uploadedImages.splice(index, 1, null);
|
|
234
|
-
this.tableConfig.rows[index][this.tableConfig.columns.find((f: any) => f.cellType === 'file-upload')?.header] = null;
|
|
235
|
-
console.log("tableConfig", this.tableConfig);
|
|
236
|
-
this.tableFormControl.setValue(this.tableConfig);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
public parseUrls(url: string, index: number): void {
|
|
240
|
-
this.http.get(url, { responseType: 'blob' }).subscribe({
|
|
241
|
-
next: (imageBlob: Blob) => {
|
|
242
|
-
const imageURL = URL.createObjectURL(imageBlob);
|
|
243
|
-
this.uploadedImages[index] = {
|
|
244
|
-
result: imageURL,
|
|
245
|
-
file: null
|
|
246
|
-
};
|
|
247
|
-
},
|
|
248
|
-
error: (error) => {
|
|
249
|
-
console.error('Error fetching image:', error);
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
public ngOnDestroy(): void {
|
|
255
|
-
this.destroy$.next(true);
|
|
256
|
-
this.destroy$.complete();
|
|
257
|
-
}
|
|
258
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { CommonModule } from '@angular/common';
|
|
2
|
-
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
|
|
3
|
-
import { FxForm, FxFormComponent } from '@instantsys-labs/fx';
|
|
4
|
-
import { DispatchToClinicComponent } from '../../custom-controls/dispatch-to-clinic/dispatch-to-clinic.component';
|
|
5
|
-
import { FxBuilderWrapperService } from '../../fx-builder-wrapper.service';
|
|
6
|
-
import { DynamicTableComponent } from '../dynamic-table/dynamic-table.component';
|
|
7
|
-
import { ToggleButtonComponent } from '../toggle-button/toggle-button.component';
|
|
8
|
-
import { UploaderComponent } from '../uploader/uploader.component';
|
|
9
|
-
import { ToggleComponent } from '../toggle/toggle.component';
|
|
10
|
-
|
|
11
|
-
@Component({
|
|
12
|
-
selector: 'fx-form-component',
|
|
13
|
-
standalone: true,
|
|
14
|
-
imports: [CommonModule, FxFormComponent],
|
|
15
|
-
template: `
|
|
16
|
-
<fx-form
|
|
17
|
-
[fxForm]="fxForm"
|
|
18
|
-
[value]="variables"
|
|
19
|
-
(onSubmit)="onSubmit($event)"
|
|
20
|
-
#form
|
|
21
|
-
>
|
|
22
|
-
</fx-form>
|
|
23
|
-
`,
|
|
24
|
-
})
|
|
25
|
-
export class FxFormWrapperComponent implements OnChanges, OnInit {
|
|
26
|
-
@ViewChild('form') form!: FxFormComponent;
|
|
27
|
-
@Input() fxForm!: FxForm;
|
|
28
|
-
@Input() variables: any;
|
|
29
|
-
@Output() fxFormSubmit = new EventEmitter<any>();
|
|
30
|
-
|
|
31
|
-
constructor(private fxWrapperService: FxBuilderWrapperService) {
|
|
32
|
-
this.registerCustomComponents();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public ngOnChanges(changes: SimpleChanges): void {
|
|
36
|
-
// if('variables' in changes && !changes['fxForm']) {
|
|
37
|
-
// this.fxWrapperService.variables$.next(this.variables);
|
|
38
|
-
// }
|
|
39
|
-
if ('variables' in changes) {
|
|
40
|
-
this.fxWrapperService.variables$.next(this.variables);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public ngOnInit(): void {
|
|
45
|
-
// if (!Boolean(this.fxWrapperService.getComponent('dispatch-to-clinic'))) {
|
|
46
|
-
// this.fxWrapperService.registerCustomComponent('Dispatch To Clinic', 'dispatch-to-clinic', DispatchToClinicComponent);
|
|
47
|
-
// }
|
|
48
|
-
// if (!Boolean(this.fxWrapperService.getComponent('dynamic-table'))) {
|
|
49
|
-
// this.fxWrapperService.registerCustomComponent('Dynamic Table', 'dynamic-table', DynamicTableComponent);
|
|
50
|
-
// }
|
|
51
|
-
// if (!Boolean(this.fxWrapperService.getComponent('toggle-button'))) {
|
|
52
|
-
// this.fxWrapperService.registerCustomComponent('Toggle Button', 'toggle-button', ToggleButtonComponent);
|
|
53
|
-
// }
|
|
54
|
-
// if (!Boolean(this.fxWrapperService.getComponent('uploader'))) {
|
|
55
|
-
// this.fxWrapperService.registerCustomComponent('Uploader', 'uploader', UploaderComponent);
|
|
56
|
-
// }
|
|
57
|
-
// if (!Boolean(this.fxWrapperService.getComponent('toggle'))) {
|
|
58
|
-
// this.fxWrapperService.registerCustomComponent('Toggle', 'toggle', ToggleComponent);
|
|
59
|
-
// }
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
private registerCustomComponents(): void {
|
|
64
|
-
const components = [
|
|
65
|
-
{ name: 'Dispatch To Clinic', key: 'dispatch-to-clinic', component: DispatchToClinicComponent },
|
|
66
|
-
{ name: 'Dynamic Table', key: 'dynamic-table', component: DynamicTableComponent },
|
|
67
|
-
{ name: 'Toggle Button', key: 'toggle-button', component: ToggleButtonComponent },
|
|
68
|
-
{ name: 'Uploader', key: 'uploader', component: UploaderComponent },
|
|
69
|
-
{ name: 'Toggle', key: 'toggle', component: ToggleComponent }
|
|
70
|
-
];
|
|
71
|
-
|
|
72
|
-
components.forEach(({ name, key, component }) => {
|
|
73
|
-
if (!this.fxWrapperService.getComponent(key)) {
|
|
74
|
-
this.fxWrapperService.registerCustomComponent(name, key, component);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public onSubmit(event: any): void {
|
|
80
|
-
this.fxFormSubmit.emit(event);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public submit(): void {
|
|
84
|
-
this.form.submit();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
label {
|
|
2
|
-
position: relative;
|
|
3
|
-
white-space: nowrap;
|
|
4
|
-
border-radius: 0;
|
|
5
|
-
border: 0 solid #999999;
|
|
6
|
-
margin: 0 14px 0 0;
|
|
7
|
-
width: 120px;
|
|
8
|
-
height: auto;
|
|
9
|
-
padding: 0;
|
|
10
|
-
text-align: center;
|
|
11
|
-
cursor: pointer;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.form-radio {
|
|
15
|
-
background-color: #DAE6F0;
|
|
16
|
-
color: white;
|
|
17
|
-
box-shadow: none;
|
|
18
|
-
transition: background-color 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
|
|
19
|
-
border: 1px solid #DEDEDE;
|
|
20
|
-
padding: 9px 10px;
|
|
21
|
-
margin: 0;
|
|
22
|
-
white-space: nowrap;
|
|
23
|
-
width: 100%;
|
|
24
|
-
height: 38px;
|
|
25
|
-
background-image: none;
|
|
26
|
-
border-radius: 4px;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.form-radio:checked {
|
|
30
|
-
background-color: #ADD8E6;
|
|
31
|
-
border-color: #9BBBD6;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.form-radio:focus {
|
|
35
|
-
box-shadow: 0 0 0 2px #fff, 0 0 0 4px #9dc1fb, 0 1px 2px 0 black;
|
|
36
|
-
background-color: #ADD8E6;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.form-radio:hover {
|
|
40
|
-
border-color: #4682B4;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
span {
|
|
44
|
-
position: absolute;
|
|
45
|
-
left: 0;
|
|
46
|
-
right: 0;
|
|
47
|
-
top: 8px;
|
|
48
|
-
bottom: 0;
|
|
49
|
-
margin: 0;
|
|
50
|
-
padding: 0;
|
|
51
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<fx-component [fxData]="fxData">
|
|
2
|
-
<div style="display: flex;">
|
|
3
|
-
<label>
|
|
4
|
-
<input [formControl]="toggleControl" type="radio" name="radio_grp" class="form-radio mr-3" value="true">
|
|
5
|
-
<span class="mt-1">{{setting('accept')}}</span>
|
|
6
|
-
</label>
|
|
7
|
-
<label>
|
|
8
|
-
<input [formControl]="toggleControl" type="radio" name="radio_grp" class="form-radio mr-3" value="false">
|
|
9
|
-
<span class="mt-1">{{setting('reject')}}</span>
|
|
10
|
-
</label>
|
|
11
|
-
</div>
|
|
12
|
-
</fx-component>
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { CommonModule } from '@angular/common';
|
|
2
|
-
import { ChangeDetectorRef, Component, inject } from '@angular/core';
|
|
3
|
-
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
4
|
-
import { FxBaseComponent, FxComponent, FxSetting, FxStringSetting, FxValidation, FxValidatorService } from '@instantsys-labs/fx';
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
selector: 'fx-toggle',
|
|
8
|
-
standalone: true,
|
|
9
|
-
imports: [CommonModule, FxComponent, FormsModule, ReactiveFormsModule],
|
|
10
|
-
templateUrl: './toggle.component.html',
|
|
11
|
-
styleUrl: './toggle.component.css'
|
|
12
|
-
})
|
|
13
|
-
export class ToggleComponent extends FxBaseComponent {
|
|
14
|
-
public toggleControl = new FormControl<boolean>(false)
|
|
15
|
-
|
|
16
|
-
constructor(private cdr: ChangeDetectorRef) {
|
|
17
|
-
super(cdr)
|
|
18
|
-
this.onInit.subscribe((fxData)=>{
|
|
19
|
-
this._register(this.toggleControl);
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
protected settings(): FxSetting[] {
|
|
24
|
-
return [
|
|
25
|
-
new FxStringSetting({ key: 'accept', $title: 'Accept Text', value: 'Yes' }),
|
|
26
|
-
new FxStringSetting({ key: 'reject', $title: 'Reject Text', value: 'No' })
|
|
27
|
-
];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
protected validations(): FxValidation[] {
|
|
31
|
-
return [FxValidatorService.required];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
.custom-toggle-btn {
|
|
2
|
-
padding: 10px 20px;
|
|
3
|
-
font-size: 16px;
|
|
4
|
-
font-weight: bold;
|
|
5
|
-
color: white;
|
|
6
|
-
border: none;
|
|
7
|
-
border-radius: 5px;
|
|
8
|
-
cursor: pointer;
|
|
9
|
-
background-color: #ccc;
|
|
10
|
-
transition: background-color 0.3s;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.custom-toggle-btn.active {
|
|
14
|
-
background-color: #4caf50;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.custom-toggle-btn:hover {
|
|
18
|
-
opacity: 0.9;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<fx-component [fxData]="fxData">
|
|
2
|
-
<button
|
|
3
|
-
class="custom-toggle-btn"
|
|
4
|
-
[class]="setting('classes') ? setting('classes'): ''"
|
|
5
|
-
[class.active]="toggleBtnControl.value"
|
|
6
|
-
(click)="toggle()"
|
|
7
|
-
>
|
|
8
|
-
{{ toggleBtnControl.value ? setting('active-text') : setting('inactive-text') }}
|
|
9
|
-
</button>
|
|
10
|
-
</fx-component>
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { CommonModule } from '@angular/common';
|
|
2
|
-
import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
|
|
3
|
-
import { FormControl, FormsModule, ReactiveFormsModule, UntypedFormControl } from '@angular/forms';
|
|
4
|
-
import { FxBaseComponent, FxComponent, FxIconSetting, FxSetting, FxStringSetting, FxValidation, FxValidatorService } from '@instantsys-labs/fx';
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
selector: 'lib-toggle-button',
|
|
8
|
-
standalone: true,
|
|
9
|
-
imports: [CommonModule, FxComponent, ReactiveFormsModule, FormsModule],
|
|
10
|
-
templateUrl: './toggle-button.component.html',
|
|
11
|
-
styleUrl: './toggle-button.component.css'
|
|
12
|
-
})
|
|
13
|
-
export class ToggleButtonComponent extends FxBaseComponent {
|
|
14
|
-
public toggleBtnControl = new UntypedFormControl(false);
|
|
15
|
-
public isToggled = false;
|
|
16
|
-
|
|
17
|
-
constructor(private cdr: ChangeDetectorRef) {
|
|
18
|
-
super(cdr);
|
|
19
|
-
this.onInit.subscribe((fxData)=>{
|
|
20
|
-
this._register(this.toggleBtnControl);
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public toggle(): void {
|
|
25
|
-
this.isToggled = !this.toggleBtnControl.value;
|
|
26
|
-
this.toggleBtnControl.setValue(this.isToggled);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
protected settings(): FxSetting[] {
|
|
30
|
-
return [
|
|
31
|
-
new FxStringSetting({ key: 'classes', $title: 'Classes', value: '' }),
|
|
32
|
-
new FxStringSetting({ key: 'active-text', $title: 'Active Text', value: 'On' }),
|
|
33
|
-
new FxStringSetting({ key: 'inactive-text', $title: 'Inactive Text', value: 'Off' }),
|
|
34
|
-
];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
protected validations(): FxValidation[] {
|
|
38
|
-
return [FxValidatorService.required];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
.custom-upload {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: row;
|
|
4
|
-
align-items: flex-start;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.custom-upload button {
|
|
8
|
-
padding: 10px 20px;
|
|
9
|
-
font-size: 16px;
|
|
10
|
-
font-weight: bold;
|
|
11
|
-
color: white;
|
|
12
|
-
background-color: #007bff;
|
|
13
|
-
border: none;
|
|
14
|
-
border-radius: 5px;
|
|
15
|
-
cursor: pointer;
|
|
16
|
-
transition: background-color 0.3s;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.custom-upload button:hover {
|
|
20
|
-
background-color: #0056b3;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.custom-upload .file-list {
|
|
24
|
-
display: flex;
|
|
25
|
-
/* margin-top: 10px; */
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.custom-upload .file-list p {
|
|
29
|
-
margin: 0;
|
|
30
|
-
padding: 5px;
|
|
31
|
-
background-color: #f1f1f1;
|
|
32
|
-
border: 1px solid #ddd;
|
|
33
|
-
border-radius: 3px;
|
|
34
|
-
font-size: 14px;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.custom-upload .file-list > div {
|
|
38
|
-
display: flex;
|
|
39
|
-
flex-direction: column;
|
|
40
|
-
align-items: center;
|
|
41
|
-
justify-content: center;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.custom-upload .file-list .file-thumbnail {
|
|
45
|
-
width: 100px;
|
|
46
|
-
height: 100px;
|
|
47
|
-
object-fit: contain;
|
|
48
|
-
}
|
|
49
|
-
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<fx-component [fxData]="fxData">
|
|
2
|
-
<div class="custom-upload">
|
|
3
|
-
<button type="button" (click)="fileInput.click()">
|
|
4
|
-
{{setting('upload-text')}}
|
|
5
|
-
</button>
|
|
6
|
-
<input
|
|
7
|
-
#fileInput
|
|
8
|
-
type="file"
|
|
9
|
-
[multiple]="setting('multiple-upload')"
|
|
10
|
-
(change)="onFileSelected($event)"
|
|
11
|
-
[formControl]="uploadFileControl"
|
|
12
|
-
hidden
|
|
13
|
-
/>
|
|
14
|
-
<div class="file-list">
|
|
15
|
-
<ng-container *ngIf="uploadedFiles?.length">
|
|
16
|
-
<div (click)="deleteFile(file?.id)" *ngFor="let file of uploadedFiles">
|
|
17
|
-
<img class="file-thumbnail" style="border-radius: 4px" [src]="file?.previewUrl" alt="">
|
|
18
|
-
<!-- <p>{{file?.name}}</p> -->
|
|
19
|
-
</div>
|
|
20
|
-
</ng-container>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
</fx-component>
|