Fix item input
yeah
This commit is contained in:
@@ -35,15 +35,68 @@
|
|||||||
<!-- input field -->
|
<!-- input field -->
|
||||||
|
|
||||||
<div class="field-header-box">
|
<div class="field-header-box">
|
||||||
<div class="inputField-header">
|
<!-- <div class="inputField-header">-->
|
||||||
<input class="newItemName" id="inputTextField" autofocus autocomplete="off" placeholder="Add here..." v-model="newItem"
|
<!-- <input class="newItemName" id="inputTextField" autofocus autocomplete="off" placeholder="Add here..." v-model="newItem"-->
|
||||||
@keyup.enter="addItem"/>
|
<!-- @keyup.enter="addItem"/>-->
|
||||||
<label for="inputTextField" class="formLabel">
|
<!-- <label for="inputTextField" class="formLabel">-->
|
||||||
Add here ...
|
<!-- Add here ...-->
|
||||||
</label>
|
<!-- </label>-->
|
||||||
</div>
|
<v-row>
|
||||||
|
<v-col cols="3">
|
||||||
|
<v-text-field
|
||||||
|
label="Ingredient"
|
||||||
|
value=""
|
||||||
|
v-model="newItem"
|
||||||
|
@keyup.enter="addItem"
|
||||||
|
required
|
||||||
|
></v-text-field>
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="2">
|
||||||
|
<v-text-field
|
||||||
|
label="Quantity"
|
||||||
|
required
|
||||||
|
v-model="newQuantity"
|
||||||
|
@keyup.enter="addItem"
|
||||||
|
></v-text-field>
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="1">
|
||||||
|
<p>Unit</p>
|
||||||
|
|
||||||
|
<v-btn-toggle
|
||||||
|
v-model="newUnit"
|
||||||
|
tile
|
||||||
|
color="deep-purple accent-3"
|
||||||
|
group
|
||||||
|
mandatory
|
||||||
|
|
||||||
|
>
|
||||||
|
<v-btn value="units">
|
||||||
|
units
|
||||||
|
</v-btn>
|
||||||
|
|
||||||
|
<v-btn value="g">
|
||||||
|
g
|
||||||
|
</v-btn>
|
||||||
|
|
||||||
|
<v-btn value="ml">
|
||||||
|
ml
|
||||||
|
</v-btn>
|
||||||
|
|
||||||
|
</v-btn-toggle>
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="1">
|
||||||
|
<!-- <v-btn-->
|
||||||
|
<!-- elevation="2"-->
|
||||||
|
<!-- fab-->
|
||||||
|
<!-- @click="addItem"-->
|
||||||
|
<!-- ><v-icon>mdi-plus</v-icon>-->
|
||||||
|
<!-- </v-btn>-->
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- response element -->
|
<!-- response element -->
|
||||||
|
|
||||||
<div class="item-section" v-show="items.length" v-cloak>
|
<div class="item-section" v-show="items.length" v-cloak>
|
||||||
@@ -87,6 +140,8 @@ const Items = {
|
|||||||
return {
|
return {
|
||||||
items: [],
|
items: [],
|
||||||
newItem: '',
|
newItem: '',
|
||||||
|
newQuantity: 0,
|
||||||
|
newUnit: '',
|
||||||
editedItem: null,
|
editedItem: null,
|
||||||
loading: true,
|
loading: true,
|
||||||
error: null,
|
error: null,
|
||||||
@@ -112,29 +167,29 @@ const Items = {
|
|||||||
return this.activeUser ? this.activeUser.email : ''
|
return this.activeUser ? this.activeUser.email : ''
|
||||||
},
|
},
|
||||||
inputPlaceholder: function () {
|
inputPlaceholder: function () {
|
||||||
return this.activeUser ? this.activeUser.given_name + ', what do you want to add?' : 'What needs to be added'
|
return this.activeUser ? this.activeUser.given_name + ', What do you want to add?' : 'What needs to be added?'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
addItem: function () {
|
addItem: function () {
|
||||||
const value = this.newItem && this.newItem.trim();
|
const addableItem = this.newItem && this.newItem.trim();
|
||||||
if (!value) {
|
const addableQuantity = parseInt(this.newQuantity);
|
||||||
|
const addableUnit = this.newUnit;
|
||||||
|
if (!addableItem) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const components = value.split(' ');
|
api.createNew(addableItem,
|
||||||
|
addableQuantity,
|
||||||
api.createNew(components[0],
|
addableUnit
|
||||||
parseInt(components[1].replace(/[^\d.]/g, '')),
|
|
||||||
components[1].replace(/[0-9]/g, '') === 'ml' ? 'MILLILETERS' : "GRAMMS"
|
|
||||||
).then((response) => {
|
).then((response) => {
|
||||||
this.$log.debug("New item created:", response);
|
this.$log.debug("New item created:", response);
|
||||||
this.items.push({
|
this.items.push({
|
||||||
id: response.data.id,
|
id: response.data.id,
|
||||||
name: components[0],
|
name: addableItem,
|
||||||
quantity: parseInt(components[1].replace(/[^\d.]/g, '')),
|
quantity: addableQuantity,
|
||||||
unit: components[1].replace(/[0-9]/g, '') === 'MILLILETERS' ? 'ml' : 'g'
|
unit: addableUnit
|
||||||
})
|
})
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.$log.debug(error);
|
this.$log.debug(error);
|
||||||
@@ -167,10 +222,6 @@ export default Items
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
||||||
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200&display=swap');
|
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200&display=swap');
|
||||||
@@ -225,23 +276,23 @@ body{
|
|||||||
|
|
||||||
/* input field styling */
|
/* input field styling */
|
||||||
|
|
||||||
.field-header-box{
|
//.field-header-box{
|
||||||
z-index: 3;
|
// z-index: 3;
|
||||||
position: fixed;
|
// position: center;
|
||||||
width: 100vw;
|
// width: 200vw;
|
||||||
height: 5vh;
|
// height: 5vh;
|
||||||
left: 0;
|
// left: 0;
|
||||||
top: 10vh;
|
// top: 10vh;
|
||||||
display: grid;
|
// display: grid;
|
||||||
align-content: center;
|
// align-content: center;
|
||||||
justify-content: center;
|
// justify-content: center;
|
||||||
}
|
//}
|
||||||
|
|
||||||
.inputField-header {
|
.inputField-header {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 5;
|
z-index: 5;
|
||||||
width: 20vh;
|
width: 20vh;
|
||||||
height: 3vh;
|
height: 2vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.newItemName {
|
.newItemName {
|
||||||
|
|||||||
Reference in New Issue
Block a user