Page 1 of 1

[ANGULAR] editor fields will not stay disabled

Posted: Thu Oct 06, 2022 9:13 pm
by bherford

I've got

        beforeTaskEditShow({editor}) {
            editor.widgetMap.schedulingModeField.disabled = true
            editor.widgetMap.effortDrivenField.disabled = true
        },

which disables the fields properly, but then when I edit another field, they lose their disabled state. I've attached a video below

disablebug.mov
(7.89 MiB) Downloaded 32 times

Re: [ANGULAR] editor fields will not stay disabled

Posted: Thu Oct 06, 2022 10:09 pm
by marcio

Hey bherford,

To disable fields, you need to change the configuration object (you can check the documentation here https://www.bryntum.com/docs/gantt/api/Gantt/widget/TaskEditor#task-editor-customization-example):

 features : {
        taskEdit : {
            items : {
                advancedTab : {
                    items : {
                        schedulingModeField : {
                            readOnly : true
                        },
                        effortDrivenField : {
                            readOnly : true
                        }
                    }
                }
            }
        }
    }

Also, we recommend using readOnly instead of disabled for accessibility reasons


Re: [ANGULAR] editor fields will not stay disabled

Posted: Thu Oct 06, 2022 10:47 pm
by bherford

Marcio, thanks for the quick response

I implemented your code snippet - and initially displayed properly, then when I changed another field they became editable again:

Screen Shot 2022-10-06 at 4.45.26 PM.png
Screen Shot 2022-10-06 at 4.45.26 PM.png (123.35 KiB) Viewed 560 times
Screen Shot 2022-10-06 at 4.45.43 PM.png
Screen Shot 2022-10-06 at 4.45.43 PM.png (122.99 KiB) Viewed 560 times

Re: [ANGULAR] editor fields will not stay disabled

Posted: Fri Oct 07, 2022 1:09 am
by marcio

Hey bherford,

Could you confirm which version are you using? As you can see in the video, in our latest version demos with that configuration that I shared we don't have that behavior, perhaps you have another configuration that could be causing that behavior, are you able to create a sample configuration for us to check?


Re: [ANGULAR] editor fields will not stay disabled

Posted: Fri Oct 07, 2022 8:43 pm
by bherford
    "@bryntum/gantt": "^5.1.3",
    "@bryntum/gantt-angular": "^5.1.3",
    

I was able to get the config here in my

gantt.config.js

to work:

        beforeTaskEditShow({editor}) {
            editor.widgetMap.schedulingModeField.readOnly = true
            editor.widgetMap.effortDrivenField.disabled = true
            editor.widgetMap.manuallyScheduledField.disabled = true
            editor.widgetMap.rollupField.disabled = true
        },

by adding this line:

isEditable() {}

to my

task.js

What could be causing this behavior? I'm looking into how to share the project code with you


Re: [ANGULAR] editor fields will not stay disabled

Posted: Sat Oct 08, 2022 11:15 am
by tasnim

Yes. We need a runnable test case so that we can debug it and figure out the solution. You can share the project like this

  1. first remove node_modules folder
  2. And then wrap your whole app in a .zip file
  3. Then drag and drop the file into our forum text box
  4. Then submit

Re: [ANGULAR] editor fields will not stay disabled

Posted: Tue Oct 11, 2022 2:24 pm
by bherford

Even without node_modules this file is too big to upload. here is a link to drive https://drive.google.com/file/d/1MUGpodbyHnXyVO0SgOof7c8QXvRfS3W3/view?usp=sharing


Re: [ANGULAR] editor fields will not stay disabled

Posted: Tue Oct 11, 2022 8:14 pm
by marcio

Hello bherford,

I got an error when trying to compile that project, could you please update the source code or provide a valid configuration for the project that you shared?


Re: [ANGULAR] editor fields will not stay disabled

Posted: Wed Oct 12, 2022 3:40 pm
by bherford

Hi Marcio,

I was able to find a workaround by adding


beforeTaskEditShow({editor}) {
            // Define list of fields to disable.
            const disabledAdvancedFields = ['rollupField', 'manuallyScheduledField', 'effortDrivenField', 'schedulingModeField']
            disabledAdvancedFields.forEach(field => {
                // e.g: editor.widgetMap.rollupField.readOnly
                editor.widgetMap[field].readOnly = true
                // Without this class the field looks editable 
                editor.widgetMap[field].cls = 'b-disabled'
            })
        },


Re: [ANGULAR] editor fields will not stay disabled

Posted: Thu Oct 13, 2022 5:25 am
by tasnim

That's really great. Glad to hear that.

Good Luck :)