From c71068fa1c4e98801aaa0c4dd68c4658bb1724f8 Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 7 Aug 2019 11:01:39 -0400 Subject: [PATCH] Create at-switch directive. Use it in all the places --- awx/ui/client/lib/components/_index.less | 1 + awx/ui/client/lib/components/index.js | 2 ++ .../components/switch/_index.less} | 0 .../lib/components/switch/switch.directive.js | 22 +++++++++++++++++++ .../lib/components/switch/switch.partial.html | 6 +++++ awx/ui/client/lib/theme/index.less | 1 - .../configuration-system.partial.html | 7 +----- .../instances/instances-list.partial.html | 7 +----- .../hosts/hosts.partial.html | 7 +----- .../src/partials/survey-maker-modal.html | 7 +----- awx/ui/client/src/shared/form-generator.js | 21 +++--------------- awx/ui/client/src/shared/generator-helpers.js | 7 +----- .../prompt-other-prompts.partial.html | 7 +----- 13 files changed, 40 insertions(+), 55 deletions(-) rename awx/ui/client/{src/shared/switch.block.less => lib/components/switch/_index.less} (100%) create mode 100644 awx/ui/client/lib/components/switch/switch.directive.js create mode 100644 awx/ui/client/lib/components/switch/switch.partial.html diff --git a/awx/ui/client/lib/components/_index.less b/awx/ui/client/lib/components/_index.less index a0be9a31a7..81dc40c580 100644 --- a/awx/ui/client/lib/components/_index.less +++ b/awx/ui/client/lib/components/_index.less @@ -15,3 +15,4 @@ @import 'utility/_index'; @import 'code-mirror/_index'; @import 'cards/_index'; +@import 'switch/_index'; diff --git a/awx/ui/client/lib/components/index.js b/awx/ui/client/lib/components/index.js index f6ae129858..8080175627 100644 --- a/awx/ui/client/lib/components/index.js +++ b/awx/ui/client/lib/components/index.js @@ -44,6 +44,7 @@ import truncate from '~components/truncate/truncate.directive'; import atCodeMirror from '~components/code-mirror'; import card from '~components/cards/card.directive'; import cardGroup from '~components/cards/group.directive'; +import atSwitch from '~components/switch/switch.directive'; import BaseInputController from '~components/input/base.controller'; import ComponentsStrings from '~components/components.strings'; @@ -98,6 +99,7 @@ angular .directive('atTruncate', truncate) .directive('atCard', card) .directive('atCardGroup', cardGroup) + .directive('atSwitch', atSwitch) .service('BaseInputController', BaseInputController) .service('ComponentsStrings', ComponentsStrings); diff --git a/awx/ui/client/src/shared/switch.block.less b/awx/ui/client/lib/components/switch/_index.less similarity index 100% rename from awx/ui/client/src/shared/switch.block.less rename to awx/ui/client/lib/components/switch/_index.less diff --git a/awx/ui/client/lib/components/switch/switch.directive.js b/awx/ui/client/lib/components/switch/switch.directive.js new file mode 100644 index 0000000000..cf33d29f55 --- /dev/null +++ b/awx/ui/client/lib/components/switch/switch.directive.js @@ -0,0 +1,22 @@ +const templateUrl = require('~components/switch/switch.partial.html'); + +function atSwitch () { + return { + restrict: 'E', + replace: true, + templateUrl, + scope: { + hide: '=', + onToggle: '&', + switchOn: '=', + switchDisabled: '=', + tooltip: '=', + tooltipString: '@', + tooltipPlacement: '@', + tooltipContainer: '@', + tooltipWatch: '=' + }, + }; +} + +export default atSwitch; diff --git a/awx/ui/client/lib/components/switch/switch.partial.html b/awx/ui/client/lib/components/switch/switch.partial.html new file mode 100644 index 0000000000..59dde21588 --- /dev/null +++ b/awx/ui/client/lib/components/switch/switch.partial.html @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/awx/ui/client/lib/theme/index.less b/awx/ui/client/lib/theme/index.less index eb289aff5a..a9f9d2bdde 100644 --- a/awx/ui/client/lib/theme/index.less +++ b/awx/ui/client/lib/theme/index.less @@ -108,7 +108,6 @@ @import '../../src/shared/media-object.block.less'; @import '../../src/shared/text-label'; @import '../../src/shared/upgrade/upgrade.block.less'; -@import '../../src/shared/switch.block.less'; @import '../../src/smart-status/smart-status.block.less'; @import '../../src/workflow-results/standard-out.block.less'; @import '../../src/templates/prompt/prompt.block.less'; diff --git a/awx/ui/client/src/configuration/forms/system-form/configuration-system.partial.html b/awx/ui/client/src/configuration/forms/system-form/configuration-system.partial.html index 4a20835129..0a32b40b95 100644 --- a/awx/ui/client/src/configuration/forms/system-form/configuration-system.partial.html +++ b/awx/ui/client/src/configuration/forms/system-form/configuration-system.partial.html @@ -35,12 +35,7 @@ - - - - - - +
diff --git a/awx/ui/client/src/instance-groups/instances/instances-list.partial.html b/awx/ui/client/src/instance-groups/instances/instances-list.partial.html index 0afd4d99be..06524af963 100644 --- a/awx/ui/client/src/instance-groups/instances/instances-list.partial.html +++ b/awx/ui/client/src/instance-groups/instances/instances-list.partial.html @@ -45,12 +45,7 @@
- - - - - - +
diff --git a/awx/ui/client/src/inventories-hosts/hosts/hosts.partial.html b/awx/ui/client/src/inventories-hosts/hosts/hosts.partial.html index baa70f694a..d8e5e684e8 100644 --- a/awx/ui/client/src/inventories-hosts/hosts/hosts.partial.html +++ b/awx/ui/client/src/inventories-hosts/hosts/hosts.partial.html @@ -52,12 +52,7 @@
- - - - - - +
diff --git a/awx/ui/client/src/partials/survey-maker-modal.html b/awx/ui/client/src/partials/survey-maker-modal.html index e4f4c542b4..2809a93591 100644 --- a/awx/ui/client/src/partials/survey-maker-modal.html +++ b/awx/ui/client/src/partials/survey-maker-modal.html @@ -22,12 +22,7 @@
{{name || "New Job Template"}}
SURVEY
- - - - - - +
diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index 90a99d33d5..994ec53a89 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -514,12 +514,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat if (field.type === 'toggle'){ html += `
- - - - - - +
`; } else if (field.type === 'html') { @@ -673,12 +668,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat if (field.type === 'toggle'){ html += ` - - - - - - + `; } @@ -737,12 +727,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += `
- - - - - - +
`; } diff --git a/awx/ui/client/src/shared/generator-helpers.js b/awx/ui/client/src/shared/generator-helpers.js index 84fe68fed5..18907f78d4 100644 --- a/awx/ui/client/src/shared/generator-helpers.js +++ b/awx/ui/client/src/shared/generator-helpers.js @@ -529,12 +529,7 @@ angular.module('GeneratorHelpers', [systemStatus.name]) } else if (field.type === 'toggle') { html += `
- - - - - - +
`; } else if (field.type === 'invalid') { diff --git a/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.partial.html b/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.partial.html index f6eda5d111..ca57599137 100644 --- a/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.partial.html +++ b/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.partial.html @@ -111,12 +111,7 @@
- - - - - - +