Skip to content

Commit

Permalink
workflow: hide/show parameters based on other parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
masco committed Jun 3, 2019
1 parent b697ba5 commit bba3b70
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions api/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 15 additions & 3 deletions statics/js/components/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ Vue.component('item', {
'Description',
'Type',
'Values',
'Default'
'Default',
'Depends',
'Factors'
],

inject: [
'formData'
],

template: `
<div class="form-group">
<div class="form-group" v-if="allowed()">
<div v-if="Type == 'string'" class="form-group">
<label :for="Name">{{Description}}</label>
<textarea:id="Name" v-model="formData[Name]"></textarea>
Expand Down Expand Up @@ -52,7 +54,17 @@ Vue.component('item', {
<item v-for="i in item" v-bind="i" :key="i.Name"></item>
</template>
</div>
</div>`
</div>`,

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', {
Expand Down

0 comments on commit bba3b70

Please sign in to comment.