Our state of the art Gantt chart


Post by shimnx »

Error message

Attachments
屏幕截图 2022-05-23 132814.png
屏幕截图 2022-05-23 132814.png (44.06 KiB) Viewed 412 times

Post by alex.l »

You have text "Do you really want to select?", but it appears on deselect action:

if(changed.action == "deselect"){

but you check later selected property

changed.selected[0]

If you check your console (you already added console.log(changed);), you will see that changed.selected is empty.

All the best,
Alex


Post by shimnx »

Yes changed.selected is empty, so I can't write that either

 listeners: {
                        async selectionChange(changed) {
                            console.log(changed);

                            const result = await MessageDialog.confirm({
                                title: 'The big question',
                                message: 'Do you really want to select?',
                                okButton: 'Yes',
                                cancelButton: 'No'
                            });

                            if (result != MessageDialog.okButton) {
                                console.log(changed);
                                // this.scrollRowIntoView()
                                this.deselectRow(changed.deselected[0])
                                // call deselect on your row
                            }
                    }
                },

Post by alex.l »

Why do you need to deselect deselected?
Try to fix your logic and check your code with debugger, please.

All the best,
Alex


Post by shimnx »

When we have A task, assigned to A, if I go to modify the appointed person, amend the A to B, this time need to have A confirmation box when the user clicks on the confirmation, then can modify the appointed person, if you click cancel, the assignment should be still A rather than B, the question now is when I click on the cancel my assigned person is rather than A B


Post by alex.l »

If you need to have confirmation when you selected another resource, check "select" action

                            if (changed.action == "select") {
                                const result = await MessageDialog.confirm({
                                    title: 'The big question',
                                    message: 'Do you really want to select?',
                                    okButton: 'Yes',
                                    cancelButton: 'No'
                                });

                            if (result != MessageDialog.okButton) {
                                this.deselectRow(changed.selected[0])
                            }
                        }

If you need confirmation when you deselect resource, check "deselect" action

                            if (changed.action == "deselect") {
                                const result = await MessageDialog.confirm({
                                    title: 'The big question',
                                    message: 'Do you really want to deselect?',
                                    okButton: 'Yes',
                                    cancelButton: 'No'
                                });

                            if (result != MessageDialog.okButton) {
                                this.selectRow(changed.deselected[0])
                            }
                        }

All the best,
Alex


Post by shimnx »

Now, after I hit No, the assignment is cleared, not returned to the original person.Another problem is that I don't need to be prompted the first time I double click to deactivate the checkbox.

Thank you!

Attachments
IMG_6261.MOV
(17.65 MiB) Downloaded 43 times

Post by tasnim »

Hi,

Now, after I hit No, the assignment is cleared, not returned to the original person

You need to select the deselected item like this:

this.selectRow(changed.deselected[0]);

Another problem is that I don't need to be prompted the first time I double click to deactivate the checkbox.

The way I know, is that you need to listen when the widget shows and when the widget hides. so you need to listen to 2 events.
Here are those events you can listen to:
https://bryntum.com/docs/gantt/api/Core/widget/DatePicker#event-beforeShow
https://bryntum.com/docs/gantt/api/Core/widget/DatePicker#event-beforeHide

Then you need to define a variable count outside the ganttConfig which is gonna have the value of 0. Then, when the show event fires increment it by 1, and when the hide event fires decrement by 1 or set it to 0. then we're gonna show the message dialog when the count is greater than 1.

Here is the full code snippet below:

                        beforeShow() {
                            count++
                        },
                        beforeHide() {
                            count--;
                        },
                        async selectionChange(changed) {
                            if (count > 0) {
                                const result = await MessageDialog.confirm({
                                    title: 'The big question',
                                    message: 'Do you really want to select?',
                                    okButton: 'Yes',
                                    cancelButton: 'No'
                                });

                            if (result != MessageDialog.okButton) {
                                this.scrollRowIntoView();
                                changed.selected.length && this.deselectRow(changed.selected[0]);
                                // returning to the original person
                                changed.deselected.length && this.selectRow(changed.deselected[0]);
                            }
                        }
                    }
                }

Best regards,
Tasnim


Post by shimnx »

Thank you. Now there is another problem that when I deselect a designated person, the confirmation popup box pops up, which was normal before, but when I click No, it asks me to confirm, I do not need this secondary popup, can I remove it

 {
                type: 'resourceassignment', width: 120, showAvatars: true, itemTpl: ({ units }) => units,

            editor: {

                picker: {
                    listeners: {
                        beforeShow() {
                            count++
                        },
                        beforeHide() {
                            count--;
                        },
                        async selectionChange(changed) {
                            console.log(changed);
                            let data = await window['GanttComponent'].component.reloadData()
                            console.log(data)
                            if (changed.action == "select" && data.wl > 0) {
                                if (count > 0) {
                                    const result = await MessageDialog.confirm({
                                        title: 'The big question',
                                        message: 'Do you really want to select?',
                                        okButton: 'Yes',
                                        cancelButton: 'No'
                                    });
                                    if (result != MessageDialog.okButton) {
                                        this.scrollRowIntoView();
                                        changed.selected.length && this.deselectRow(changed.selected[0]);
                                        // returning to the original person
                                        changed.deselected.length && this.selectRow(changed.deselected[0]);
                                    }
                                }
                            }
                            if (changed.action == "deselect" && data.wl > 0) {
                                if (count > 0) {
                                    const result = await MessageDialog.confirm({
                                        title: 'The big question',
                                        message: 'Do you really want to deselect?',
                                        okButton: 'Yes',
                                        cancelButton: 'No'
                                    });
                                    if (result != MessageDialog.okButton) {
                                        this.scrollRowIntoView();
                                        changed.deselected.length && this.selectRow(changed.deselected[0])
                                        changed.selected.length && this.deselectRow(changed.selected[0]);
                                    }

                                }
                            }
                        }
                    },
                    selectionMode: {
                        rowCheckboxSelection: true,
                        multiSelect: false,
                        showCheckAll: false,

                    },

                    features: {
                        filterBar: true,
                        group: 'resource.orgCode',
                        headerMenu: false,
                        cellMenu: false,
                    },
                    // The extra columns are concatenated onto the base column set.
                    // columns: [{
                    //     text: 'Calendar',
                    //     // Read a nested property (name) from the resource calendar
                    //     field: 'resource.name',
                    //     filterable: false,
                    //     editor: false,
                    //     width: 200,
                    // }],
                },

            }
        },
Attachments
IMG_6285.MOV
(16.12 MiB) Downloaded 44 times

Post by tasnim »

You just need to close the MessageDialog.

Please check the code below

changed.deselected.length && this.selectRow(changed.deselected[0])
changed.selected.length && this.deselectRow(changed.selected[0]);
// add this code
MessageDialog.close();

Please let us know if this solves your issue.


Post Reply