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

Commit dc9d3c7

Browse files
committed
Fixed behaviour of closeOnSelect and closeOnDeselect
1 parent deb44a1 commit dc9d3c7

File tree

2 files changed

+59
-37
lines changed

2 files changed

+59
-37
lines changed

pages/javascripts/pages/home/home.html

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,29 @@ <h2 style="margin-bottom: 0">Download</h2>
2222
</ol>
2323
</div>
2424
</div>
25-
<accordion close-others="true">
26-
<accordion-group heading="Basic Usage Example" is-open="true">
25+
<uib-accordion close-others="true">
26+
<!--<uib-accordion-group heading="test Settings Example">
27+
<div class="row">
28+
<div class="col-xs-12">
29+
test
30+
</div>
31+
</div>
32+
<div class="row">
33+
<div class="col-xs-12 col-sm-6">
34+
<h3>Demo</h3>
35+
<div class="well">
36+
<div>
37+
<div ng-dropdown-multiselect options="testdata" selected-model="testmodel" extra-settings="testsettings"></div>
38+
</div>
39+
</div>
40+
</div>
41+
<div class="col-xs-12 col-sm-6">
42+
<h3>The model:</h3>
43+
<pre>{{testmodel|json}}</pre>
44+
</div>
45+
</div>
46+
</uib-accordion-group>-->
47+
<uib-accordion-group heading="Basic Usage Example" is-open="true">
2748
<div class="row">
2849
<div class="col-xs-12 col-sm-6">
2950
<h3>Demo</h3>
@@ -49,8 +70,8 @@ <h3>Code</h3>
4970
</div>
5071
</div>
5172
</div>
52-
</accordion-group>
53-
<accordion-group heading="Basic Settings Example">
73+
</uib-accordion-group>
74+
<uib-accordion-group heading="Basic Settings Example">
5475
<div class="row">
5576
<div class="col-xs-12">
5677
This example shows the ability to select the property to display as text label.
@@ -82,8 +103,8 @@ <h3>Code</h3>
82103
</div>
83104
</div>
84105
</div>
85-
</accordion-group>
86-
<accordion-group heading="Smart Button Text">
106+
</uib-accordion-group>
107+
<uib-accordion-group heading="Smart Button Text">
87108
<div class="row">
88109
<div class="col-xs-12">
89110
You can use the feature in order to show which items are selected instead the items count.<br />
@@ -135,8 +156,8 @@ <h3>Code</h3>
135156
</div>
136157
</div>
137158
</div>
138-
</accordion-group>
139-
<accordion-group heading="Scrollable List">
159+
</uib-accordion-group>
160+
<uib-accordion-group heading="Scrollable List">
140161
<div class="row">
141162
<div class="col-xs-12">
142163
You can use the feature in order to make the list of items scrollable. Useful when you deal with a lot of items.
@@ -185,8 +206,8 @@ <h3>Code</h3>
185206
</div>
186207
</div>
187208
</div>
188-
</accordion-group>
189-
<accordion-group heading="Enabling Search">
209+
</uib-accordion-group>
210+
<uib-accordion-group heading="Enabling Search">
190211
<div class="row">
191212
<div class="col-xs-12 col-sm-6">
192213
<h3>Demo</h3>
@@ -212,8 +233,8 @@ <h3>Code</h3>
212233
</div>
213234
</div>
214235
</div>
215-
</accordion-group>
216-
<accordion-group heading="Selection Limit">
236+
</uib-accordion-group>
237+
<uib-accordion-group heading="Selection Limit">
217238
<div class="row">
218239
<div class="col-xs-12">
219240
By default, there is no limit on the maximum selected items.
@@ -257,8 +278,8 @@ <h3>Code</h3>
257278
</div>
258279
</div>
259280
</div>
260-
</accordion-group>
261-
<accordion-group heading="Single Selection Limit">
281+
</uib-accordion-group>
282+
<uib-accordion-group heading="Single Selection Limit">
262283
<div class="row">
263284
<div class="col-xs-12">
264285
Please read the notes in the "Selection Limit" example.
@@ -297,8 +318,8 @@ <h3>Code</h3>
297318
</div>
298319
</div>
299320
</div>
300-
</accordion-group>
301-
<accordion-group heading="Group Items By Property">
321+
</uib-accordion-group>
322+
<uib-accordion-group heading="Group Items By Property">
302323
<div class="row">
303324
<div class="col-xs-12">
304325
You can also group the items by propery that you want, in order to to that, provide the "group-by" attribute.
@@ -335,8 +356,8 @@ <h3>Code</h3>
335356
</div>
336357
</div>
337358
</div>
338-
</accordion-group>
339-
<accordion-group heading="Custom ID property">
359+
</uib-accordion-group>
360+
<uib-accordion-group heading="Custom ID property">
340361
<div class="row">
341362
<div class="col-xs-12">
342363
By default, the directive tries to find "id" property for each object to identify it as unique.
@@ -371,8 +392,8 @@ <h3>Code</h3>
371392
</div>
372393
</div>
373394
</div>
374-
</accordion-group>
375-
<accordion-group heading="Model Custom Property">
395+
</uib-accordion-group>
396+
<uib-accordion-group heading="Model Custom Property">
376397
<div class="row">
377398
<div class="col-xs-12">
378399
By default, the model of the selected items will contain the objects with "id" property with the value of the idProp settings.
@@ -404,8 +425,8 @@ <h3>Code</h3>
404425
</div>
405426
</div>
406427
</div>
407-
</accordion-group>
408-
<accordion-group heading="Custom Button Text">
428+
</uib-accordion-group>
429+
<uib-accordion-group heading="Custom Button Text">
409430
<div class="row">
410431
<div class="col-xs-12">
411432
You can select your own text of the button using the "defaultText" in settings.
@@ -436,8 +457,8 @@ <h3>Code</h3>
436457
</div>
437458
</div>
438459
</div>
439-
</accordion-group>
440-
<accordion-group heading="Pre-selected Values">
460+
</uib-accordion-group>
461+
<uib-accordion-group heading="Pre-selected Values">
441462
<div class="row">
442463
<div class="col-xs-12">
443464
This example shows a demostration of using a pre-setted model.
@@ -470,8 +491,8 @@ <h3>Code</h3>
470491
</div>
471492
</div>
472493
</div>
473-
</accordion-group>
474-
<accordion-group heading="Full Object as model">
494+
</uib-accordion-group>
495+
<uib-accordion-group heading="Full Object as model">
475496
<div class="row">
476497
<div class="col-xs-12">
477498
This example shows a demostration of using full object as a model.
@@ -505,8 +526,8 @@ <h3>Code</h3>
505526
</div>
506527
</div>
507528
</div>
508-
</accordion-group>
509-
<accordion-group heading="External Search Filter">
529+
</uib-accordion-group>
530+
<uib-accordion-group heading="External Search Filter">
510531
<div class="row">
511532
<div class="col-xs-12">
512533
This example shows a demostration of access and set the search filter from outside the directive.
@@ -553,8 +574,8 @@ <h3>Code</h3>
553574
</div>
554575
</div>
555576
</div>
556-
</accordion-group>
557-
<accordion-group heading="Checkboxes List">
577+
</uib-accordion-group>
578+
<uib-accordion-group heading="Checkboxes List">
558579
<div class="row">
559580
<div class="col-xs-12">
560581
You can also use a checkboxes list by adding "checkboxes" attribute to your element!
@@ -585,8 +606,8 @@ <h3>Code</h3>
585606
</div>
586607
</div>
587608
</div>
588-
</accordion-group>
589-
<accordion-group heading="Style active items">
609+
</uib-accordion-group>
610+
<uib-accordion-group heading="Style active items">
590611
<div class="row">
591612
<div class="col-xs-12 col-sm-6">
592613
<h3>Demo</h3>
@@ -614,8 +635,8 @@ <h3>Code</h3>
614635
</div>
615636
</div>
616637
</div>
617-
</accordion-group>
618-
</accordion>
638+
</uib-accordion-group>
639+
</uib-accordion>
619640
<h1>Full API Documentation</h1>
620641
<h2>Attributes</h2>
621642
<p>List of allowed attributes, you can find more information about them in the usage examples above.</p>
@@ -765,7 +786,7 @@ <h2>Settings</h2>
765786
<td>closeOnDeselect</td>
766787
<td>Boolean</td>
767788
<td>false</td>
768-
<td>Indicates if to close the dropdown after unchecking an item on the list.</td>
789+
<td>Indicates if to close the dropdown after unchecking an item on the list. With selectionLimit = 1 setting this to true does the same as setting closeOnSelect to true.</td>
769790
</tr>
770791
<tr>
771792
<td>buttonClasses</td>

