Announcement

Collapse
No announcement yet.

Front-End custom createView can not setFieldNotReadOnly

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Front-End custom createView can not setFieldNotReadOnly

    Hi all,

    I'm trying to createView to Edit Lead Record with Field condition by role. I'm looking for the way to set Field to not readonly after click my custom button to createView Edit But It doesn't work anyway. Can you pls help me to do it.

    This is my custom code to extend detail view of Lead Entity

    PHP Code:

    define
    ('custom:views/lead/detail', ['views/detail','moment'], function (DepMoment) {
        return 
    Dep.extend({
            
    setup: function () {
                
    Dep.prototype.setup.call(this);  
                
    // console.log(this);    
                
    this.addMenuItem('buttons',{
                    
    name'superEdit',
                    
    textthis.translate('Edit''labels' 'Lead'),
                    
    acl'edit',
                    
    hiddentrue,
                    
    style'success',
                    
    action'superEdit',
                });
                
    /* Connected */
                
    this.hideHeaderActionItem('convert');
                
    this.hideHeaderActionItem('unfollow');
                
    this.hideHeaderActionItem('follow');
                
    this.listenTo(this.model'sync' ,() => this.hideHeaderActionItem('follow'));
                
    this.listenTo(this.model'sync' ,() => this.hideHeaderActionItem('unfollow'));
                
    this.controlSuperEditButton();
                
    this.listenTo(this.model'sync',() => this.controlSuperEditButton());
            },
            
    /* Action template */
            
    controlSuperEditButton: function () {
                
    let dateEnd this.model.get('editEndedAt');
                
    let checkDate this.getDateTime()
                .
    toMoment(dateEnd)
                .
    isBefore(moment.now());
                if (
    checkDate) {
                    
    this.updateMenuItem('superEdit', {
                        
    hiddenfalse,
                    });
                }
            },
            
    actionSuperEdit: function () {
              
                var 
    Lead this.getMetadata().get('clientDefs.Lead.modelViews.edit') || 'views/modals/edit';
                
    this.createView('LeadSuperEdit'Lead, {
                    
    scope'Lead',
                    
    fullFormDisabledtrue,
                    
    headerTextthis.translate('Edit''labels' 'Lead') + ' → 'this.model.get('name'),
                    
    backdropfalse,
                    
    idthis.model.get('id'),
                },(
    view) => {
                    
    view.render(() => {
                        
    console.log("View Setup"view);
                        
    view.setFieldNotReadOnly('source',true); // ALWAYS RECEIVE ALERT THAT THIS IS NOT A FUNCTION
                    
    });
                    
    view.notify(false);
                    
    view.once('after:save'models => {
                            
    view.close();
                            
    this.model.fetch();
                    });
                });
            },
          
        });
    });
    ​ 

    ALWAYS RECEIVE ALERT THAT THIS IS NOT A FUNCTION
    PHP Code:
    view.render(() => {
                        
    console.log("View Setup"view);
                        
    view.setFieldNotReadOnly('source',true);
                    });
    ​ 
    Last edited by trungtvmso; 07-19-2024, 03:49 AM.

  • #2
    Wrong forum category. Should be posted in Developer Help. I moved your another post yesterday. Moving posts is also work that takes time.

    Comment


    • trungtvmso
      trungtvmso commented
      Editing a comment
      Very sorry Yuri because of my mistake. I will not post in wrong category anymore. Once again, i'm very sorry

  • #3
    views/modals/edit does not have this method: https://github.com/espocrm/espocrm/b...ls/edit.js#L29

    But you can obtain the list view with getRecordView() method.

    Comment


    • trungtvmso
      trungtvmso commented
      Editing a comment
      So we can not change readOnly field into edit mode when open in view/modals/edit. Am I right, sir?

    • yuri
      yuri commented
      Editing a comment
      Not right. You have access to the list view with getRecordView, so you can.

  • #4
    I did resolved this by another way.

    I've just relized that we can set readOnly or Edit each field by role instead of using code. The consql when you worked hard in code over 180 mins per each day. LOL

    Comment

    Working...
    X