-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40a2911
commit b9b54e1
Showing
9 changed files
with
188 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
packages/renderer/src/components/Task/TaskGroupActions.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<script lang="ts" setup> | ||
import { ref } from 'vue' | ||
import { NIcon, NButton, NPopconfirm, NInput, NSpace, NText, useMessage } from 'naive-ui' | ||
import { useI18n } from 'vue-i18n' | ||
import { TrashOutline } from '@vicons/ionicons5' | ||
import useTaskStore from '@/store/tasks' | ||
import EditIcon from '@/assets/icons/edit.svg?component' | ||
const props = defineProps<{ | ||
taskGroup: TaskGroup | undefined | ||
deviceUuid: string | ||
}>() | ||
const taskStore = useTaskStore() | ||
const message = useMessage() | ||
const { t } = useI18n() | ||
const isEditing = ref(false) | ||
const handleEditDone = (value: string) => { | ||
if (!props.taskGroup) return | ||
const trimed = value.trim() | ||
if (trimed === '') { | ||
message.error(t('error.cannotBeEmpty', { name: t('task.taskGroupName') })) | ||
return | ||
} | ||
taskStore.changeTaskGroupName(props.deviceUuid, props.taskGroup.id, trimed) | ||
isEditing.value = false | ||
} | ||
const handleDelete = () => { | ||
if (!props.taskGroup) return | ||
try { | ||
taskStore.deleteTaskGroup(props.deviceUuid, props.taskGroup.id) | ||
} catch (error) { | ||
message.error(t(`errors.${error.message}`)) | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<NSpace class="task-group" align="center"> | ||
<NInput | ||
v-if="isEditing" | ||
passively-activated | ||
:default-value="props.taskGroup?.name" | ||
:disabled="!props.taskGroup" | ||
@change="handleEditDone" | ||
@blur="isEditing = false" | ||
/> | ||
<NText v-else> | ||
{{ props.taskGroup?.name }} | ||
</NText> | ||
<NButton | ||
v-if="!isEditing" | ||
size="small" | ||
quaternary | ||
circle | ||
@click="isEditing = true" | ||
> | ||
<template #icon> | ||
<NIcon> | ||
<EditIcon /> | ||
</NIcon> | ||
</template> | ||
</NButton> | ||
<NPopconfirm @positive-click="handleDelete"> | ||
<template #trigger> | ||
<NButton | ||
size="small" | ||
quaternary | ||
circle | ||
type="error" | ||
> | ||
<template #icon> | ||
<NIcon> | ||
<TrashOutline /> | ||
</NIcon> | ||
</template> | ||
</NButton> | ||
</template> | ||
<template #default> | ||
<NText>确定要删除{{ props.taskGroup?.name }}吗?</NText> | ||
</template> | ||
</NPopconfirm> | ||
</NSpace> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.