Announcement

Collapse
No announcement yet.

Dynamic layout switching potential issues

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

  • Dynamic layout switching potential issues

    Hi there!

    Our Task entity has grown into a massive entity with a lot of fields placed on the layout at the same time. The issue is that we only need certain fields under specific conditions (e.g., specific team + specific task type), each of which requires a unique layout.

    I know that we can utilize dynamic logic or a dynamic handler to manage field visibility, but due to the large number of unused fields, I believe there’s a better approach: creating multiple custom detail layouts (which can be edited in the admin panel) and switching between them when certain conditions are met.

    Here’s what I’ve come up with after digging into the record detail view architecture:

    PHP Code:
    setup() {
        
    super.setup();
        
    this.listenTo(this.model'change:type', () => {
            
    setTimeout(() => this.onTypeChanged(), 50);
        });
    }

    onTypeChanged() {
        
    this.gridLayout null;
        
    this.detailLayout null;
        
    this.layoutName 'designDevelopmentDetail'//for testing it is hardcoded
        
    this.clearView('middle');
        
    this.createMiddleView(() => {
            
    this.getMiddleView().render().then(() => {
                
    let mode Espo.Utils.upperCaseFirst(this.mode);
                
    let setModeMethodName = `set${mode}Mode`;
                if (
    typeof this[setModeMethodName] === 'function') {
                    
    this[setModeMethodName]();
                }
            });
        });
    }
    ​ 
    Question:
    What potential issues should I be aware of with this approach? Any feedback or suggestions for improvement would be greatly appreciated!

  • #2
    Hi,

    One of the potential issues is something break after future upgrade. It's not guaranteed that internals of the record/detail view won't change in the future without migration guidelines.

    Comment

    Working...
    X