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

New feature: allow displaying information when there is no record found #1011

Merged
merged 1 commit into from
Mar 28, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions src/bootstrap/no-choice.tpl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ul class="ui-select-no-choice dropdown-menu"
ng-show="$select.items.length == 0">
<li ng-transclude>

</li>
</ul>
1 change: 1 addition & 0 deletions src/bootstrap/select.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
ng-model="$select.search"
ng-show="$select.searchEnabled && $select.open">
<div class="ui-select-choices"></div>
<div class="ui-select-no-choice"></div>
</div>
2 changes: 1 addition & 1 deletion src/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ body > .select2-container.open {
}

/* See Scrollable Menu with Bootstrap 3 http://stackoverflow.com/questions/19227496 */
.ui-select-bootstrap > .ui-select-choices {
.ui-select-bootstrap > .ui-select-choices ,.ui-select-bootstrap > .ui-select-no-choice {
width: 100%;
height: auto;
max-height: 200px;
Expand Down
7 changes: 7 additions & 0 deletions src/uiSelectDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ uis.directive('uiSelect',
throw uiSelectMinErr('transcluded', "Expected 1 .ui-select-choices but got '{0}'.", transcludedChoices.length);
}
element.querySelectorAll('.ui-select-choices').replaceWith(transcludedChoices);

var transcludedNoChoice = transcluded.querySelectorAll('.ui-select-no-choice');
transcludedNoChoice.removeAttr('ui-select-no-choice'); //To avoid loop in case directive as attr
transcludedNoChoice.removeAttr('data-ui-select-no-choice'); // Properly handle HTML5 data-attributes
if (transcludedNoChoice.length == 1) {
element.querySelectorAll('.ui-select-no-choice').replaceWith(transcludedNoChoice);
}
});

// Support for appending the select field to the body when its open
Expand Down
14 changes: 14 additions & 0 deletions src/uiSelectNoChoiceDirective.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uis.directive('uiSelectNoChoice',
['uiSelectConfig', function (uiSelectConfig) {
return {
restrict: 'EA',
require: '^uiSelect',
replace: true,
transclude: true,
templateUrl: function (tElement) {
// Gets theme attribute from parent (ui-select)
var theme = tElement.parent().attr('theme') || uiSelectConfig.theme;
return theme + '/no-choice.tpl.html';
}
};
}]);