Last active
August 29, 2015 14:24
-
-
Save knownasilya/3553b7cc2581120a67cf to your computer and use it in GitHub Desktop.
Custom outlet panels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// inside application route | |
showPanel(panelName) { | |
if (!this.can('view panel of application', { panel: panelName })) { | |
return; | |
} | |
if (!panelName) { | |
return console.warn('Invalid panel toggled'); | |
} | |
let controller = this.getPanelController(panelName); | |
if (controller) { | |
controller.set('isOpen', true); | |
} | |
this.controller.set('activePanel', panelName); | |
this.render(`panels/${panelName}`, { | |
into: 'application', | |
outlet: 'panel' | |
}); | |
}, | |
removePanel() { | |
var lastPanel = this.controller.get('activePanel'); | |
if (lastPanel) { | |
let controller = this.getPanelController(lastPanel); | |
if (controller) { | |
controller.set('isOpen', false); | |
} | |
} | |
this.controller.set('activePanel', undefined); | |
this.disconnectOutlet({ | |
outlet: 'panel', | |
parentView: 'application' | |
}); | |
}, | |
getPanelController(panelName) { | |
try { | |
var controller = this.controllerFor(`panels/${panelName}`); | |
return controller; | |
} catch(e) { | |
// pass | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment