Skip to content

Commit

Permalink
Fixed #4233
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Oct 26, 2017
1 parent c2726f9 commit 3b84cf7
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/app/components/multiselect/multiselect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NgModule,Component,ElementRef,OnInit,AfterViewInit,AfterContentInit,AfterViewChecked,DoCheck,OnDestroy,Input,Output,Renderer2,EventEmitter,IterableDiffers,
import {NgModule,Component,ElementRef,OnInit,AfterViewInit,AfterContentInit,AfterViewChecked,OnDestroy,Input,Output,Renderer2,EventEmitter,IterableDiffers,
forwardRef,ViewChild,ChangeDetectorRef,TemplateRef,ContentChildren,QueryList} from '@angular/core';
import {CommonModule} from '@angular/common';
import {SelectItem} from '../common/selectitem';
Expand Down Expand Up @@ -69,7 +69,7 @@ export const MULTISELECT_VALUE_ACCESSOR: any = {
`,
providers: [DomHandler,ObjectUtils,MULTISELECT_VALUE_ACCESSOR]
})
export class MultiSelect implements OnInit,AfterViewInit,AfterContentInit,AfterViewChecked,DoCheck,OnDestroy,ControlValueAccessor {
export class MultiSelect implements OnInit,AfterViewInit,AfterContentInit,AfterViewChecked,OnDestroy,ControlValueAccessor {

@Input() scrollHeight: string = '200px';

Expand Down Expand Up @@ -175,6 +175,7 @@ export class MultiSelect implements OnInit,AfterViewInit,AfterContentInit,AfterV
set options(val: any[]) {
let opts = this.optionLabel ? this.objectUtils.generateSelectItems(val, this.optionLabel) : val;
this._options = opts;
this.updateLabel();
}

ngOnInit() {
Expand Down Expand Up @@ -221,16 +222,7 @@ export class MultiSelect implements OnInit,AfterViewInit,AfterContentInit,AfterV
this.filtered = false;
}
}

ngDoCheck() {
let valueChanges = this.value ? this.valueDiffer.diff(this.value) : true;
let optionChanges = this.optionsDiffer.diff(this.options);

if(valueChanges||optionChanges) {
this.updateLabel();
}
}

writeValue(value: any) : void {
this.value = value;
this.updateLabel();
Expand Down Expand Up @@ -258,6 +250,7 @@ export class MultiSelect implements OnInit,AfterViewInit,AfterContentInit,AfterV

this.onModelChange(this.value);
this.onChange.emit({originalEvent: event, value: this.value});
this.updateLabel();
}

isSelected(value) {
Expand Down Expand Up @@ -292,9 +285,11 @@ export class MultiSelect implements OnInit,AfterViewInit,AfterContentInit,AfterV
}
}
}

checkbox.checked = !checkbox.checked;
this.onModelChange(this.value);
this.onChange.emit({originalEvent: event, value: this.value});
this.updateLabel();
}

isAllChecked() {
Expand Down

0 comments on commit 3b84cf7

Please sign in to comment.