From fa7ea0c617ec39dfa1f8208101863e4df1c57ce6 Mon Sep 17 00:00:00 2001 From: Manuel Mtz-Almeida Date: Sun, 2 Apr 2017 15:01:34 +0200 Subject: [PATCH] feat(split-pane): adds enabled input fixes #10949 --- src/components/split-pane/split-pane.ts | 26 ++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/components/split-pane/split-pane.ts b/src/components/split-pane/split-pane.ts index da00ae3c8e0..c333047b7a5 100644 --- a/src/components/split-pane/split-pane.ts +++ b/src/components/split-pane/split-pane.ts @@ -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'; @@ -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[]; @@ -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 */ @@ -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);