refactor: reduce responsability of individual parts

This commit is contained in:
2026-07-10 11:24:21 +02:00
parent f4425494f5
commit cb31d4e8af
7 changed files with 156 additions and 119 deletions
+3 -20
View File
@@ -3,13 +3,10 @@ import { onBeforeMount, ref, watch, computed } from "vue";
import type { Task } from "@/types";
import { Copy, Trash, Save, X } from "@lucide/vue";
import { updateTask } from "@/api/tasks";
import { CronExpressionParser } from 'cron-parser'
import CronInput from "@/components/CronInput.vue";
import { taskCompleted } from "@/lib/tasks";
const emit = defineEmits<{
(e: 'clone', task: Task): void
(e: 'delete', task: Task): void
}>();
const emit = defineEmits<(e: 'clone' | 'delete', task: Task) => void>();
const task = defineModel<Task>({ required: true });
@@ -18,21 +15,7 @@ const editName = ref<string>('');
const editCron = ref<string|null>(null);
const refreshKey = ref<number>(0);
const checked = computed<boolean>(() => {
if (task.value.check_date === null) {
return false;
}
if (task.value.reset_cron === null) {
return true;
}
try {
const interval = CronExpressionParser.parse(task.value.reset_cron, {currentDate: task.value.check_date});
const nextDate = interval.next();
return nextDate.getTime() > (new Date()).getTime();
} catch {
return false;
}
});
const checked = computed<boolean>(() => taskCompleted(task.value));
function onClose() {
editMode.value = false;