ciyidogan commited on
Commit
2911ce4
·
verified ·
1 Parent(s): 23aadc9

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
@@ -214,6 +214,46 @@ export default class IntentEditDialogComponent implements OnInit {
214
  }
215
  }
216
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  // Parameter caption management
218
  getCaptionDisplay(captions: LocalizedCaption[]): string {
219
  if (!captions || captions.length === 0) return '(No caption)';
@@ -231,7 +271,7 @@ export default class IntentEditDialogComponent implements OnInit {
231
  const currentCaptions = param.get('caption')?.value || [];
232
 
233
  // Import and open caption dialog
234
- const { default: CaptionDialogComponent } = await import('./caption-dialog.component');
235
 
236
  const dialogRef = this.dialog.open(CaptionDialogComponent, {
237
  width: '600px',
@@ -291,6 +331,10 @@ export default class IntentEditDialogComponent implements OnInit {
291
  }
292
  }
293
 
 
 
 
 
294
  cancel() {
295
  this.dialogRef.close();
296
  }
 
214
  }
215
  }
216
 
217
+ // Test regex functionality
218
+ testRegex(paramIndex: number) {
219
+ const param = this.parameters.at(paramIndex);
220
+ const regex = param.get('validation_regex')?.value;
221
+
222
+ if (!regex) {
223
+ this.snackBar.open('No regex pattern to test', 'Close', { duration: 2000 });
224
+ return;
225
+ }
226
+
227
+ // Simple test implementation
228
+ const testValue = prompt('Enter a test value:');
229
+ if (testValue !== null) {
230
+ try {
231
+ const pattern = new RegExp(regex);
232
+ const matches = pattern.test(testValue);
233
+ this.snackBar.open(
234
+ matches ? '✓ Pattern matches!' : '✗ Pattern does not match',
235
+ 'Close',
236
+ { duration: 3000 }
237
+ );
238
+ } catch (e) {
239
+ this.snackBar.open('Invalid regex pattern', 'Close', { duration: 3000 });
240
+ }
241
+ }
242
+ }
243
+
244
+ // Move parameter up or down
245
+ moveParameter(index: number, direction: 'up' | 'down') {
246
+ const newIndex = direction === 'up' ? index - 1 : index + 1;
247
+
248
+ if (newIndex < 0 || newIndex >= this.parameters.length) {
249
+ return;
250
+ }
251
+
252
+ const currentItem = this.parameters.at(index);
253
+ this.parameters.removeAt(index);
254
+ this.parameters.insert(newIndex, currentItem);
255
+ }
256
+
257
  // Parameter caption management
258
  getCaptionDisplay(captions: LocalizedCaption[]): string {
259
  if (!captions || captions.length === 0) return '(No caption)';
 
271
  const currentCaptions = param.get('caption')?.value || [];
272
 
273
  // Import and open caption dialog
274
+ const { default: CaptionDialogComponent } = await import('../caption-dialog/caption-dialog.component');
275
 
276
  const dialogRef = this.dialog.open(CaptionDialogComponent, {
277
  width: '600px',
 
331
  }
332
  }
333
 
334
+ save() {
335
+ this.onSubmit();
336
+ }
337
+
338
  cancel() {
339
  this.dialogRef.close();
340
  }