show optional fields in generic forms
This commit is contained in:
parent
237bcb92c9
commit
439539f56d
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<b-form-group v-bind:label="label" class="mb-3">
|
||||
<b-form-group v-bind:label="field_label" class="mb-3">
|
||||
<b-form-select v-model="new_value" :placeholder="placeholder" :options="translatedOptions"></b-form-select>
|
||||
</b-form-group>
|
||||
</div>
|
||||
@ -10,12 +10,13 @@
|
||||
export default {
|
||||
name: "ChoiceInput",
|
||||
props: {
|
||||
field: { type: String, default: "You Forgot To Set Field Name" },
|
||||
label: { type: String, default: "Text Field" },
|
||||
value: { type: String, default: "" },
|
||||
field: {type: String, default: "You Forgot To Set Field Name"},
|
||||
label: {type: String, default: "Text Field"},
|
||||
value: {type: String, default: ""},
|
||||
options: [],
|
||||
placeholder: { type: String, default: "You Should Add Placeholder Text" },
|
||||
show_merge: { type: Boolean, default: false },
|
||||
placeholder: {type: String, default: "You Should Add Placeholder Text"},
|
||||
show_merge: {type: Boolean, default: false},
|
||||
optional: {type: Boolean, default: false},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -31,9 +32,16 @@ export default {
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
field_label: function () {
|
||||
if (this.optional) {
|
||||
return this.label
|
||||
} else {
|
||||
return this.label + '*'
|
||||
}
|
||||
},
|
||||
translatedOptions() {
|
||||
return this.options.map((x) => {
|
||||
return { ...x, text: this.$t(x.text) }
|
||||
return {...x, text: this.$t(x.text)}
|
||||
})
|
||||
},
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<b-form-group v-bind:label="label" class="mb-3">
|
||||
<b-form-group v-bind:label="field_label" class="mb-3">
|
||||
<b-form-input v-model="new_value" type="date" ></b-form-input>
|
||||
<em v-if="help" class="small text-muted">{{ help }}</em>
|
||||
<small v-if="subtitle" class="text-muted">{{ subtitle }}</small>
|
||||
@ -17,6 +17,16 @@ export default {
|
||||
value: { type: String, default: "" },
|
||||
help: { type: String, default: undefined },
|
||||
subtitle: { type: String, default: undefined },
|
||||
optional: {type: Boolean, default: false},
|
||||
},
|
||||
computed: {
|
||||
field_label: function () {
|
||||
if (this.optional) {
|
||||
return this.label
|
||||
} else {
|
||||
return this.label + '*'
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<b-form-group
|
||||
v-bind:label="label"
|
||||
v-bind:label="field_label"
|
||||
class="mb-3">
|
||||
|
||||
<input class="form-control" v-model="new_value">
|
||||
@ -27,6 +27,7 @@ export default {
|
||||
field: {type: String, default: 'You Forgot To Set Field Name'},
|
||||
label: {type: String, default: ''},
|
||||
value: {type: String, default: ''},
|
||||
optional: {type: Boolean, default: false},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -36,6 +37,15 @@ export default {
|
||||
emojisOutput: ""
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
field_label: function () {
|
||||
if (this.optional) {
|
||||
return this.label
|
||||
} else {
|
||||
return this.label + '*'
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'new_value': function () {
|
||||
this.$root.$emit('change', this.field, this.new_value ?? null)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<b-form-group
|
||||
v-bind:label="label"
|
||||
v-bind:label="field_label"
|
||||
class="mb-3">
|
||||
<b-form-file
|
||||
v-model="new_value"
|
||||
@ -30,7 +30,17 @@ export default {
|
||||
value: {type: String, default: ''},
|
||||
placeholder: {type: String, default: ''},
|
||||
show_merge: {type: Boolean, default: false},
|
||||
optional: {type: Boolean, default: false},
|
||||
},
|
||||
computed: {
|
||||
field_label: function () {
|
||||
if (this.optional) {
|
||||
return this.label
|
||||
} else {
|
||||
return this.label + '*'
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
new_value: undefined,
|
||||
|
@ -11,15 +11,16 @@
|
||||
</template>
|
||||
<div v-for="(f, i) in form.fields" v-bind:key="i">
|
||||
<p v-if="visibleCondition(f, 'instruction')">{{ f.label }}</p>
|
||||
<lookup-input v-if="visibleCondition(f, 'lookup')" :form="f" :model="listModel(f.list)" @change="storeValue" :help="showHelp && f.help"/>
|
||||
<lookup-input v-if="visibleCondition(f, 'lookup')" :form="f" :model="listModel(f.list)" @change="storeValue" :help="showHelp && f.help" :optional="f.optional"/>
|
||||
<checkbox-input class="mb-3" v-if="visibleCondition(f, 'checkbox')" :label="f.label" :value="f.value" :field="f.field" :help="showHelp && f.help"/>
|
||||
<text-input v-if="visibleCondition(f, 'text')" :label="f.label" :value="f.value" :field="f.field" :placeholder="f.placeholder" :help="showHelp && f.help" :subtitle="f.subtitle" :disabled="f.disabled"/>
|
||||
<choice-input v-if="visibleCondition(f, 'choice')" :label="f.label" :value="f.value" :field="f.field" :options="f.options" :placeholder="f.placeholder"/>
|
||||
<emoji-input v-if="visibleCondition(f, 'emoji')" :label="f.label" :value="f.value" :field="f.field" @change="storeValue"/>
|
||||
<file-input v-if="visibleCondition(f, 'file')" :label="f.label" :value="f.value" :field="f.field" @change="storeValue"/>
|
||||
<small-text v-if="visibleCondition(f, 'smalltext')" :value="f.value"/>
|
||||
<date-input v-if="visibleCondition(f, 'date')" :label="f.label" :value="f.value" :field="f.field" :help="showHelp && f.help" :subtitle="f.subtitle"/>
|
||||
<number-input v-if="visibleCondition(f, 'number')" :label="f.label" :value="f.value" :field="f.field" :placeholder="f.placeholder" :help="showHelp && f.help" :subtitle="f.subtitle"/>
|
||||
<text-input v-if="visibleCondition(f, 'text')" :label="f.label" :value="f.value" :field="f.field" :placeholder="f.placeholder" :help="showHelp && f.help" :subtitle="f.subtitle" :disabled="f.disabled" :optional="f.optional"/>
|
||||
<text-area-input v-if="visibleCondition(f, 'textarea')" :label="f.label" :value="f.value" :field="f.field" :placeholder="f.placeholder" :help="showHelp && f.help" :subtitle="f.subtitle" :disabled="f.disabled" :optional="f.optional"/>
|
||||
<choice-input v-if="visibleCondition(f, 'choice')" :label="f.label" :value="f.value" :field="f.field" :options="f.options" :placeholder="f.placeholder" :optional="f.optional"/>
|
||||
<emoji-input v-if="visibleCondition(f, 'emoji')" :label="f.label" :value="f.value" :field="f.field" @change="storeValue" :optional="f.optional"/>
|
||||
<file-input v-if="visibleCondition(f, 'file')" :label="f.label" :value="f.value" :field="f.field" @change="storeValue" :optional="f.optional"/>
|
||||
<small-text v-if="visibleCondition(f, 'smalltext')" :value="f.value" />
|
||||
<date-input v-if="visibleCondition(f, 'date')" :label="f.label" :value="f.value" :field="f.field" :help="showHelp && f.help" :subtitle="f.subtitle" :optional="f.optional"/>
|
||||
<number-input v-if="visibleCondition(f, 'number')" :label="f.label" :value="f.value" :field="f.field" :placeholder="f.placeholder" :help="showHelp && f.help" :subtitle="f.subtitle" :optional="f.optional"/>
|
||||
</div>
|
||||
<template v-slot:modal-footer>
|
||||
<div class="row w-100">
|
||||
@ -57,6 +58,7 @@ import FileInput from "@/components/Modals/FileInput"
|
||||
import SmallText from "@/components/Modals/SmallText"
|
||||
import HelpBadge from "@/components/Badges/Help"
|
||||
import NumberInput from "@/components/Modals/NumberInput.vue";
|
||||
import TextAreaInput from "@/components/Modals/TextAreaInput.vue";
|
||||
|
||||
export default {
|
||||
name: "GenericModalForm",
|
||||
@ -70,7 +72,8 @@ export default {
|
||||
SmallText,
|
||||
HelpBadge,
|
||||
DateInput,
|
||||
NumberInput
|
||||
NumberInput,
|
||||
TextAreaInput
|
||||
},
|
||||
mixins: [ApiMixin, ToastMixin],
|
||||
props: {
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div>
|
||||
<b-form-group :class="class_list">
|
||||
<template #label v-if="show_label">
|
||||
{{ form.label }}
|
||||
{{ field_label }}
|
||||
</template>
|
||||
<generic-multiselect
|
||||
@change="new_value = $event.val"
|
||||
@ -27,11 +27,11 @@
|
||||
|
||||
<script>
|
||||
import GenericMultiselect from "@/components/GenericMultiselect"
|
||||
import { StandardToasts, ApiMixin } from "@/utils/utils"
|
||||
import {StandardToasts, ApiMixin} from "@/utils/utils"
|
||||
|
||||
export default {
|
||||
name: "LookupInput",
|
||||
components: { GenericMultiselect },
|
||||
components: {GenericMultiselect},
|
||||
mixins: [ApiMixin],
|
||||
props: {
|
||||
form: {
|
||||
@ -46,11 +46,13 @@ export default {
|
||||
return undefined
|
||||
},
|
||||
},
|
||||
class_list: { type: String, default: "mb-3" },
|
||||
show_label: { type: Boolean, default: true },
|
||||
clear: { type: Number },
|
||||
help: { type: String, default: undefined },
|
||||
class_list: {type: String, default: "mb-3"},
|
||||
show_label: {type: Boolean, default: true},
|
||||
clear: {type: Number},
|
||||
help: {type: String, default: undefined},
|
||||
optional: {type: Boolean, default: false},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
new_value: undefined,
|
||||
@ -67,7 +69,7 @@ export default {
|
||||
this.label = this.form?.label ?? ""
|
||||
this.sticky_options = this.form?.sticky_options ?? []
|
||||
this.sticky_options = this.sticky_options.map((x) => {
|
||||
return { ...x, name: this.$t(x.name) }
|
||||
return {...x, name: this.$t(x.name)}
|
||||
})
|
||||
this.list_label = this.form?.list_label ?? undefined
|
||||
if (this.list_label?.includes("::")) {
|
||||
@ -75,6 +77,13 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
field_label: function () {
|
||||
if (this.optional) {
|
||||
return this.form.label
|
||||
} else {
|
||||
return this.form.label + '*'
|
||||
}
|
||||
},
|
||||
modelName() {
|
||||
return this.$t(this?.model?.name) ?? this.$t("Search")
|
||||
},
|
||||
@ -124,7 +133,7 @@ export default {
|
||||
let item = undefined
|
||||
let label = this.form.list_label.split("::")
|
||||
itemlist.forEach((x) => {
|
||||
item = { ...x }
|
||||
item = {...x}
|
||||
for (const [k, v] of Object.entries(x)) {
|
||||
if (k == label[0]) {
|
||||
item["id"] = v.id
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<b-form-group v-bind:label="label" class="mb-3">
|
||||
<b-form-group v-bind:label="field_label" class="mb-3">
|
||||
<b-form-input v-model="new_value" type="number" :placeholder="placeholder"></b-form-input>
|
||||
<em v-if="help" class="small text-muted">{{ help }}</em>
|
||||
<small v-if="subtitle" class="text-muted">{{ subtitle }}</small>
|
||||
@ -18,6 +18,16 @@ export default {
|
||||
placeholder: { type: Number, default: 0 },
|
||||
help: { type: String, default: undefined },
|
||||
subtitle: { type: String, default: undefined },
|
||||
optional: {type: Boolean, default: false},
|
||||
},
|
||||
computed: {
|
||||
field_label: function () {
|
||||
if (this.optional) {
|
||||
return this.label
|
||||
} else {
|
||||
return this.label + '*'
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
48
vue/src/components/Modals/TextAreaInput.vue
Normal file
48
vue/src/components/Modals/TextAreaInput.vue
Normal file
@ -0,0 +1,48 @@
|
||||
<template>
|
||||
<div>
|
||||
<b-form-group v-bind:label="field_label" class="mb-3">
|
||||
<b-form-textarea v-model="new_value" type="text" :placeholder="placeholder" :disabled="disabled"></b-form-textarea>
|
||||
<em v-if="help" class="small text-muted">{{ help }}</em>
|
||||
<small v-if="subtitle" class="text-muted">{{ subtitle }}</small>
|
||||
</b-form-group>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "TextAreaInput",
|
||||
props: {
|
||||
field: {type: String, default: "You Forgot To Set Field Name"},
|
||||
label: {type: String, default: "Text Field"},
|
||||
value: {type: String, default: ""},
|
||||
placeholder: {type: String, default: "You Should Add Placeholder Text"},
|
||||
help: {type: String, default: undefined},
|
||||
subtitle: {type: String, default: undefined},
|
||||
disabled: {type: Boolean, default: false},
|
||||
optional: {type: Boolean, default: false},
|
||||
},
|
||||
computed: {
|
||||
field_label: function () {
|
||||
if (this.optional) {
|
||||
return this.label
|
||||
} else {
|
||||
return this.label + '*'
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
new_value: undefined,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.new_value = this.value
|
||||
},
|
||||
watch: {
|
||||
new_value: function () {
|
||||
this.$root.$emit("change", this.field, this.new_value)
|
||||
},
|
||||
},
|
||||
methods: {},
|
||||
}
|
||||
</script>
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<b-form-group v-bind:label="label" class="mb-3">
|
||||
<b-form-group v-bind:label="field_label" class="mb-3">
|
||||
<b-form-input v-model="new_value" type="text" :placeholder="placeholder" :disabled="disabled"></b-form-input>
|
||||
<em v-if="help" class="small text-muted">{{ help }}</em>
|
||||
<small v-if="subtitle" class="text-muted">{{ subtitle }}</small>
|
||||
@ -18,13 +18,23 @@ export default {
|
||||
placeholder: { type: String, default: "You Should Add Placeholder Text" },
|
||||
help: { type: String, default: undefined },
|
||||
subtitle: { type: String, default: undefined },
|
||||
disabled: { type: Boolean, default: false }
|
||||
disabled: { type: Boolean, default: false },
|
||||
optional: {type: Boolean, default: false},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
new_value: undefined,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
field_label: function () {
|
||||
if (this.optional) {
|
||||
return this.label
|
||||
} else {
|
||||
return this.label + '*'
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.new_value = this.value
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user