From fc1591ffbf4a8c564143c877e78a80d962e75909 Mon Sep 17 00:00:00 2001 From: Miikka Koskinen Date: Tue, 15 Dec 2015 16:09:47 +0200 Subject: [PATCH 1/2] Add a way to disable the item counter --- doc/views/configs-options.htm | 12 +++++++++++- isteven-multi-select.js | 8 ++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/doc/views/configs-options.htm b/doc/views/configs-options.htm index 73b38a7..98d5f79 100644 --- a/doc/views/configs-options.htm +++ b/doc/views/configs-options.htm @@ -16,6 +16,7 @@
Full spec
orientation="horizontal | vertical" selection-mode="multiple | single" max-labels="999" + show-counter="true" directive-id="..." is-disabled="true | false" helper-elements="all none reset filter" @@ -177,7 +178,16 @@
max-labels
  • max-labels="1" will display: "Bruce Wayne, ... (2)" on the button.
  • max-labels="0" will display: "(2)" on the button.
  • - + +
    show-counter
    +

    + To show the counter in the dropdown button if there are more items than allowed by max-labels. +

    +

    + Type: Boolean-parseable string ("true" or "false")
    + Default value: "true"
    +

    +
    is-disabled

    Will disable or enable all checkboxes except stated otherwise in "disable-property" above. diff --git a/isteven-multi-select.js b/isteven-multi-select.js index b5d3465..dac48ac 100644 --- a/isteven-multi-select.js +++ b/isteven-multi-select.js @@ -64,7 +64,7 @@ angular.module( 'isteven-multi-select', ['ng'] ).directive( 'istevenMultiSelect' /* * 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 */ templateUrl: @@ -550,7 +550,11 @@ angular.module( 'isteven-multi-select', ['ng'] ).directive( 'istevenMultiSelect' if (tempMaxLabels > 0) { $scope.varButtonLabel += ', ... '; } - $scope.varButtonLabel += '(' + $scope.outputModel.length + ')'; + + // Default showCounter to true + if ( typeof attrs.showCounter === 'undefined' || attrs.showCounter === 'true' ) { + $scope.varButtonLabel += '(' + $scope.outputModel.length + ')'; + } } } $scope.varButtonLabel = $sce.trustAsHtml( $scope.varButtonLabel + '' ); From a93353c096992e04d75d40c9607ce323e37931fa Mon Sep 17 00:00:00 2001 From: Miikka Koskinen Date: Tue, 15 Dec 2015 16:11:17 +0200 Subject: [PATCH 2/2] Make the ellipsis in the dropdown customizable --- doc/views/configs-options.htm | 13 ++++++++++++- isteven-multi-select.js | 13 +++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/views/configs-options.htm b/doc/views/configs-options.htm index 98d5f79..4cc3d41 100644 --- a/doc/views/configs-options.htm +++ b/doc/views/configs-options.htm @@ -16,7 +16,8 @@

    Full spec
    orientation="horizontal | vertical" selection-mode="multiple | single" max-labels="999" - show-counter="true" + show-counter="true | false" + more-text="string" directive-id="..." is-disabled="true | false" helper-elements="all none reset filter" @@ -188,6 +189,16 @@
    show-counter
    Default value: "true"

    +
    more-text
    +

    + Text to show after the items in the dropdown button if there are + more items than allowed by max-labels. +

    +

    + Type: String
    + Default value: ", ..."
    +

    +
    is-disabled

    Will disable or enable all checkboxes except stated otherwise in "disable-property" above. diff --git a/isteven-multi-select.js b/isteven-multi-select.js index dac48ac..611cfcc 100644 --- a/isteven-multi-select.js +++ b/isteven-multi-select.js @@ -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, showCounter + * tickProperty, disableProperty, groupProperty, searchProperty, maxHeight, outputProperties, showCounter, + * moreText */ - + templateUrl: 'isteven-multi-select.htm', @@ -548,7 +549,11 @@ 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