From 89c01475f53d8ecc07256d9147609f96dff2c9ef Mon Sep 17 00:00:00 2001 From: gconsidine Date: Thu, 30 Mar 2017 17:15:16 -0400 Subject: [PATCH] Add display of multi-select options in survey preview --- awx/ui/client/src/shared/Utilities.js | 4 ++++ .../survey-maker/render/multiple-choice.directive.js | 6 +++--- .../survey-maker/render/survey-question.partial.html | 3 +-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/awx/ui/client/src/shared/Utilities.js b/awx/ui/client/src/shared/Utilities.js index 3d3646e64d..0b7a86970f 100644 --- a/awx/ui/client/src/shared/Utilities.js +++ b/awx/ui/client/src/shared/Utilities.js @@ -665,6 +665,10 @@ angular.module('Utilities', ['RestServices', 'Utilities']) // Don't toggle the dropdown when a multiselect option is // being removed if (multiple) { + if (params.disabledOptions) { + $(element).on('select2:selecting', e => e.preventDefault()); + } + $(element).on('select2:opening', (e) => { var unselecting = $(e.target).data('select2-unselecting'); if (unselecting === true) { diff --git a/awx/ui/client/src/templates/survey-maker/render/multiple-choice.directive.js b/awx/ui/client/src/templates/survey-maker/render/multiple-choice.directive.js index 1be5229456..6b30a42248 100644 --- a/awx/ui/client/src/templates/survey-maker/render/multiple-choice.directive.js +++ b/awx/ui/client/src/templates/survey-maker/render/multiple-choice.directive.js @@ -2,7 +2,6 @@ import {templateUrl} from '../../../shared/template-url/template-url.factory'; function link($timeout, CreateSelect2, scope, element, attrs, ngModel) { - $timeout(function() { // select2-ify the dropdown. If the preview flag is passed here @@ -13,12 +12,13 @@ function link($timeout, CreateSelect2, scope, element, attrs, ngModel) { // and we don't actually need the dropdown portion. Note that the custom // dropdown adapter is used to get the dropdown contents to show up in // a modal. + CreateSelect2({ element: element.find('select'), multiple: scope.isMultipleSelect(), - customDropdownAdapter: scope.preview ? false : true + customDropdownAdapter: scope.preview ? false : true, + disabledOptions: true }); - }); } diff --git a/awx/ui/client/src/templates/survey-maker/render/survey-question.partial.html b/awx/ui/client/src/templates/survey-maker/render/survey-question.partial.html index 0777b94c90..381686d868 100644 --- a/awx/ui/client/src/templates/survey-maker/render/survey-question.partial.html +++ b/awx/ui/client/src/templates/survey-maker/render/survey-question.partial.html @@ -11,8 +11,7 @@ choices="choices" ng-required="isRequired === 'true'" ng-model="defaultValue" - ng-disabled="isDisabled === 'true'" - preview="preview"> + ng-disabled="isDisabled === 'false'">