angular-2-dropdown-multiselect
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "angular-2-dropdown-multiselect", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Customizable dropdown multiselect in Angular 2 with bootstrap css.", | ||
@@ -5,0 +5,0 @@ "main": "src/multiselect-dropdown.ts", |
@@ -117,2 +117,12 @@ /* | ||
}; | ||
MultiselectDropdown.prototype.validate = function (c) { | ||
return (this.model && this.model.length) ? null : { | ||
required: { | ||
valid: false, | ||
}, | ||
}; | ||
}; | ||
MultiselectDropdown.prototype.registerOnValidatorChange = function (fn) { | ||
throw new Error('Method not implemented.'); | ||
}; | ||
MultiselectDropdown.prototype.clearSearch = function (event) { | ||
@@ -162,2 +172,3 @@ event.stopPropagation(); | ||
this.onModelChange(this.model); | ||
this.onModelTouched(); | ||
}; | ||
@@ -199,2 +210,3 @@ MultiselectDropdown.prototype.updateNumSelected = function () { | ||
this.onModelChange(this.model); | ||
this.onModelTouched(); | ||
}; | ||
@@ -206,2 +218,3 @@ MultiselectDropdown.prototype.uncheckAll = function () { | ||
this.onModelChange(this.model); | ||
this.onModelTouched(); | ||
}; | ||
@@ -208,0 +221,0 @@ MultiselectDropdown.prototype.preventCheckboxCheck = function (event, option) { |
@@ -24,3 +24,3 @@ /* | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule, NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms'; | ||
import { FormsModule, NG_VALUE_ACCESSOR, ControlValueAccessor, Validator, AbstractControl } from '@angular/forms'; | ||
@@ -71,8 +71,8 @@ const MULTISELECT_VALUE_ACCESSOR: any = { | ||
const matchPredicate = (option: IMultiSelectOption) => option.name.toLowerCase().indexOf((args || '').toLowerCase()) > -1, | ||
getChildren = (option: IMultiSelectOption) => options.filter(child => child.parentId === option.id), | ||
getParent = (option: IMultiSelectOption) => options.find(parent => option.parentId === parent.id); | ||
getChildren = (option: IMultiSelectOption) => options.filter(child => child.parentId === option.id), | ||
getParent = (option: IMultiSelectOption) => options.find(parent => option.parentId === parent.id); | ||
return options.filter((option: IMultiSelectOption) => { | ||
return matchPredicate(option) || | ||
(typeof(option.parentId) === 'undefined' && getChildren(option).some(matchPredicate)) || | ||
(typeof(option.parentId) !== 'undefined' && matchPredicate(getParent(option))); | ||
return matchPredicate(option) || | ||
(typeof (option.parentId) === 'undefined' && getChildren(option).some(matchPredicate)) || | ||
(typeof (option.parentId) !== 'undefined' && matchPredicate(getParent(option))); | ||
}); | ||
@@ -137,4 +137,3 @@ } | ||
}) | ||
export class MultiselectDropdown implements OnInit, DoCheck, ControlValueAccessor { | ||
export class MultiselectDropdown implements OnInit, DoCheck, ControlValueAccessor, Validator { | ||
@Input() options: Array<IMultiSelectOption>; | ||
@@ -228,2 +227,14 @@ @Input() settings: IMultiSelectSettings; | ||
validate(c: AbstractControl): { [key: string]: any; } { | ||
return (this.model && this.model.length) ? null : { | ||
required: { | ||
valid: false, | ||
}, | ||
}; | ||
} | ||
registerOnValidatorChange(fn: () => void): void { | ||
throw new Error('Method not implemented.'); | ||
} | ||
clearSearch(event: Event) { | ||
@@ -273,2 +284,3 @@ event.stopPropagation(); | ||
this.onModelChange(this.model); | ||
this.onModelTouched(); | ||
} | ||
@@ -308,2 +320,3 @@ | ||
this.onModelChange(this.model); | ||
this.onModelTouched(); | ||
} | ||
@@ -315,2 +328,3 @@ | ||
this.onModelChange(this.model); | ||
this.onModelTouched(); | ||
} | ||
@@ -333,2 +347,2 @@ | ||
}) | ||
export class MultiselectDropdownModule {} | ||
export class MultiselectDropdownModule { } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40380
635