Skip to content

Commit

Permalink
feat(ui): add some missing input type
Browse files Browse the repository at this point in the history
close #610
  • Loading branch information
tchiotludo committed Jul 4, 2022
1 parent f305477 commit aec0bb8
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 4 deletions.
66 changes: 62 additions & 4 deletions ui/src/components/flows/FlowRun.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
type="text"
:required="input.required"
:placeholder="`${placeholder} ${input.name}`"
:state="state(input)"
/>
<b-form-input
v-if="input.type === 'INT'"
Expand All @@ -26,6 +27,7 @@
step="1"
:required="input.required"
:placeholder="`${placeholder} ${input.name}`"
:state="state(input)"
/>
<b-form-input
v-if="input.type === 'FLOAT'"
Expand All @@ -34,28 +36,69 @@
step="0.001"
:required="input.required"
:placeholder="`${placeholder} ${input.name}`"
:state="state(input)"
/>
<b-form-checkbox
v-if="input.type === 'BOOLEAN'"
v-model="input.value"
type="checkbox"
value="true"
unchecked-value="false"
:required="input.required"
:state="state(input)"
/>
<date-picker
v-if="input.type === 'DATETIME'"
v-model="input.value"
:required="input.required"
:state="state(input)"
type="datetime"
class="w-100"
:placeholder="$t('select datetime')"
:placeholder="`${placeholder} ${input.name}`"
/>
<date-picker
v-if="input.type === 'DATE'"
v-model="input.value"
:required="input.required"
:state="state(input)"
type="date"
:placeholder="`${placeholder} ${input.name}`"
/>
<date-picker
v-if="input.type === 'TIME'"
v-model="input.value"
:required="input.required"
:state="state(input)"
type="time"
:placeholder="`${placeholder} ${input.name}`"
/>
<date-picker
v-if="input.type === 'DURATION'"
v-model="input.value"
:required="input.required"
:state="state(input)"
type="time"
:placeholder="`${placeholder} ${input.name}`"
/>
<b-form-file
v-if="input.type === 'FILE'"
v-model="input.value"
:required="input.required"
:state="Boolean(input.value)"
:state="state(input)"
:placeholder="$t('choose file')"
/>
<b-form-textarea
v-if="input.type === 'JSON'"
v-model="input.value"
:required="input.required"
:state="state(input)"
:placeholder="`${placeholder} ${input.name}`"
/>
<small v-if="input.description" class="form-text text-muted">{{ input.description }}</small>
</b-form-group>
<b-form-group class="text-right mb-0">
<b-button type="submit" variant="primary" :disabled="flow.disabled" v-b-tooltip.hover.top="'(Ctrl + Enter)'">
{{ $t('launch execution') }}
<trigger title />
<trigger title="" />
</b-button>
</b-form-group>
</b-form>
Expand Down Expand Up @@ -97,7 +140,22 @@
onSubmit() {
executeTask(this, this.flow, {redirect: this.redirect, id: this.flow.id, namespace: this.flow.namespace})
this.$emit("onExecutionTrigger")
},
state(input) {
const required = input.required === undefined ? true : input.required;
if (!required && input.value === undefined) {
return null;
}
if (required && input.value === undefined) {
return false;
}
return true;
}
}
};
</script>
Expand Down
8 changes: 8 additions & 0 deletions ui/src/styles/layout/bootstrap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,14 @@ select {
}
}

form {
.form-group {
.custom-checkbox {
top: 8px;
}
}
}

.custom-file-label {
font-size: $input-font-size;
color: $input-placeholder-color;
Expand Down
8 changes: 8 additions & 0 deletions ui/src/utils/submitTask.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import Vue from "vue";

export const executeTask = (submitor, flow, options) => {
const formData = new FormData();
for (let input of flow.inputs || []) {
if (input.value !== undefined) {
if (input.type === "DATETIME") {
formData.append(input.name, input.value.toISOString());
} else if (input.type === "DATE") {
formData.append(input.name, Vue.moment(input.value).format("YYYY-MM-DD"));
} else if (input.type === "TIME") {
formData.append(input.name, Vue.moment(input.value).format("hh:mm:ss"));
} else if (input.type === "DURATION") {
formData.append(input.name, Vue.moment.duration(Vue.moment(input.value).format("hh:mm:ss")));
} else if (input.type === "FILE") {
formData.append("files", input.value, input.name);
} else {
Expand Down

0 comments on commit aec0bb8

Please sign in to comment.