From bba3b705faf7bf399c4a1a024b5cd1552d966639 Mon Sep 17 00:00:00 2001 From: Masco Kaliyamoorthy Date: Wed, 29 May 2019 16:32:52 +0530 Subject: [PATCH] workflow: hide/show parameters based on other parameter --- api/types/types.go | 2 ++ statics/js/components/workflow.js | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/api/types/types.go b/api/types/types.go index 1085d17259..3549cec64f 100644 --- a/api/types/types.go +++ b/api/types/types.go @@ -193,6 +193,8 @@ type WorkflowParam struct { Type string `yaml:"Type"` Default interface{} `yaml:"Default"` Values []WorkflowChoice `yaml:"Values"` + Depends string `yaml:"Depends"` + Factors []interface{} `yaml:"Factors"` } // Workflow describes a workflow diff --git a/statics/js/components/workflow.js b/statics/js/components/workflow.js index 12ccb0b37b..52652ed24e 100644 --- a/statics/js/components/workflow.js +++ b/statics/js/components/workflow.js @@ -6,7 +6,9 @@ Vue.component('item', { 'Description', 'Type', 'Values', - 'Default' + 'Default', + 'Depends', + 'Factors' ], inject: [ @@ -14,7 +16,7 @@ Vue.component('item', { ], template: ` -
+
@@ -52,7 +54,17 @@ Vue.component('item', {
-
` +
`, + + methods: { + allowed: function() { + if (this.Depends === "" || this.Factors === null) { + return true + } + let d = this.formData[this.Depends] + return this.Factors.indexOf(d) >= 0 + } + }, }) Vue.component('workflow-params', {