From 45af8a304073c77f9f72ce8dab7d8b19916a5faa Mon Sep 17 00:00:00 2001 From: Rumit Parakhiya Date: Tue, 25 Oct 2016 23:30:43 +0530 Subject: [PATCH] Added extra setting option using which client can enable/disable options --- pages/javascripts/pages/home/home.html | 6 ++++++ src/angularjs-dropdown-multiselect.js | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pages/javascripts/pages/home/home.html b/pages/javascripts/pages/home/home.html index cfcf370d..6d306a8a 100644 --- a/pages/javascripts/pages/home/home.html +++ b/pages/javascripts/pages/home/home.html @@ -801,6 +801,12 @@

Settings

angular.noop Related the "Smart Button Text" feature, if a function provided - it will called with two paramters: The item's text and the original item, the return value will displayed instead of the item's display property. This feature is useful when you want to convert the displayed text into something else. + + allowSelectionProp + String + undefined + Name of the property that should be used to determine it should allow user to select the option or not +

Events

diff --git a/src/angularjs-dropdown-multiselect.js b/src/angularjs-dropdown-multiselect.js index 81f611b4..4ee61f58 100644 --- a/src/angularjs-dropdown-multiselect.js +++ b/src/angularjs-dropdown-multiselect.js @@ -36,10 +36,10 @@ directiveModule.directive('ngDropdownMultiselect', ['$filter', '$document', '$co template += '
  • '; } - template += ''; + template += ''; if (checkboxes) { - template += '
    '; + template += '
    '; } else { template += ' {{getPropertyForObject(option, settings.displayProp)}}'; } @@ -93,7 +93,8 @@ directiveModule.directive('ngDropdownMultiselect', ['$filter', '$document', '$co groupBy: $attrs.groupBy || undefined, groupByTextProvider: null, smartButtonMaxItems: 0, - smartButtonTextConverter: angular.noop + smartButtonTextConverter: angular.noop, + allowSelectionProp: undefined }; $scope.texts = { @@ -257,6 +258,11 @@ directiveModule.directive('ngDropdownMultiselect', ['$filter', '$document', '$co finalObj = findObj; } + if($scope.settings.allowSelectionProp && getPropertyForObject(_.find($scope.options, findObj), $scope.settings.allowSelectionProp) === false) { + //Disabled option + return; + } + if ($scope.singleSelection) { clearObject($scope.selectedModel); angular.extend($scope.selectedModel, finalObj);