From 66a377177dc4beba6db68068b5633a890d8a27f7 Mon Sep 17 00:00:00 2001 From: Chirag Chhatrala Date: Thu, 13 Feb 2025 16:54:55 +0530 Subject: [PATCH 1/4] when duplicate remove removed_properties --- api/app/Http/Controllers/Forms/FormController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/api/app/Http/Controllers/Forms/FormController.php b/api/app/Http/Controllers/Forms/FormController.php index ac987b1a9..084a33b85 100644 --- a/api/app/Http/Controllers/Forms/FormController.php +++ b/api/app/Http/Controllers/Forms/FormController.php @@ -186,6 +186,7 @@ public function duplicate($id) // Create copy $formCopy = $form->replicate(); $formCopy->title = 'Copy of ' . $formCopy->title; + $formCopy->removed_properties = null; $formCopy->save(); return $this->success([ From 30d3583df2e77937f9c19f8b00e53b2eee5216fc Mon Sep 17 00:00:00 2001 From: Chirag Chhatrala Date: Thu, 13 Feb 2025 17:32:34 +0530 Subject: [PATCH 2/4] when duplicate remove removed_properties --- api/app/Http/Controllers/Forms/FormController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/app/Http/Controllers/Forms/FormController.php b/api/app/Http/Controllers/Forms/FormController.php index 084a33b85..084c316f9 100644 --- a/api/app/Http/Controllers/Forms/FormController.php +++ b/api/app/Http/Controllers/Forms/FormController.php @@ -186,7 +186,7 @@ public function duplicate($id) // Create copy $formCopy = $form->replicate(); $formCopy->title = 'Copy of ' . $formCopy->title; - $formCopy->removed_properties = null; + $formCopy->removed_properties = []; $formCopy->save(); return $this->success([ From 4aaa02955bd99d0522bac35ac173d7cb026babd5 Mon Sep 17 00:00:00 2001 From: Chirag Chhatrala Date: Thu, 13 Feb 2025 18:30:23 +0530 Subject: [PATCH 3/4] On duplicate form re-generate slug --- api/app/Http/Controllers/Forms/FormController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/app/Http/Controllers/Forms/FormController.php b/api/app/Http/Controllers/Forms/FormController.php index 084c316f9..fc935c96d 100644 --- a/api/app/Http/Controllers/Forms/FormController.php +++ b/api/app/Http/Controllers/Forms/FormController.php @@ -185,6 +185,14 @@ public function duplicate($id) // Create copy $formCopy = $form->replicate(); + // generate new slug before changing title + if (Str::isUuid($formCopy->slug)) { + $formCopy->slug = Str::uuid(); + } else { + $formCopy->slug = null; // Reset the slug first + $formCopy->save(); // Save to ensure we have an ID + $formCopy->generateSlug(); // Now generate the slug + } $formCopy->title = 'Copy of ' . $formCopy->title; $formCopy->removed_properties = []; $formCopy->save(); From 394570b46f1ca562129671159b9c5839b0b001f0 Mon Sep 17 00:00:00 2001 From: Chirag Chhatrala Date: Thu, 13 Feb 2025 20:33:25 +0530 Subject: [PATCH 4/4] On duplicate form re-generate slug --- api/app/Http/Controllers/Forms/FormController.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/api/app/Http/Controllers/Forms/FormController.php b/api/app/Http/Controllers/Forms/FormController.php index fc935c96d..f47e1bdf5 100644 --- a/api/app/Http/Controllers/Forms/FormController.php +++ b/api/app/Http/Controllers/Forms/FormController.php @@ -188,10 +188,9 @@ public function duplicate($id) // generate new slug before changing title if (Str::isUuid($formCopy->slug)) { $formCopy->slug = Str::uuid(); - } else { - $formCopy->slug = null; // Reset the slug first - $formCopy->save(); // Save to ensure we have an ID - $formCopy->generateSlug(); // Now generate the slug + } else { // it will generate a new slug + $formCopy->slug = null; + $formCopy->save(); } $formCopy->title = 'Copy of ' . $formCopy->title; $formCopy->removed_properties = [];