src/angularjs-dropdown-multiselect.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ directiveModule.directive('ngDropdownMultiselect', ['$filter', '$document', '$co
270270
clearObject($scope.selectedModel);
271271
angular.extend($scope.selectedModel, finalObj);
272272
$scope.externalEvents.onItemSelect(finalObj);
273-
if ($scope.settings.closeOnSelect) $scope.open = false;
273+
if ($scope.settings.closeOnSelect || $scope.settings.closeOnDeselect) $scope.open = false;
274274

275275
return;
276276
}
@@ -282,11 +282,12 @@ directiveModule.directive('ngDropdownMultiselect', ['$filter', '$document', '$co
282282
if (!dontRemove && exists) {
283283
$scope.selectedModel.splice(findIndex($scope.selectedModel, findObj), 1);
284284
$scope.externalEvents.onItemDeselect(findObj);
285+
if ($scope.settings.closeOnDeselect) $scope.open = false;
285286
} else if (!exists && ($scope.settings.selectionLimit === 0 || $scope.selectedModel.length < $scope.settings.selectionLimit)) {
286287
$scope.selectedModel.push(finalObj);
287288
$scope.externalEvents.onItemSelect(finalObj);
289+
if ($scope.settings.closeOnSelect) $scope.open = false;
288290
}
289-
if ($scope.settings.closeOnSelect) $scope.open = false;
290291
};
291292

292293
$scope.isChecked = function (id) {

0 commit comments

Comments
 (0)