Spaces:
Paused
Paused
Update flare-ui/src/app/dialogs/version-edit-dialog/version-edit-dialog.component.ts
Browse files
flare-ui/src/app/dialogs/version-edit-dialog/version-edit-dialog.component.ts
CHANGED
|
@@ -71,7 +71,7 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
| 71 |
@Inject(MAT_DIALOG_DATA) public data: any
|
| 72 |
) {
|
| 73 |
this.project = data.project;
|
| 74 |
-
this.versions = [...this.project.versions].sort((a, b) => b.
|
| 75 |
}
|
| 76 |
|
| 77 |
ngOnInit() {
|
|
@@ -93,7 +93,7 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
| 93 |
|
| 94 |
initializeForm() {
|
| 95 |
this.versionForm = this.fb.group({
|
| 96 |
-
|
| 97 |
caption: ['', Validators.required],
|
| 98 |
published: [{value: false, disabled: true}],
|
| 99 |
general_prompt: ['', Validators.required],
|
|
@@ -130,7 +130,7 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
| 130 |
|
| 131 |
// Form değerlerini set et
|
| 132 |
this.versionForm.patchValue({
|
| 133 |
-
|
| 134 |
caption: version.caption || '',
|
| 135 |
published: version.published || false,
|
| 136 |
general_prompt: (version as any).general_prompt || '', // Backend'den gelen general_prompt
|
|
@@ -169,11 +169,11 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
| 169 |
const project = await this.apiService.getProject(this.project.id).toPromise();
|
| 170 |
if (project) {
|
| 171 |
this.project = project;
|
| 172 |
-
this.versions = [...project.versions].sort((a, b) => b.
|
| 173 |
|
| 174 |
// Re-select current version if it still exists
|
| 175 |
if (this.selectedVersion) {
|
| 176 |
-
const currentVersion = this.versions.find(v => v.
|
| 177 |
if (currentVersion) {
|
| 178 |
this.loadVersion(currentVersion);
|
| 179 |
} else if (this.versions.length > 0) {
|
|
@@ -360,8 +360,8 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
| 360 |
message: 'Which published version would you like to use as a base for the new version?',
|
| 361 |
showDropdown: true,
|
| 362 |
dropdownOptions: publishedVersions.map(v => ({ // ✅ publishedVersions kullan
|
| 363 |
-
value: v.
|
| 364 |
-
label: `Version ${v.
|
| 365 |
})),
|
| 366 |
dropdownPlaceholder: 'Select published version (or leave empty for blank)',
|
| 367 |
confirmText: 'Create',
|
|
@@ -377,15 +377,15 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
| 377 |
|
| 378 |
if (result.selectedValue) {
|
| 379 |
// Copy from selected version
|
| 380 |
-
const sourceVersion = this.versions.find(v => v.
|
| 381 |
if (sourceVersion) {
|
| 382 |
newVersionData = {
|
| 383 |
...sourceVersion,
|
| 384 |
-
|
| 385 |
published: false,
|
| 386 |
last_update_date: undefined,
|
| 387 |
-
caption: `Copy of version ${sourceVersion.
|
| 388 |
-
description: sourceVersion.caption ? `Copy of ${sourceVersion.caption}` : `Copy of version ${sourceVersion.
|
| 389 |
};
|
| 390 |
}
|
| 391 |
} else {
|
|
@@ -492,7 +492,7 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
| 492 |
|
| 493 |
const result = await this.apiService.updateVersion(
|
| 494 |
this.project.id,
|
| 495 |
-
currentVersion.
|
| 496 |
updateData
|
| 497 |
).toPromise();
|
| 498 |
|
|
@@ -564,7 +564,7 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
| 564 |
try {
|
| 565 |
await this.apiService.updateVersion(
|
| 566 |
this.project.id,
|
| 567 |
-
currentVersion.
|
| 568 |
retryUpdateData,
|
| 569 |
true
|
| 570 |
).toPromise();
|
|
@@ -601,7 +601,7 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
| 601 |
try {
|
| 602 |
await this.apiService.publishVersion(
|
| 603 |
this.project.id,
|
| 604 |
-
this.selectedVersion.
|
| 605 |
).toPromise();
|
| 606 |
|
| 607 |
this.snackBar.open('Version published successfully', 'Close', { duration: 3000 });
|
|
@@ -639,7 +639,7 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
| 639 |
try {
|
| 640 |
await this.apiService.deleteVersion(
|
| 641 |
this.project.id,
|
| 642 |
-
this.selectedVersion.
|
| 643 |
).toPromise();
|
| 644 |
|
| 645 |
this.snackBar.open('Version deleted successfully', 'Close', { duration: 3000 });
|
|
@@ -738,7 +738,7 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
| 738 |
|
| 739 |
if (updatedProject) {
|
| 740 |
this.project = updatedProject;
|
| 741 |
-
this.versions = [...updatedProject.versions].sort((a, b) => b.
|
| 742 |
}
|
| 743 |
} catch (error) {
|
| 744 |
console.error('Failed to reload project:', error);
|
|
|
|
| 71 |
@Inject(MAT_DIALOG_DATA) public data: any
|
| 72 |
) {
|
| 73 |
this.project = data.project;
|
| 74 |
+
this.versions = [...this.project.versions].sort((a, b) => b.no - a.no);
|
| 75 |
}
|
| 76 |
|
| 77 |
ngOnInit() {
|
|
|
|
| 93 |
|
| 94 |
initializeForm() {
|
| 95 |
this.versionForm = this.fb.group({
|
| 96 |
+
no: [{value: '', disabled: true}],
|
| 97 |
caption: ['', Validators.required],
|
| 98 |
published: [{value: false, disabled: true}],
|
| 99 |
general_prompt: ['', Validators.required],
|
|
|
|
| 130 |
|
| 131 |
// Form değerlerini set et
|
| 132 |
this.versionForm.patchValue({
|
| 133 |
+
no: version.no,
|
| 134 |
caption: version.caption || '',
|
| 135 |
published: version.published || false,
|
| 136 |
general_prompt: (version as any).general_prompt || '', // Backend'den gelen general_prompt
|
|
|
|
| 169 |
const project = await this.apiService.getProject(this.project.id).toPromise();
|
| 170 |
if (project) {
|
| 171 |
this.project = project;
|
| 172 |
+
this.versions = [...project.versions].sort((a, b) => b.no - a.no);
|
| 173 |
|
| 174 |
// Re-select current version if it still exists
|
| 175 |
if (this.selectedVersion) {
|
| 176 |
+
const currentVersion = this.versions.find(v => v.no === this.selectedVersion!.no);
|
| 177 |
if (currentVersion) {
|
| 178 |
this.loadVersion(currentVersion);
|
| 179 |
} else if (this.versions.length > 0) {
|
|
|
|
| 360 |
message: 'Which published version would you like to use as a base for the new version?',
|
| 361 |
showDropdown: true,
|
| 362 |
dropdownOptions: publishedVersions.map(v => ({ // ✅ publishedVersions kullan
|
| 363 |
+
value: v.no,
|
| 364 |
+
label: `Version ${v.no} - ${v.caption || 'No description'}`
|
| 365 |
})),
|
| 366 |
dropdownPlaceholder: 'Select published version (or leave empty for blank)',
|
| 367 |
confirmText: 'Create',
|
|
|
|
| 377 |
|
| 378 |
if (result.selectedValue) {
|
| 379 |
// Copy from selected version
|
| 380 |
+
const sourceVersion = this.versions.find(v => v.no === result.selectedValue);
|
| 381 |
if (sourceVersion) {
|
| 382 |
newVersionData = {
|
| 383 |
...sourceVersion,
|
| 384 |
+
no: undefined,
|
| 385 |
published: false,
|
| 386 |
last_update_date: undefined,
|
| 387 |
+
caption: `Copy of version ${sourceVersion.no}`,
|
| 388 |
+
description: sourceVersion.caption ? `Copy of ${sourceVersion.caption}` : `Copy of version ${sourceVersion.no}`
|
| 389 |
};
|
| 390 |
}
|
| 391 |
} else {
|
|
|
|
| 492 |
|
| 493 |
const result = await this.apiService.updateVersion(
|
| 494 |
this.project.id,
|
| 495 |
+
currentVersion.no,
|
| 496 |
updateData
|
| 497 |
).toPromise();
|
| 498 |
|
|
|
|
| 564 |
try {
|
| 565 |
await this.apiService.updateVersion(
|
| 566 |
this.project.id,
|
| 567 |
+
currentVersion.no,
|
| 568 |
retryUpdateData,
|
| 569 |
true
|
| 570 |
).toPromise();
|
|
|
|
| 601 |
try {
|
| 602 |
await this.apiService.publishVersion(
|
| 603 |
this.project.id,
|
| 604 |
+
this.selectedVersion.no
|
| 605 |
).toPromise();
|
| 606 |
|
| 607 |
this.snackBar.open('Version published successfully', 'Close', { duration: 3000 });
|
|
|
|
| 639 |
try {
|
| 640 |
await this.apiService.deleteVersion(
|
| 641 |
this.project.id,
|
| 642 |
+
this.selectedVersion.no
|
| 643 |
).toPromise();
|
| 644 |
|
| 645 |
this.snackBar.open('Version deleted successfully', 'Close', { duration: 3000 });
|
|
|
|
| 738 |
|
| 739 |
if (updatedProject) {
|
| 740 |
this.project = updatedProject;
|
| 741 |
+
this.versions = [...updatedProject.versions].sort((a, b) => b.no - a.no);
|
| 742 |
}
|
| 743 |
} catch (error) {
|
| 744 |
console.error('Failed to reload project:', error);
|