2323 * @tagClick="onTagClick" />
2424 */
2525
26- import type { Ref } from " vue" ;
26+ import { reactive , type Ref , ref } from " vue" ;
2727
2828import type { AnyHistoryEntry , MyHistory } from " @/api/histories" ;
2929import { isMyHistory } from " @/api/histories" ;
30+ import { useHistoryStore } from " @/stores/historyStore" ;
3031
32+ import RenameModal from " @/components/Common/RenameModal.vue" ;
3133import HistoryCard from " @/components/History/HistoryCard.vue" ;
3234
3335interface Props {
@@ -150,6 +152,28 @@ const emit = defineEmits<{
150152 */
151153 (e : " on-history-card-click" , history : AnyHistoryEntry , event : Event ): void ;
152154}>();
155+
156+ const historyStore = useHistoryStore ();
157+
158+ const modalOptions = reactive ({
159+ rename: {
160+ id: " " ,
161+ name: " " ,
162+ },
163+ });
164+
165+ const showRename = ref (false );
166+
167+ function onRenameClose() {
168+ showRename .value = false ;
169+ emit (" refreshList" , true , true );
170+ }
171+
172+ function onRename(id : string , name : string ) {
173+ modalOptions .rename .id = id ;
174+ modalOptions .rename .name = name ;
175+ showRename .value = true ;
176+ }
153177 </script >
154178
155179<template >
@@ -173,8 +197,16 @@ const emit = defineEmits<{
173197 @tagClick =" (...args) => emit('tagClick', ...args)"
174198 @refreshList =" (...args) => emit('refreshList', ...args)"
175199 @updateFilter =" (...args) => emit('updateFilter', ...args)"
200+ @rename =" onRename"
176201 @on-key-down =" (...args) => emit('on-key-down', ...args)"
177202 @on-history-card-click =" (...args) => emit('on-history-card-click', ...args)" />
203+
204+ <RenameModal
205+ v-if =" showRename"
206+ item-type =" history"
207+ :name =" modalOptions.rename.name"
208+ :rename-action =" (newName) => historyStore.updateHistory(modalOptions.rename.id, { name: newName })"
209+ @close =" onRenameClose" />
178210 </div >
179211</template >
180212
0 commit comments