Skip to content
This repository has been archived by the owner on May 21, 2021. It is now read-only.

Commit

Permalink
fix(select): enable hierarchical pre-select
Browse files Browse the repository at this point in the history
  • Loading branch information
Can Kattw committed Jul 18, 2017
1 parent 4f643e8 commit d7866c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
11 changes: 11 additions & 0 deletions src/lib/build-internal-options-map.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function buildInternalOptionsMap(internalOptions, internalOptionsMap) {
internalOptions.forEach((option) => {
if (internalOptionsMap[option.trackingId]) {
throw new Error('Duplicate hash value for options ' + option.label + ' and ' + internalOptionsMap[option.trackingId].label);
}
internalOptionsMap[option.trackingId] = option;
if (option.children) {
buildInternalOptionsMap(option.children, internalOptionsMap);
}
});
}
11 changes: 2 additions & 9 deletions src/w11k-select.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {InternalOption} from './model/internal-option.model';
import {OptionState} from './model/option-state.enum';
import {ConfigInstance} from './model/config.model';
import {collectActiveLabels} from './lib/collect-active-labels';
import {buildInternalOptionsMap} from './lib/build-internal-options-map';


export interface Scope extends ng.IScope {
Expand Down Expand Up @@ -420,15 +421,7 @@ export function w11kSelect(w11kSelectConfig, $parse, $document, w11kSelectHelper
if (angular.isArray(externalOptions)) {
internalOptions = externalOptions2internalOptions(externalOptions, viewValue, w11kSelectHelper, optionsExpParsed, scope.config);
internalOptionsMap = {};
let i = internalOptions.length;
while (i--) {
let option: any = internalOptions[i];
if (internalOptionsMap[option.trackingId]) {
throw new Error('Duplicate hash value for options ' + option.label + ' and ' + internalOptionsMap[option.trackingId].label);
}
internalOptionsMap[option.trackingId] = option;
}

buildInternalOptionsMap(internalOptions,internalOptionsMap);
filterOptions();

if (ngModelAlreadyRead) {
Expand Down

0 comments on commit d7866c3

Please sign in to comment.