Spaces:
Running
Running
Update flare-ui/src/app/dialogs/intent-edit-dialog/intent-edit-dialog.component.ts
Browse files
flare-ui/src/app/dialogs/intent-edit-dialog/intent-edit-dialog.component.ts
CHANGED
@@ -77,27 +77,32 @@ export default class IntentEditDialogComponent implements OnInit {
|
|
77 |
}
|
78 |
|
79 |
populateForm(intent: any) {
|
|
|
80 |
this.form.patchValue({
|
81 |
-
name: intent.name,
|
82 |
-
caption: intent.caption,
|
83 |
-
locale: intent.locale,
|
84 |
-
detection_prompt: intent.detection_prompt,
|
85 |
-
action: intent.action,
|
86 |
-
fallback_timeout_prompt: intent.fallback_timeout_prompt,
|
87 |
-
fallback_error_prompt: intent.fallback_error_prompt
|
88 |
});
|
89 |
|
90 |
-
//
|
91 |
-
if (intent.examples) {
|
92 |
const examplesArray = this.form.get('examples') as FormArray;
|
|
|
93 |
intent.examples.forEach((example: string) => {
|
94 |
-
|
|
|
|
|
95 |
});
|
96 |
}
|
97 |
|
98 |
-
//
|
99 |
-
if (intent.parameters) {
|
100 |
const parametersArray = this.form.get('parameters') as FormArray;
|
|
|
101 |
intent.parameters.forEach((param: any) => {
|
102 |
parametersArray.push(this.createParameterFormGroup(param));
|
103 |
});
|
@@ -127,12 +132,13 @@ export default class IntentEditDialogComponent implements OnInit {
|
|
127 |
}
|
128 |
|
129 |
addExample() {
|
130 |
-
|
131 |
-
|
|
|
132 |
this.newExample = '';
|
133 |
}
|
134 |
}
|
135 |
-
|
136 |
removeExample(index: number) {
|
137 |
this.examples.removeAt(index);
|
138 |
}
|
@@ -190,7 +196,15 @@ export default class IntentEditDialogComponent implements OnInit {
|
|
190 |
}
|
191 |
|
192 |
const formValue = this.form.value;
|
193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
}
|
195 |
|
196 |
cancel() {
|
|
|
77 |
}
|
78 |
|
79 |
populateForm(intent: any) {
|
80 |
+
// Önce basit alanları doldur
|
81 |
this.form.patchValue({
|
82 |
+
name: intent.name || '',
|
83 |
+
caption: intent.caption || '',
|
84 |
+
locale: intent.locale || 'tr-TR',
|
85 |
+
detection_prompt: intent.detection_prompt || '',
|
86 |
+
action: intent.action || '',
|
87 |
+
fallback_timeout_prompt: intent.fallback_timeout_prompt || '',
|
88 |
+
fallback_error_prompt: intent.fallback_error_prompt || ''
|
89 |
});
|
90 |
|
91 |
+
// Examples array'ini doldur
|
92 |
+
if (intent.examples && Array.isArray(intent.examples)) {
|
93 |
const examplesArray = this.form.get('examples') as FormArray;
|
94 |
+
examplesArray.clear();
|
95 |
intent.examples.forEach((example: string) => {
|
96 |
+
if (typeof example === 'string') {
|
97 |
+
examplesArray.push(this.fb.control(example));
|
98 |
+
}
|
99 |
});
|
100 |
}
|
101 |
|
102 |
+
// Parameters array'ini doldur
|
103 |
+
if (intent.parameters && Array.isArray(intent.parameters)) {
|
104 |
const parametersArray = this.form.get('parameters') as FormArray;
|
105 |
+
parametersArray.clear();
|
106 |
intent.parameters.forEach((param: any) => {
|
107 |
parametersArray.push(this.createParameterFormGroup(param));
|
108 |
});
|
|
|
132 |
}
|
133 |
|
134 |
addExample() {
|
135 |
+
const trimmedExample = this.newExample?.trim();
|
136 |
+
if (trimmedExample) {
|
137 |
+
this.examples.push(this.fb.control(trimmedExample));
|
138 |
this.newExample = '';
|
139 |
}
|
140 |
}
|
141 |
+
|
142 |
removeExample(index: number) {
|
143 |
this.examples.removeAt(index);
|
144 |
}
|
|
|
196 |
}
|
197 |
|
198 |
const formValue = this.form.value;
|
199 |
+
|
200 |
+
// Examples array'ini düzgün formatta döndür
|
201 |
+
const result = {
|
202 |
+
...formValue,
|
203 |
+
examples: formValue.examples || [],
|
204 |
+
parameters: formValue.parameters || []
|
205 |
+
};
|
206 |
+
|
207 |
+
this.dialogRef.close(result);
|
208 |
}
|
209 |
|
210 |
cancel() {
|