Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

feat(choices): allow user select group header #1998

Merged
merged 12 commits into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bootstrap/choices.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ng-show="$select.open && $select.items.length > 0">
<li class="ui-select-choices-group" id="ui-select-choices-{{ $select.generatedId }}" >
<div class="divider" ng-show="$select.isGrouped && $index > 0"></div>
<div ng-show="$select.isGrouped" class="ui-select-choices-group-label dropdown-header" ng-bind="$group.name"></div>
<div ng-show="$select.isGrouped" class="ui-select-choices-group-label dropdown-header" ng-bind="$group.name" ng-click="$select.headerClick($group)"></div>
<div ng-attr-id="ui-select-choices-row-{{ $select.generatedId }}-{{$index}}" class="ui-select-choices-row"
ng-class="{active: $select.isActive(this), disabled: $select.isDisabled(this)}" role="option">
<span class="ui-select-choices-row-inner"></span>
Expand Down
9 changes: 9 additions & 0 deletions src/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,15 @@ body > .ui-select-bootstrap.open {
border-right: 1px solid #428bca;
}

.ui-select-bootstrap .ui-select-choices-group-label.dropdown-header:hover {
background-color: #f5f5f5;
}

.ui-select-bootstrap .ui-select-choices-group-label.dropdown-header {
color: black;
cursor: pointer;
}

.ui-select-bootstrap .ui-select-choices-row>span {
cursor: pointer;
display: block;
Expand Down
7 changes: 7 additions & 0 deletions src/uiSelectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ uis.controller('uiSelectCtrl',
throw uiSelectMinErr('searchInput', "Expected 1 input.ui-select-search but got '{0}'.", ctrl.searchInput.length);
}

ctrl.headerClick = function(g) {
var items = g.items;
for(var i = 0; i < items.length; i++) {
ctrl.select(items[i], false, ' ');
}
};

ctrl.isEmpty = function() {
return isNil(ctrl.selected) || ctrl.selected === '' || (ctrl.multiple && ctrl.selected.length === 0);
};
Expand Down