Skip to content

Instantly share code, notes, and snippets.

@elchele elchele/subpanels.js
Last active May 16, 2017

What would you like to do?
Custom controller for subpanels layout, hides specific subpanels based on parent record data
/* Author: Angel Magaña --
* File: ./custom/modules/<Module>/clients/base/layouts/subpanels/subpanels.js
* Extended subpanels layout controller for hiding
* subpanels upon record load and based on parent record data
extendsFrom: 'SubpanelsLayout',
initialize: function(options) {
this._super('initialize', [options]);
//Perform check of parent data once parent record finishes loading
this.model.on('data:sync:complete', this.doRecordCheck, this);
doRecordCheck: function() {
var sRecType = this.model.get('lead_source');
var oHidden = [];
//Set the list of subpanels to be hidden, based on Lead Source value
switch(sRecType) {
case 'Cold Call':
oHidden = ['calls', 'meetings'];
if (sRecType === 'Cold Call')
_.each(this._components, function(component) {
//Get link name (relationship)
var link = component.context.get('link');
//Hide subpanels if in list of subpanels to be hidden
if (oHidden.indexOf(link) > -1)
_dispose: function(){
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.