diff --git a/awx/ui/static/js/shared/multi-select-list/multi-select-list.directive.js b/awx/ui/static/js/shared/multi-select-list/multi-select-list.directive.js index f65d8a2f4d..3a9e0f8ae7 100644 --- a/awx/ui/static/js/shared/multi-select-list/multi-select-list.directive.js +++ b/awx/ui/static/js/shared/multi-select-list/multi-select-list.directive.js @@ -63,6 +63,68 @@ + + # Making other elements respond to the state of the selction + + In this example, we'll see how to make a button that enables/disables + itself based on some property of the selection. + + + + angular.module('stateTrackingExample', ['multiSelectList']) + .controller('namesController', ['$scope', function($scope) { + $scope.names = + [ { name: 'John' + }, + { name: 'Jared' + }, + { name: 'Joe' + }, + { name: 'James' + }, + { name: 'Matt' + }, + { name: 'Luke' + }, + { name: 'Chris' + } + ]; + + // Initial logic for buttons + $scope.noSelections = true; + $scope.atLeastOneSelection = false; + $scope.exactlyTwoSelections = false; + + var cleanup = $scope.$on('multiSelectList.selectionChanged', function(e, selection) { + // Recalculate logic for buttons whenever selections change + $scope.noSelections = selection.length == 0; + $scope.atLeastOneSelection = selection.length >= 1; + $scope.exactlyTwoSelections = selection.length == 2; + }); + }]); + + +
+ + + +
    +
  • + + {{item.name}} +
  • +
+
+
+ +
+ * */ import controller from './multi-select-list.controller';