Merge pull request #861 from smilerz/food_tree_patch
post food_tree bug fixing
This commit is contained in:
@ -356,7 +356,7 @@ export default {
|
||||
|
||||
this.loadMealPlan()
|
||||
// this.loadRecentlyViewed()
|
||||
// this.refreshData(false) // this gets triggered when the cookies get loaded
|
||||
this.refreshData(false)
|
||||
})
|
||||
|
||||
this.$i18n.locale = window.CUSTOM_LOCALE
|
||||
|
@ -4,12 +4,14 @@
|
||||
:options="objects"
|
||||
:close-on-select="true"
|
||||
:clear-on-select="true"
|
||||
:hide-selected="true"
|
||||
:hide-selected="multiple"
|
||||
:preserve-search="true"
|
||||
:placeholder="lookupPlaceholder"
|
||||
:label="label"
|
||||
track-by="id"
|
||||
:multiple="multiple"
|
||||
:taggable="create_new"
|
||||
:tag-placeholder="createText"
|
||||
:loading="loading"
|
||||
@search-change="search"
|
||||
@input="selectionChanged">
|
||||
@ -41,7 +43,9 @@ export default {
|
||||
limit: {type: Number, default: 10,},
|
||||
sticky_options: {type:Array, default(){return []}},
|
||||
initial_selection: {type:Array, default(){return []}},
|
||||
multiple: {type: Boolean, default: true}
|
||||
multiple: {type: Boolean, default: true},
|
||||
create_new: {type: Boolean, default: false}, // TODO: this will create option to add new drop-downs
|
||||
create_text: {type: String, default: 'You Forgot to Add a Tag Placeholder'},
|
||||
},
|
||||
watch: {
|
||||
initial_selection: function (newVal, oldVal) { // watch it
|
||||
@ -64,6 +68,9 @@ export default {
|
||||
lookupPlaceholder() {
|
||||
return this.placeholder || this.model.name || this.$t('Search')
|
||||
},
|
||||
createText() {
|
||||
return this.create_text
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// this.genericAPI inherited from ApiMixin
|
||||
|
@ -4,6 +4,7 @@
|
||||
<template v-slot:modal-title><h4>{{form.title}}</h4></template>
|
||||
<div v-for="(f, i) in form.fields" v-bind:key=i>
|
||||
<p v-if="f.type=='instruction'">{{f.label}}</p>
|
||||
<!-- this lookup is single selection -->
|
||||
<lookup-input v-if="f.type=='lookup'"
|
||||
:label="f.label"
|
||||
:value="f.value"
|
||||
@ -12,6 +13,7 @@
|
||||
:sticky_options="f.sticky_options || undefined"
|
||||
@change="storeValue"/> <!-- TODO add ability to create new items associated with lookup -->
|
||||
<!-- TODO: add emoji field -->
|
||||
<!-- TODO: add multi-selection input list -->
|
||||
<checkbox-input v-if="f.type=='checkbox'"
|
||||
:label="f.label"
|
||||
:value="f.value"
|
||||
|
@ -3,15 +3,15 @@
|
||||
<b-form-group
|
||||
v-bind:label="label"
|
||||
class="mb-3">
|
||||
<generic-multiselect
|
||||
@change="new_value=$event.val['id']"
|
||||
:initial_selection="[]"
|
||||
:model="model"
|
||||
:multiple="false"
|
||||
:sticky_options="sticky_options"
|
||||
style="flex-grow: 1; flex-shrink: 1; flex-basis: 0"
|
||||
:placeholder="modelName">
|
||||
</generic-multiselect>
|
||||
<generic-multiselect
|
||||
@change="new_value=$event.val"
|
||||
:initial_selection="[value]"
|
||||
:model="model"
|
||||
:multiple="false"
|
||||
:sticky_options="sticky_options"
|
||||
style="flex-grow: 1; flex-shrink: 1; flex-basis: 0"
|
||||
:placeholder="modelName">
|
||||
</generic-multiselect>
|
||||
</b-form-group>
|
||||
</div>
|
||||
</template>
|
||||
@ -28,15 +28,15 @@ export default {
|
||||
value: {type: Object, default () {return {}}},
|
||||
model: {type: Object, default () {return {}}},
|
||||
sticky_options: {type:Array, default(){return []}},
|
||||
// TODO: include create_new and create_text props and associated functionality to create objects for drop down
|
||||
// see 'tagging' here: https://vue-multiselect.js.org/#sub-tagging
|
||||
// perfect world would have it trigger a new modal associated with the associated item model
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
new_value: undefined,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.new_value = this.value.id
|
||||
},
|
||||
computed: {
|
||||
modelName() {
|
||||
return this?.model?.name ?? this.$t('Search')
|
||||
@ -44,7 +44,7 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
'new_value': function () {
|
||||
this.$root.$emit('change', this.field, this.new_value)
|
||||
this.$root.$emit('change', this.field, this.new_value?.id ?? null)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
@ -99,7 +99,7 @@ export class Models {
|
||||
'type': 'lookup',
|
||||
'field': 'supermarket_category',
|
||||
'list': 'SHOPPING_CATEGORY',
|
||||
'label': i18n.t('Shopping_Category')
|
||||
'label': i18n.t('Shopping_Category'),
|
||||
},
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user