another fix for export import templates

This commit is contained in:
Simon Pocrnjič 2025-12-28 14:46:18 +01:00
parent b9f66cbfbe
commit 082a637719
3 changed files with 41 additions and 20 deletions

View File

@ -22,6 +22,11 @@ class ImportTemplate extends Model
'reactivate' => 'boolean', 'reactivate' => 'boolean',
]; ];
public function getRouteKeyName(): string
{
return 'uuid';
}
public function user(): BelongsTo public function user(): BelongsTo
{ {
return $this->belongsTo(User::class); return $this->belongsTo(User::class);

View File

@ -125,7 +125,23 @@ function handleFileChange(event) {
} }
function performImport() { function performImport() {
importForm.post(route("importTemplates.import"), { // Convert string IDs to integers before submitting
const formData = {
...importForm.data(),
segment_id: importForm.segment_id ? parseInt(importForm.segment_id) : null,
decision_id: importForm.decision_id ? parseInt(importForm.decision_id) : null,
action_id: importForm.action_id ? parseInt(importForm.action_id) : null,
activity_action_id: importForm.activity_action_id
? parseInt(importForm.activity_action_id)
: null,
activity_decision_id: importForm.activity_decision_id
? parseInt(importForm.activity_decision_id)
: null,
};
importForm
.transform(() => formData)
.post(route("importTemplates.import"), {
preserveScroll: true, preserveScroll: true,
onSuccess: () => { onSuccess: () => {
importModalOpen.value = false; importModalOpen.value = false;
@ -271,14 +287,14 @@ const props = defineProps({
<AlertDialogCancel @click="cancelDelete" :disabled="deleteForm.processing"> <AlertDialogCancel @click="cancelDelete" :disabled="deleteForm.processing">
Prekliči Prekliči
</AlertDialogCancel> </AlertDialogCancel>
<AlertDialogAction <Button
@click="performDelete" @click="performDelete"
:disabled="deleteForm.processing" :disabled="deleteForm.processing"
class="bg-destructive hover:bg-destructive/90" class="bg-destructive hover:bg-destructive/90"
> >
<span v-if="deleteForm.processing">Brisanje</span> <span v-if="deleteForm.processing">Brisanje</span>
<span v-else>Izbriši</span> <span v-else>Izbriši</span>
</AlertDialogAction> </Button>
</AlertDialogFooter> </AlertDialogFooter>
</AlertDialogContent> </AlertDialogContent>
</AlertDialog> </AlertDialog>