File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 39
39
return ;
40
40
}
41
41
await api .updateTemplate (newName, data .content );
42
+ loadTemplates ();
42
43
} catch (err) {
43
44
console .error (err);
44
45
alert (` 복제 실행 중 오류 발생: ${ err} ` );
74
75
alert (` 새 템플릿 생성 중 오류 발생: ${ err} ` );
75
76
}
76
77
}
78
+
79
+ // 템플릿 이름변경
80
+ async function renameTemplate (originalName ) {
81
+ const newName = prompt (
82
+ " 변경할 템플릿 이름을 입력하세요:" ,
83
+ originalName,
84
+ );
85
+ if (! newName) return ;
86
+ if (templates .includes (newName)) {
87
+ alert (" 이미 해당 이름의 템플릿이 존재합니다." );
88
+ return ;
89
+ }
90
+ try {
91
+ const data = await api .fetchTemplate (originalName);
92
+ await api .updateTemplate (newName, data .content );
93
+ await api .deleteTemplate (originalName);
94
+ loadTemplates ();
95
+ } catch (err) {
96
+ console .error (err);
97
+ alert (` 이름 변경 중 오류 발생: ${ err} ` );
98
+ }
99
+ }
77
100
</script >
78
101
79
102
<svelte:head >
104
127
>
105
128
{tpl }
106
129
</a >
130
+ <button
131
+ on:click ={() => renameTemplate (tpl )}
132
+ class =" bg-blue-500 hover:bg-blue-700 text-white font-bold py-1 px-2 rounded"
133
+ >
134
+ Rename
135
+ </button >
107
136
<button
108
137
on:click ={() => duplicateTemplate (tpl )}
109
138
class =" bg-yellow-500 hover:bg-yellow-700 text-white font-bold py-1 px-2 rounded"
You can’t perform that action at this time.
0 commit comments