Skip to main content

delete-task

Description​

Fires when deleting a task

Usage​

"delete-task": ({
id: string | number,
source?: string | number
}) => boolean | void;

Parameters​

The callback of the delete-task action can take an object with the following parameters:

  • id - (required) the ID of a task to be deleted
  • source - (optional) the ID of a source task that is deleted
info

For handling the actions you can use the Event Bus methods. Returning false from the action handler will block the action (see Preventing actions)

Example​

Use the api.exec method to trigger the action:

<script setup>
import { ref } from "vue";
import { getData } from "./common/data";
import { Gantt } from "@svar-ui/vue-gantt";
import { Button } from "@svar-ui/vue-wx";

const data = getData();

const api = ref(null);
const selected = ref(null);

function handleDelete() {
api.value.exec("delete-task", { id: selected.value });
}
</script>

<template>
<Toolbar>
<Button v-if="selected" :onclick="handleDelete">Delete task</Button>
</Toolbar>
<Gantt
:tasks="data.tasks"
:init="init" />
</template>

Preventing task deletion​

You can intercept the action and return false to block it:

api.intercept("delete-task", ev => {
if (!allowDelete) return false; // prevents deletion
});

Related articles: