Spaces:
Paused
Paused
Update flare-ui/src/app/dialogs/api-edit-dialog/api-edit-dialog.component.ts
Browse files
flare-ui/src/app/dialogs/api-edit-dialog/api-edit-dialog.component.ts
CHANGED
|
@@ -52,6 +52,9 @@ export default class ApiEditDialogComponent implements OnInit {
|
|
| 52 |
retryStrategies = ['static', 'exponential'];
|
| 53 |
variableTypes = ['str', 'int', 'float', 'bool', 'date'];
|
| 54 |
|
|
|
|
|
|
|
|
|
|
| 55 |
constructor(
|
| 56 |
private fb: FormBuilder,
|
| 57 |
private apiService: ApiService,
|
|
@@ -567,4 +570,39 @@ export default class ApiEditDialogComponent implements OnInit {
|
|
| 567 |
cancel() {
|
| 568 |
this.dialogRef.close(false);
|
| 569 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 570 |
}
|
|
|
|
| 52 |
retryStrategies = ['static', 'exponential'];
|
| 53 |
variableTypes = ['str', 'int', 'float', 'bool', 'date'];
|
| 54 |
|
| 55 |
+
// ✅ Cursor position tracking
|
| 56 |
+
private cursorPositions: { [key: string]: number } = {};
|
| 57 |
+
|
| 58 |
constructor(
|
| 59 |
private fb: FormBuilder,
|
| 60 |
private apiService: ApiService,
|
|
|
|
| 570 |
cancel() {
|
| 571 |
this.dialogRef.close(false);
|
| 572 |
}
|
| 573 |
+
|
| 574 |
+
saveCursorPosition(field: string, event: any) {
|
| 575 |
+
const textarea = event.target;
|
| 576 |
+
this.cursorPositions[field] = textarea.selectionStart;
|
| 577 |
+
}
|
| 578 |
+
|
| 579 |
+
insertTemplateVariable(field: string, variable: string) {
|
| 580 |
+
const control = field.includes('.')
|
| 581 |
+
? this.form.get(field)
|
| 582 |
+
: this.form.get(field);
|
| 583 |
+
|
| 584 |
+
if (control) {
|
| 585 |
+
const currentValue = control.value || '';
|
| 586 |
+
const variableText = `{{${variable}}}`;
|
| 587 |
+
const cursorPos = this.cursorPositions[field] || currentValue.length;
|
| 588 |
+
|
| 589 |
+
// ✅ Değişkeni cursor pozisyonuna ekle
|
| 590 |
+
const newValue =
|
| 591 |
+
currentValue.slice(0, cursorPos) +
|
| 592 |
+
variableText +
|
| 593 |
+
currentValue.slice(cursorPos);
|
| 594 |
+
|
| 595 |
+
control.setValue(newValue);
|
| 596 |
+
|
| 597 |
+
// ✅ Cursor pozisyonunu güncelle (değişken sonrası)
|
| 598 |
+
setTimeout(() => {
|
| 599 |
+
const textarea = document.querySelector(`textarea[formControlName="${field}"]`) as HTMLTextAreaElement;
|
| 600 |
+
if (textarea) {
|
| 601 |
+
const newPos = cursorPos + variableText.length;
|
| 602 |
+
textarea.setSelectionRange(newPos, newPos);
|
| 603 |
+
textarea.focus();
|
| 604 |
+
}
|
| 605 |
+
}, 0);
|
| 606 |
+
}
|
| 607 |
+
}
|
| 608 |
}
|