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

Commit a2726ed

Browse files
committed
Added the smartButtonTextProvider setting
1 parent e7e6003 commit a2726ed

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

src/app/component/angularjs-dropdown-multiselect.controller.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ export default function dropdownMultiselectController(
230230

231231
function getButtonText() {
232232
if ($scope.settings.dynamicTitle && $scope.selectedModel && $scope.selectedModel.length > 0) {
233+
if (angular.isFunction($scope.settings.smartButtonTextProvider)) {
234+
return $scope.settings.smartButtonTextProvider($scope.selectedModel);
235+
}
236+
233237
if ($scope.settings.smartButtonMaxItems > 0) {
234238
const paddingWidth = 12 * 2;
235239
const borderWidth = 1 * 2;

src/app/main/main.controller.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,5 +324,18 @@ export default class MainController {
324324
$scope.idPropertySettings = {
325325
idProperty: 'id',
326326
};
327+
328+
$scope.smartButtonTextProviderModel = [
329+
];
330+
$scope.smartButtonTextProviderData = [
331+
{ id: 1, label: 'David' },
332+
{ id: 2, label: 'Jhon' },
333+
{ id: 3, label: 'Danny' },
334+
];
335+
$scope.smartButtonTextProviderSettings = {
336+
smartButtonTextProvider(selectionArray) {
337+
return selectionArray.length + 2;
338+
},
339+
};
327340
}
328341
}

src/app/main/main.template.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,48 @@ <h3>Code</h3>
10581058
];
10591059
$scope.idPropertySettings = {
10601060
idProperty: 'id',
1061+
};
1062+
</div>
1063+
</div>
1064+
</div>
1065+
</div>
1066+
<div uib-accordion-group heading="Button text provider">
1067+
<div class="row">
1068+
<div class="col-xs-12">
1069+
When there is a selection this method will be called with the selection as a parameter. The function is supposed to return the text that you want to display on the button.
1070+
</div>
1071+
</div>
1072+
<div class="row">
1073+
<div class="col-xs-12 col-sm-6">
1074+
<h3>Demo</h3>
1075+
<div class="well">
1076+
<div ng-dropdown-multiselect="" options="smartButtonTextProviderData" selected-model="smartButtonTextProviderModel" extra-settings="smartButtonTextProviderSettings">
1077+
</div>
1078+
</div>
1079+
</div>
1080+
<div class="col-xs-12 col-sm-6">
1081+
<h3>The model:</h3>
1082+
<pre>{{smartButtonTextProviderModel|json}}</pre>
1083+
</div>
1084+
</div>
1085+
<div class="row">
1086+
<div class="col-md-12">
1087+
<h3>Code</h3>
1088+
<div hljs language="javascript">
1089+
// HTML
1090+
<div ng-dropdown-multiselect="" options="idPropertyData" selected-model="idPropertyModel" extra-settings="idPropertySettings">
1091+
</div>
1092+
1093+
$scope.smartButtonTextProviderModel = [];
1094+
$scope.smartButtonTextProviderData = [
1095+
{ id: 1, label: 'David' },
1096+
{ id: 2, label: 'Jhon' },
1097+
{ id: 3, label: 'Danny' },
1098+
];
1099+
$scope.idPropertySettings = {
1100+
smartButtonTextProvider(selectionArray) {
1101+
return selectionArray.length + 2;
1102+
},
10611103
};
10621104
</div>
10631105
</div>

0 commit comments

Comments
 (0)