Skip to main content

update-assignment

PRO

The functionality is available in PRO Edition only

Description​

Fires when updating a resource assignment

Usage​

"update-assignment": ({
id: string | number,
assignment: {
id?: string | number,
task?: string | number,
resource?: string | number,
units?: number,
[key: string]: any,
},
}) => boolean | void;
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)

Parameters​

The callback of the update-assignment action can take an object with the following parameters:

  • id - (required) the ID of the assignment to be updated
  • assignment - (required) an object with the fields to update:
    • id - (optional) the assignment ID
    • task - (optional) the task ID the assignment belongs to
    • resource - (optional) the new resource ID; the new resource must not already be assigned to this task
    • units - (optional) the new allocation percentage from 0 to 100

Example​

Use the api.exec method to trigger the action:

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

const data = getData();
let api = ref();

function init(ganttApi) {
api = ganttApi;
}

function updateAllocation() {
api.exec("update-assignment", {
id: 1,
assignment: { units: 50 },
});
}
</script>

<Gantt
:tasks="data.tasks"
:links="data.links"
:scales="data.scales"
:init="init"
/>

Related articles: