Skip to content

Commit bba3b70

Browse files
committed
workflow: hide/show parameters based on other parameter
1 parent b697ba5 commit bba3b70

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

api/types/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ type WorkflowParam struct {
193193
Type string `yaml:"Type"`
194194
Default interface{} `yaml:"Default"`
195195
Values []WorkflowChoice `yaml:"Values"`
196+
Depends string `yaml:"Depends"`
197+
Factors []interface{} `yaml:"Factors"`
196198
}
197199

198200
// Workflow describes a workflow

statics/js/components/workflow.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ Vue.component('item', {
66
'Description',
77
'Type',
88
'Values',
9-
'Default'
9+
'Default',
10+
'Depends',
11+
'Factors'
1012
],
1113

1214
inject: [
1315
'formData'
1416
],
1517

1618
template: `
17-
<div class="form-group">
19+
<div class="form-group" v-if="allowed()">
1820
<div v-if="Type == 'string'" class="form-group">
1921
<label :for="Name">{{Description}}</label>
2022
<textarea:id="Name" v-model="formData[Name]"></textarea>
@@ -52,7 +54,17 @@ Vue.component('item', {
5254
<item v-for="i in item" v-bind="i" :key="i.Name"></item>
5355
</template>
5456
</div>
55-
</div>`
57+
</div>`,
58+
59+
methods: {
60+
allowed: function() {
61+
if (this.Depends === "" || this.Factors === null) {
62+
return true
63+
}
64+
let d = this.formData[this.Depends]
65+
return this.Factors.indexOf(d) >= 0
66+
}
67+
},
5668
})
5769

5870
Vue.component('workflow-params', {

0 commit comments

Comments
 (0)