Our state of the art Gantt chart


Post by mrefaat »

The create Task on toolbar doesn’t fire the on Add event
so when we use it to create a task it's not created in the database
we can only create it if we pressed on the enter key
you can use this project to test "Test For Create Task2"

Attachments
create task - Made with Clipchamp.mp4
(15.31 MiB) Downloaded 7 times

Post by alex.l »

How can we review the code you used in Save btn handler of your custom "Add Task" popup?

All the best,
Alex


Post by mrefaat »

This is the code

async onAddTaskClick() {
        const
            { gantt } = this,
            added = gantt.taskStore.rootNode.appendChild({ 
                name : 'New task', 
                duration : 1, 
                effort : gantt.project.hoursPerDay,
                shcedulingMode : 'Normal',
                calendar : 'general',
            });

    // run propagation to calculate new task fields
    await gantt.project.propagate();
    // scroll to the added task
    await gantt.scrollRowIntoView(added);

    gantt.features.cellEdit.startEditing({
        record : added,
        field  : 'name'
    });
}

You can find the code in the GanttToolbar.js under the lib folder in the lwc named tasksGantt


Post by alex.l »

I tested this code and I see add event is triggered on taskStore of Gantt.
I checked your video second time, I can't get why do you think the problem you faced caused by not triggered add event.
Could you please subscribe on add event and log into console?

All the best,
Alex


Post by mrefaat »

i'm already subscribing to add event on the task store

this.gantt.taskStore.on('add', ({ source, records, allRecords, parent, index, oldIndex, isChild, isExpand, isMove }) => { 
            if(! isExpand) {  //if(!isExpand && !isMove) //isMove || 
                let allTasks = this.getFlatTasks(records);
                for(let record  of allTasks){
                    if(!this.isSalesforceId(record.id)){
                        this.isInserting = true;
                        let task = JSON.parse(JSON.stringify(record));
                        task.wbs = record.wbsCode;
                        task.id = null;
                        task.successors = null;
                        task.generateInvoice = task.generateInvoice == undefined ? false : task.generateInvoice;
                        task.stopTimeEntry = task.stopTimeEntry == undefined ? false : task.stopTimeEntry;
                        task.costAdjustment = task.costAdjustment == null?0:task.costAdjustment;
                        task.revenueAdjustment = task.revenueAdjustment == null ? 0 : task.revenueAdjustment;
                        task.percentDone = task.percentDone == null ? 0 : task.percentDone;                      
task.duration = task.duration == null ? 0 : task.duration; task.effort = task.effort == null ? 0 : task.effort; task.readOnly = false; task.baselines = null; task.predecessors = null; task.children = null; this.mpaTasks2Insert.set(record.id, task); } }
}
});

Post by Maxim Gorkovsky »

I can assure you that add event is definitely triggered on the store. Check the way you fill the map and clear it. Check your conditions. Use loggers to better understand the flow.


Post by mrefaat »

Hi Maxim,

i'm sorry to tell you that the event is not triggered.

i added a console.log on the first line of the code and it's not writing it
Line 411

this.gantt.taskStore.on('add', ({ source, records, allRecords, parent, index, oldIndex, isChild, isExpand, isMove }) => { 
            console.log('on add');      
if(! isExpand) { //if(!isExpand && !isMove) //isMove ||

Post by mrefaat »

i can now see the on add event being triggered, but it's throwing a strange error " [Invalid revisions chain]"


Post by mrefaat »

In General the gantt is throwing this error

VM39329:72 Uncaught (in promise) Error: Unknown identifier Ll.$.assignmentsByCalendar


Post by mrefaat »


Post Reply