Skip to content

Commit

Permalink
⚗️ : show list component for list-alike regex validated variables
Browse files Browse the repository at this point in the history
  • Loading branch information
juwit committed Aug 30, 2019
1 parent a9b27b9 commit aabf795
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/resources/templates/vue_templates/stack-vars.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
<div class="form-row align-items-end" v-for="(modVar,modVarIdx) in editableVars" v-if="editableVars.length > 0">
<b-col>
<b-form-group :label="modVar.name" :description="modVar.description">
<b-input v-model="stack.variableValues[modVar.name]"
<b-input v-if="! isListRegex(modVar.validationRegex)"
v-model="stack.variableValues[modVar.name]"
:state="validateVariable(modVar).result"
@update="recomputeState"
trim></b-input>
<b-select v-if="isListRegex(modVar.validationRegex)"
v-model="stack.variableValues[modVar.name]"
:state="validateVariable(modVar).result"
@change="recomputeState"
:options="listOptions(modVar.validationRegex)"></b-select>
<b-form-invalid-feedback>{{validateVariable(modVar).message}}</b-form-invalid-feedback>
</b-form-group>
</b-col>
Expand Down Expand Up @@ -57,6 +63,16 @@ Vue.component('stack-vars', {
}
return {result:true};
},
isListRegex: function(regex){
const listRegex = /^\((\w*)(\|(\w*))*\)$/;
return listRegex.test(regex);
},
listOptions: function(regex){
const listExtractRegex = /[^()|]+/g;
// extracting the values from the regex
// also adding empty string to the result to be able to not select anything !
return ["", ...regex.match(listExtractRegex)];
}
},
computed: {
Expand Down

0 comments on commit aabf795

Please sign in to comment.