support icon indicating copy to clipboard operation
support copied to clipboard

Data disappears from the ResourceAssignmentEditor

Open ghulamghousdev opened this issue 10 months ago • 3 comments

Forum post

Steps to repro:

  1. Go to gantt advanced demo: https://bryntum.com/products/gantt/examples/advanced/
  2. Replace the resourceAssignment column with below config:
        {
            type        : 'resourceassignment',
            width       : 120,
            showAvatars : true,
            avatarTooltipTemplate({ resourceRecord }) {
                return `<b>${resourceRecord.name}</b>`;
            },
            editor : {
                listeners : {
                    change({ store, action, records }) {

                    }
                },
                chipView : {
                    itemTpl : assignment => {
                        // @ts-ignore
                        return assignment.resourceName;
                    }
                },
                tooltipTemplate({ assignmentRecords }) {
                    // @ts-ignore
                    return assignmentRecords.map(as => `${as.resource?.name} `).join(', ');   //???
                },
                autoClose : false,
                picker    : {
                    listeners : {
                        beforeShow({ source }) {
                            source.columns.get('units').hidden = true;
                            const taskModel = source._owner.eventRecord;
                            if (taskModel._data.duration === 0) {
                                // milestone
                                source.columns.get('doneHours').hidden = true;
                                source.columns.get('assignEfforts').hidden = true;
                                source.columns.get('currentStatus').hidden = true;
                                source.width = 240;
                            }

                            source.widgetMap.saveBtn.addListener('action', (ev) => {
                                console.log(source.selected._values);
                                const editorTotals = source.selected._values.reduce((sum, e) => sum + Number(e.assignEfforts || 0), 0);

                            });
                        },
                        onitem({ item }) {
                            console.log('You clicked ' + item);
                        },
                        beforeSelectionChange(data) {
                            // return false
                            const { action, deselected } = data;
                            if (action === 'deselect') {
                                if (deselected.length > 0 && Number(deselected[0]?.doneHours) > 0) {
                                    return false;
                                }
                                else {
                                    if (deselected.length > 0) {
                                        deselected[0].doneHours = null;
                                        deselected[0].assignEfforts = null;
                                        deselected[0].currentStatus = null;
                                        data.source.columns.get('assignEfforts').editor.required = false;
                                    }
                                }
                            }
                            else if (action === 'select') {
                                console.log(data);
                                data.selected[0].currentStatus = 'To Do';
                                data.selected[0].doneHours = 0;
                                data.selected[0].assignEfforts = 0;
                                data.source.columns.get('assignEfforts').editor.required = true;
                            }
                            return true;
                            // return true
                        },
                        beforeCellEditStart({ editorContext }, value, ...event) {
                            const { column, editor, record, cell, taskRecord } = editorContext;
                            // if(record.)
                        }

                    },
                    height        : 480,
                    width         : 500,
                    autoClose     : false,
                    // selectionMode:false,
                    selectionMode : {
                        rowCheckboxSelection : false,
                        multiSelect          : true,
                        showCheckAll         : false
                    },
                    features : {
                        filterBar  : true,
                        group      : 'resource.orgCode',
                        headerMenu : false,
                        cellMenu   : false
                    },
                    // The extra columns are concatenated onto the base column set.
                    columns : [
                        {
                            text        : 'Done Hours',
                            field       : 'doneHours',
                            filterable  : false,
                            editor      : false,
                            disabled    : true,
                            width       : 100,
                            htmlEncode  : false,
                            leafIconCls : null,

                            renderer(
                                { record, value, size, isExport }
                            ) {
                                // Parent rows are employees
                                let htmlStr;
                                if (Number(record.doneHours) > Number(record.assignEfforts)) {
                                    htmlStr = `<span class='exceedDoneHours'>${value}</span> `;
                                }
                                else {
                                    htmlStr = `<span>${value || ''}</span> `;
                                }
                                return htmlStr;
                            }
                        },
                        {
                            text       : 'Effort',
                            field      : 'assignEfforts',
                            filterable : false,
                            editor     : {
                                type      : 'numberField',
                                // editable: true,
                                clearable : false,
                                required  : false,
                                min       : 0,
                                listeners : {
                                    catchAll(data) {

                                    }

                                }
                            },
                            width : 80
                        },
                        {
                            text       : 'Status',
                            field      : 'currentStatus',
                            filterable : false,
                            editor     : {
                                type       : 'combo',
                                editable   : false,
                                autoExpand : true,
                                items      : [
                                    {
                                        value    : 'To Do',
                                        text     : 'To Do',
                                        readOnly : true
                                    },
                                    {
                                        value    : 'Doing',
                                        text     : 'Doing',
                                        readOnly : false
                                    },
                                    {
                                        value    : 'Review',
                                        text     : 'Review',
                                        readOnly : false
                                    },
                                    {
                                        value    : 'Done',
                                        text     : 'Done',
                                        readOnly : false
                                    },
                                    {
                                        value    : 'Transferred',
                                        text     : 'Transferred',
                                        readOnly : false
                                    }
                                ],
                                listeners : {
                                    beforeAll(data) {
                                        console.log(data);
                                    },
                                    beforeShow(data) {
                                        console.log(data);
                                    }
                                },
                                picker : {
                                    onBeforeItem({ record }) {
                                        console.log(record);
                                        // @ts-ignore

                                    }
                                }
                            },
                            width : 100
                        }
                    ]
                }

            },
            listeners : {
                catchAll(data) {
                }
            }
        },
  1. Open resource assignment editor for RunTests task and click select a resource. Now click somewhere else and the data will disappear from the editor.

https://github.com/bryntum/support/assets/52177956/a3710a30-c0e0-4561-bbca-ebf67cf63b87

ghulamghousdev avatar Apr 30 '24 09:04 ghulamghousdev

  • 1 here: https://forum.bryntum.com/viewtopic.php?p=145884#p145884

ghulamghousdev avatar May 08 '24 06:05 ghulamghousdev

Also crashes when clicking empty bbar space


Widget.js:3760 Uncaught Error: Only floating or positioned Widgets can use toFront
    at Editor.toFront (Widget.js:3760:19)
    at Editor.onFocusIn (Widget.js:6063:16)
    at focusin (GlobalEvents.js:360:51)
    at HTMLBodyElement.handler (EventHelper.js:544:78)

matsbryntse avatar May 08 '24 07:05 matsbryntse

Focus related, test pushed to 9081-resource-assignment

matsbryntse avatar May 09 '24 12:05 matsbryntse