Skip to content

Commit a973a90

Browse files
committed
Allow editing and deleting system templates
- Remove backend restriction preventing deletion of system templates in TemplateController - Update Templates/Index.vue to show Edit/Delete buttons for all templates - Remove copy functionality since direct editing is now available - Simplify template management interface with consistent Edit/Delete actions Users can now directly modify or remove original system templates without needing to copy them first.
1 parent 76455bc commit a973a90

File tree

2 files changed

+4
-47
lines changed

2 files changed

+4
-47
lines changed

app/Http/Controllers/TemplateController.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ public function update(Request $request, Template $template)
101101

102102
public function destroy(Template $template)
103103
{
104-
// Only allow deleting non-system templates
105-
if ($template->is_system) {
106-
return response()->json(['error' => 'Cannot delete system templates'], 403);
107-
}
108-
109104
$template->delete();
110105

111106
return response()->json([

resources/js/pages/Templates/Index.vue

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import AppLayout from '@/layouts/AppLayout.vue';
77
import type { BreadcrumbItem } from '@/types';
88
import { Head, router } from '@inertiajs/vue3';
99
import axios from 'axios';
10-
import { Copy, FileText, Plus } from 'lucide-vue-next';
10+
import { FileText, Plus } from 'lucide-vue-next';
1111
import { onMounted, ref } from 'vue';
1212
1313
interface Template {
@@ -62,29 +62,6 @@ const editTemplate = (templateId: string) => {
6262
router.visit(`/templates/${templateId}/edit`);
6363
};
6464
65-
const copyTemplate = async (template: Template) => {
66-
try {
67-
const copiedTemplate = {
68-
name: `${template.name} (Copy)`,
69-
description: template.description,
70-
prompt: template.prompt,
71-
icon: template.icon,
72-
category: template.category,
73-
variables: template.variables,
74-
talking_points: template.talking_points,
75-
additional_info: template.additional_info,
76-
is_system: false, // Make sure copied templates are not system templates
77-
};
78-
79-
await axios.post(route('templates.store'), copiedTemplate);
80-
await fetchTemplates();
81-
alert(`Template "${template.name}" copied successfully!`);
82-
} catch (error) {
83-
console.error('Failed to copy template:', error);
84-
alert('Failed to copy template. Please try again.');
85-
}
86-
};
87-
8865
const deleteTemplate = async (template: Template) => {
8966
if (confirm(`Are you sure you want to delete "${template.name}"?`)) {
9067
try {
@@ -185,26 +162,11 @@ onMounted(() => {
185162
</p>
186163

187164
<div class="flex items-center gap-2">
188-
<!-- Copy button for system templates -->
189-
<Button v-if="template.is_system" size="sm" variant="outline" @click="copyTemplate(template)">
190-
<Copy :size="14" class="mr-1" />
191-
Copy
192-
</Button>
193-
194-
<!-- Edit button (disabled for system templates) -->
195-
<Button
196-
size="sm"
197-
variant="outline"
198-
@click="editTemplate(template.id)"
199-
:disabled="template.is_system"
200-
:title="template.is_system ? 'System templates are read-only. Use Copy to create an editable version.' : 'Edit template'"
201-
>
202-
{{ template.is_system ? 'View' : 'Edit' }}
203-
</Button>
165+
<!-- Edit button -->
166+
<Button size="sm" variant="outline" @click="editTemplate(template.id)"> Edit </Button>
204167

205-
<!-- Delete button (only for user templates) -->
168+
<!-- Delete button -->
206169
<Button
207-
v-if="!template.is_system"
208170
size="sm"
209171
variant="outline"
210172
@click="deleteTemplate(template)"

0 commit comments

Comments
 (0)