Skip to content

Commit

Permalink
feat(split-pane): adds enabled input
Browse files Browse the repository at this point in the history
fixes #10949
  • Loading branch information
manucorporat committed Apr 2, 2017
1 parent c72598a commit fa7ea0c
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/components/split-pane/split-pane.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ContentChildren, Directive, ElementRef, EventEmitter, forwardRef, Input, Output, QueryList, NgZone, Renderer } from '@angular/core';
import { Ion } from '../ion';
import { assert } from '../../util/util';
import { isTrueProperty, assert } from '../../util/util';
import { Config } from '../../config/config';
import { Platform } from '../../platform/platform';

Expand Down Expand Up @@ -142,9 +142,10 @@ export abstract class RootNode {
})
export class SplitPane extends Ion implements RootNode {

_rmListener: any;
_visible: boolean = false;
_init: boolean = false;
_visible: boolean = false;
_isEnabled: boolean = true;
_rmListener: any;
_mediaQuery: string | boolean = QUERY['md'];
_children: RootNode[];

Expand Down Expand Up @@ -190,6 +191,19 @@ export class SplitPane extends Ion implements RootNode {
return this._mediaQuery;
}

/**
* @input {boolean} If `false`, the split-pane is disabled, ie. the side pane will
* never be displayed. Default `true`.
*/
@Input()
set enabled(val: boolean) {
this._isEnabled = isTrueProperty(val);
this._update();
}
get enabled(): boolean {
return this._isEnabled;
}

/**
* @output {any} Expression to be called when the split-pane visibility has changed
*/
Expand Down Expand Up @@ -247,6 +261,12 @@ export class SplitPane extends Ion implements RootNode {
this._rmListener && this._rmListener();
this._rmListener = null;

// Check if the split-pane is disabled
if (!this._isEnabled) {
this._setVisible(false);
return;
}

const query = this._mediaQuery;
if (typeof query === 'boolean') {
this._setVisible(query);
Expand Down

0 comments on commit fa7ea0c

Please sign in to comment.