Example #1
0
 /**
  * Selects a value if there's a toggle that corresponds to it.
  * @param {?} value
  * @return {?}
  */
 _selectValue(value) {
     const /** @type {?} */ correspondingOption = this._buttonToggles.find(toggle => {
         return toggle.value != null && toggle.value === value;
     });
     if (correspondingOption) {
         correspondingOption.checked = true;
         this._selectionModel.select(correspondingOption);
     }
 }
Example #2
0
 /**
  * Syncs a button toggle's selected state with the model value.
  * @param {?} toggle Toggle to be synced.
  * @param {?} select Whether the toggle should be selected.
  * @param {?=} isUserInput Whether the change was a result of a user interaction.
  * @return {?}
  */
 _syncButtonToggle(toggle, select, isUserInput = false) {
     // Deselect the currently-selected toggle, if we're in single-selection
     // mode and the button being toggled isn't selected at the moment.
     if (!this.multiple && this.selected && !toggle.checked) {
         (/** @type {?} */ (this.selected)).checked = false;
     }
     if (select) {
         this._selectionModel.select(toggle);
     }
     else {
         this._selectionModel.deselect(toggle);
     }
     // Only emit the change event for user input.
     if (isUserInput) {
         this._emitChangeEvent();
     }
     // Note: we emit this one no matter whether it was a user interaction, because
     // it is used by Angular to sync up the two-way data binding.
     this.valueChange.emit(this.value);
 }
Example #3
0
 /**
  * Expands a subtree rooted at given data node recursively.
  * @param {?} dataNode
  * @return {?}
  */
 expandDescendants(dataNode) {
     /** @type {?} */
     let toBeProcessed = [dataNode];
     toBeProcessed.push(...this.getDescendants(dataNode));
     this.expansionModel.select(...toBeProcessed);
 }
Example #4
0
 /**
  * @return {?}
  */
 ngAfterContentInit() {
     this._selectionModel.select(...this._buttonToggles.filter(toggle => toggle.checked));
 }
Example #5
0
 /**
  * Expands one single data node.
  * @param {?} dataNode
  * @return {?}
  */
 expand(dataNode) {
     this.expansionModel.select(dataNode);
 }