fix container selection in AddItemModal.vue
This commit is contained in:
parent
f7fda52fd0
commit
9141752fdf
6 changed files with 48 additions and 73 deletions
|
@ -2,7 +2,29 @@
|
||||||
<div>
|
<div>
|
||||||
<Modal v-if="isModal" title="Add Item" @close="$emit('close')">
|
<Modal v-if="isModal" title="Add Item" @close="$emit('close')">
|
||||||
<template #body>
|
<template #body>
|
||||||
<EditItem :item="item"/>
|
<div>
|
||||||
|
<InputPhoto
|
||||||
|
:model="item"
|
||||||
|
field="file"
|
||||||
|
:on-capture="storeImage"
|
||||||
|
/>
|
||||||
|
<InputString
|
||||||
|
label="description"
|
||||||
|
:model="item"
|
||||||
|
field="description"
|
||||||
|
:validation-fn="str => str && str.length > 0"
|
||||||
|
/>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="box">box</label>
|
||||||
|
<InputCombo
|
||||||
|
label="box"
|
||||||
|
:model="item"
|
||||||
|
nameKey="box"
|
||||||
|
uniqueKey="cid"
|
||||||
|
:options="boxes"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #buttons>
|
<template #buttons>
|
||||||
<button type="button" class="btn btn-secondary" @click="$emit('close')">Cancel</button>
|
<button type="button" class="btn btn-secondary" @click="$emit('close')">Cancel</button>
|
||||||
|
@ -13,33 +35,40 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {mapActions, mapGetters, mapState} from "vuex";
|
||||||
import Modal from '@/components/Modal';
|
import Modal from '@/components/Modal';
|
||||||
import EditItem from '@/components/EditItem';
|
import InputCombo from "@/components/inputs/InputCombo.vue";
|
||||||
import {mapActions, mapState} from "vuex";
|
import InputPhoto from "@/components/inputs/InputPhoto.vue";
|
||||||
|
import InputString from "@/components/inputs/InputString.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AddItemModal',
|
name: 'AddItemModal',
|
||||||
components: {Modal, EditItem},
|
components: {InputString, InputPhoto, InputCombo, Modal},
|
||||||
props: ['isModal'],
|
props: ['isModal'],
|
||||||
data: () => ({
|
data: () => ({
|
||||||
item: {}
|
item: {}
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['lastUsed'])
|
...mapState(['lastUsed']),
|
||||||
|
...mapGetters(['getBoxes']),
|
||||||
|
boxes({getBoxes}) {
|
||||||
|
return getBoxes.map(obj => ({cid: obj.id, box: obj.name}));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['postItem', 'loadBoxes', 'scheduleAfterInit']),
|
...mapActions(['postItem', 'loadBoxes', 'scheduleAfterInit']),
|
||||||
saveNewItem() {
|
async saveNewItem() {
|
||||||
this.postItem(this.item).then(() => {
|
await this.postItem(this.item);
|
||||||
this.$emit('close');
|
this.$emit('close');
|
||||||
});
|
},
|
||||||
|
storeImage(image) {
|
||||||
|
this.item.dataImage = image;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
|
||||||
this.item = {box: this.lastUsed.box || '', cid: this.lastUsed.cid || ''};
|
|
||||||
},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.scheduleAfterInit(() => [this.loadBoxes()]);
|
this.scheduleAfterInit(() => [this.loadBoxes().then(() => {
|
||||||
|
this.item = {box: this.lastUsed.box || '', cid: this.lastUsed.cid || ''};
|
||||||
|
})])
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -19,11 +19,10 @@
|
||||||
<script>
|
<script>
|
||||||
import {mapActions} from 'vuex';
|
import {mapActions} from 'vuex';
|
||||||
import Modal from '@/components/Modal';
|
import Modal from '@/components/Modal';
|
||||||
import EditItem from '@/components/EditItem';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AddTicketModal',
|
name: 'AddTicketModal',
|
||||||
components: {Modal, EditItem},
|
components: {Modal},
|
||||||
props: ['isModal'],
|
props: ['isModal'],
|
||||||
data: () => ({
|
data: () => ({
|
||||||
ticket: {
|
ticket: {
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<h6>Editing Item <span class="badge badge-secondary">#{{ item.uid }}</span></h6>
|
|
||||||
<InputPhoto
|
|
||||||
:model="item"
|
|
||||||
field="file"
|
|
||||||
:on-capture="storeImage"
|
|
||||||
/>
|
|
||||||
<InputString
|
|
||||||
label="description"
|
|
||||||
:model="item"
|
|
||||||
field="description"
|
|
||||||
:validation-fn="str => str && str.length > 0"
|
|
||||||
/>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="box">box</label>
|
|
||||||
<InputCombo
|
|
||||||
label="box"
|
|
||||||
:model="item"
|
|
||||||
nameKey="box"
|
|
||||||
uniqueKey="cid"
|
|
||||||
:options="boxes"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import InputString from './inputs/InputString';
|
|
||||||
import InputCombo from './inputs/InputCombo';
|
|
||||||
import {mapGetters} from 'vuex';
|
|
||||||
import InputPhoto from './inputs/InputPhoto';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'EditItem',
|
|
||||||
components: {InputPhoto, InputCombo, InputString},
|
|
||||||
props: ['item'],
|
|
||||||
computed: {
|
|
||||||
...mapGetters(['getBoxes']),
|
|
||||||
boxes({getBoxes}) {
|
|
||||||
return getBoxes.map(obj => ({cid: obj.cid, box: obj.name}));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
storeImage(image) {
|
|
||||||
this.item.dataImage = image;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
|
@ -43,11 +43,11 @@ export default {
|
||||||
props: ['label', 'model', 'nameKey', 'uniqueKey', 'options', 'onOptionAdd'],
|
props: ['label', 'model', 'nameKey', 'uniqueKey', 'options', 'onOptionAdd'],
|
||||||
data: ({options, model, nameKey, uniqueKey}) => ({
|
data: ({options, model, nameKey, uniqueKey}) => ({
|
||||||
internalName: model[nameKey],
|
internalName: model[nameKey],
|
||||||
selectedOption: options.filter(e => e[uniqueKey] == model[uniqueKey])[0],
|
selectedOption: options.filter(e => e[uniqueKey] === model[uniqueKey])[0],
|
||||||
addingOption: false
|
addingOption: false
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
isValid: ({options, nameKey, internalName}) => options.some(e => e[nameKey] == internalName),
|
isValid: ({options, nameKey, internalName}) => options.some(e => e[nameKey] === internalName),
|
||||||
sortedOptions: ({
|
sortedOptions: ({
|
||||||
options,
|
options,
|
||||||
nameKey
|
nameKey
|
||||||
|
@ -56,7 +56,7 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
internalName(newValue) {
|
internalName(newValue) {
|
||||||
if (this.isValid) {
|
if (this.isValid) {
|
||||||
if (!this.selectedOption || newValue != this.selectedOption[this.nameKey]) {
|
if (!this.selectedOption || newValue !== this.selectedOption[this.nameKey]) {
|
||||||
this.selectedOption = this.options.filter(e => e[this.nameKey] === newValue)[0];
|
this.selectedOption = this.options.filter(e => e[this.nameKey] === newValue)[0];
|
||||||
}
|
}
|
||||||
this.model[this.nameKey] = this.selectedOption[this.nameKey];
|
this.model[this.nameKey] = this.selectedOption[this.nameKey];
|
||||||
|
|
|
@ -112,14 +112,12 @@ import InputString from "@/components/inputs/InputString.vue";
|
||||||
import AuthenticatedImage from "@/components/AuthenticatedImage.vue";
|
import AuthenticatedImage from "@/components/AuthenticatedImage.vue";
|
||||||
import InputPhoto from "@/components/inputs/InputPhoto.vue";
|
import InputPhoto from "@/components/inputs/InputPhoto.vue";
|
||||||
import Modal from "@/components/Modal.vue";
|
import Modal from "@/components/Modal.vue";
|
||||||
import EditItem from "@/components/EditItem.vue";
|
|
||||||
import AsyncButton from "@/components/inputs/AsyncButton.vue";
|
import AsyncButton from "@/components/inputs/AsyncButton.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Item',
|
name: 'Item',
|
||||||
components: {
|
components: {
|
||||||
AsyncButton,
|
AsyncButton,
|
||||||
EditItem,
|
|
||||||
Modal, InputPhoto, AuthenticatedImage, InputString, InputCombo, AsyncLoader, ClipboardButton, Timeline
|
Modal, InputPhoto, AuthenticatedImage, InputString, InputCombo, AsyncLoader, ClipboardButton, Timeline
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
|
@ -67,11 +67,10 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {mapActions, mapGetters, mapMutations} from 'vuex';
|
||||||
import Table from '@/components/Table';
|
import Table from '@/components/Table';
|
||||||
import Cards from '@/components/Cards';
|
import Cards from '@/components/Cards';
|
||||||
import Modal from '@/components/Modal';
|
import Modal from '@/components/Modal';
|
||||||
import EditItem from '@/components/EditItem';
|
|
||||||
import {mapActions, mapGetters, mapMutations} from 'vuex';
|
|
||||||
import AuthenticatedImage from "@/components/AuthenticatedImage.vue";
|
import AuthenticatedImage from "@/components/AuthenticatedImage.vue";
|
||||||
import AsyncLoader from "@/components/AsyncLoader.vue";
|
import AsyncLoader from "@/components/AsyncLoader.vue";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
|
@ -82,7 +81,7 @@ export default {
|
||||||
lightboxHash: null,
|
lightboxHash: null,
|
||||||
editingItem: null,
|
editingItem: null,
|
||||||
}),
|
}),
|
||||||
components: {AsyncLoader, AuthenticatedImage, Table, Cards, Modal, EditItem},
|
components: {AsyncLoader, AuthenticatedImage, Table, Cards, Modal},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(['getEventItems', 'isItemsLoaded', 'layout']),
|
...mapGetters(['getEventItems', 'isItemsLoaded', 'layout']),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue