Skip to content

New customization options for when there are more than max-labels items #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
23 changes: 22 additions & 1 deletion doc/views/configs-options.htm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ <h5>Full spec</h5>
orientation="horizontal | vertical"
selection-mode="multiple | single"
max-labels="999"
show-counter="true | false"
more-text="string"
directive-id="..."
is-disabled="true | false"
helper-elements="all none reset filter"
Expand Down Expand Up @@ -177,7 +179,26 @@ <h5>max-labels</h5>
<li><code>max-labels="1"</code> will display: "Bruce Wayne, ... (2)" on the button.</li>
<li><code>max-labels="0"</code> will display: "(2)" on the button.</li>
</ul>


<h5>show-counter</h5>
<p>
To show the counter in the dropdown button if there are more items than allowed by max-labels.
</p>
<p>
<span class="inlineTitle">Type</span>: Boolean-parseable string ("true" or "false")<br />
<span class="inlineTitle">Default value</span>: "true"<br />
</p>

<h5>more-text</h5>
<p>
Text to show after the items in the dropdown button if there are
more items than allowed by max-labels.
</p>
<p>
<span class="inlineTitle">Type</span>: String<br />
<span class="inlineTitle">Default value</span>: ", ..."<br />
</p>

<h5>is-disabled</h5>
<p>
Will disable or enable all checkboxes except stated otherwise in "disable-property" above.
Expand Down
19 changes: 14 additions & 5 deletions isteven-multi-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ angular.module( 'isteven-multi-select', ['ng'] ).directive( 'istevenMultiSelect'
translation : '='
},

/*
/*
* The rest are attributes. They don't need to be parsed / binded, so we can safely access them by value.
* - buttonLabel, directiveId, helperElements, itemLabel, maxLabels, orientation, selectionMode, minSearchLength,
* tickProperty, disableProperty, groupProperty, searchProperty, maxHeight, outputProperties
* tickProperty, disableProperty, groupProperty, searchProperty, maxHeight, outputProperties, showCounter,
* moreText
*/

templateUrl:
'isteven-multi-select.htm',

Expand Down Expand Up @@ -548,9 +549,17 @@ angular.module( 'isteven-multi-select', ['ng'] ).directive( 'istevenMultiSelect'
if ( $scope.more === true ) {
// https://github.com/isteven/angular-multi-select/pull/16
if (tempMaxLabels > 0) {
$scope.varButtonLabel += ', ... ';
if ( typeof attrs.moreText !== 'undefined' ) {
$scope.varButtonLabel += attrs.moreText;
} else {
$scope.varButtonLabel += ', ...';
}
}

// Default showCounter to true
if ( typeof attrs.showCounter === 'undefined' || attrs.showCounter === 'true' ) {
$scope.varButtonLabel += '(' + $scope.outputModel.length + ')';
}
$scope.varButtonLabel += '(' + $scope.outputModel.length + ')';
}
}
$scope.varButtonLabel = $sce.trustAsHtml( $scope.varButtonLabel + '<span class="caret"></span>' );
Expand Down