show-conflicts
The functionality is available in PRO Edition only
PRODescription
Fires when opening or closing the list of scheduling conflictsinfo
The action works only if auto scheduling is enabled.
The action sets the showConflicts state, which opens or closes the ConflictReport list. The Conflicts button of the Toolbar and the close icon of the list both trigger it.
Usage
"show-conflicts": ({
mode?: boolean
}) => boolean | void;
Parameters
The callback of the show-conflicts action takes an object with the following parameter:
mode- (optional)trueopens the list,falsecloses it; if not set, the list is toggled
info
For handling the action you can use the Event Bus methods. Returning false from the action handler will block the action (see Preventing actions)
Example
The example below opens the list of conflicts whenever a scheduling run reports any.
import { useState } from "react";
import { getData } from "./common/data";
import { Gantt, ConflictReport } from "@svar/react-gantt";
const data = getData();
function App() {
const [api, setApi] = useState();
function init(api) {
api.on("set-conflicts", ({ conflicts }) => {
if (conflicts.length) api.exec("show-conflicts", { mode: true });
});
}
return (
<>
<Gantt
ref={setApi}
tasks={data.tasks}
links={data.links}
schedule={{ auto: true }}
init={init}
/>
{api && <ConflictReport api={api} />}
</>
);
}
export default App;
Related articles: