editpane before drag and drop

This commit is contained in:
Thomas Mack 2022-04-14 15:18:49 +02:00
parent ebc08ce2d6
commit ba8b8b94cf
5 changed files with 82 additions and 20 deletions

View File

@ -175,6 +175,17 @@ export default class App extends Vue {}
.billi-label { .billi-label {
font-weight: bold; font-weight: bold;
} }
.billi-value {
padding-top: 0.5rem;
justify-self: stretch;
font-weight: bold;
}
.billi-value input,
.billi-value select{
width: 100%
}
</style> </style>

View File

@ -20,7 +20,7 @@
<button @click="toggleEdit">Bearbeiten</button> <button @click="toggleEdit">Bearbeiten</button>
<InventoryItemHead :item="item"></InventoryItemHead> <InventoryItemHead :item="item"></InventoryItemHead>
<CameraTechnicalDetail :item="item"></CameraTechnicalDetail> <CameraTechnicalDetail :item="item"></CameraTechnicalDetail>
<InventoryItemCollectionInfo :globalEdit="globalEdit" :item="item"></InventoryItemCollectionInfo> <InventoryItemCollectionInfo :globalEdit="globalEdit" :item="item" @changedInput="handleChangeEvent"></InventoryItemCollectionInfo>
<InventoryItemDescription :globalEdit="globalEdit" :item="item" @changedDescription="handleChangeEvent"></InventoryItemDescription> <InventoryItemDescription :globalEdit="globalEdit" :item="item" @changedDescription="handleChangeEvent"></InventoryItemDescription>
</section> </section>
</article> </article>
@ -71,7 +71,8 @@ export default {
}, },
handleChangeEvent(value) { handleChangeEvent(value) {
console.log("handleChangedDescription" , value) console.log("handleChangedDescription" , value)
this.newCamera[value.field] = value.value.trim(); if(typeof value.value =="string") this.newCamera[value.field] = value.value.trim();
else this.newCamera[value.field] = value.value
console.log("newCamera", this.newCamera); console.log("newCamera", this.newCamera);
} }

View File

@ -64,7 +64,7 @@
<div class="billi-label"> <div class="billi-label">
Teil des Sets Teil des Sets
</div> </div>
<div class="billi-value"> <div class="billi-value form-group">
{{ set(item.set_key).name }} {{ set(item.set_key).name }}
</div> </div>
</div> </div>
@ -72,8 +72,11 @@
<div class="billi-label"> <div class="billi-label">
Jahr des Kaufs Jahr des Kaufs
</div> </div>
<div class="billi-value"> <div class="billi-value form-group">
<input name="year_of_purchase" id="year_of_purchase" v-model="newItem.year_of_purchase" type="number"/> <input name="year_of_purchase" id="year_of_purchase"
v-model="newItem.year_of_purchase"
@change="changeHandler('year_of_purchase')"
type="number"/>
</div> </div>
</div> </div>
<div v-if="item.condition_key" class="billi-row-50-50"> <div v-if="item.condition_key" class="billi-row-50-50">
@ -81,15 +84,25 @@
Zustand Zustand
</div> </div>
<div class="billi-value"> <div class="billi-value">
{{ condition(item.condition_key).name }} <select v-model="newItem.condition_key" >
<option
v-for="condition in conditions"
:value="condition.key"
:key="condition.key"
@change="changeHandler('condition_key')"
>{{condition.name}}</option>
</select>
</div> </div>
</div> </div>
<div class="billi-row-50-50"> <div class="billi-row-50-50">
<div class="billi-label"> <div class="billi-label">
Kaufpreis Kaufpreis
</div> </div>
<div class="billi-value"> <div class="billi-value form-group">
<input name="price_purchased" id="price_purchased" v-model="newItem.price_purchased" type="money"/> <input name="price_purchased" id="price_purchased"
v-model="newItem.price_purchased"
@change="changeHandler('price_purchased')"
type="number"/>
</div> </div>
</div> </div>
<div class="billi-row-50-50"> <div class="billi-row-50-50">
@ -97,7 +110,10 @@
Zeitwert Zeitwert
</div> </div>
<div class="billi-value"> <div class="billi-value">
<input name="price_current" id="price_current" v-model="newItem.price_current" type="money"/> <input name="price_current" id="price_current"
v-model="newItem.price_current"
@change="changeHandler('price_current')"
type="number"/>
</div> </div>
</div> </div>
@ -106,7 +122,10 @@
hist. Kaufpreis hist. Kaufpreis
</div> </div>
<div class="billi-value"> <div class="billi-value">
<input name="price_historic" id="price_historic" v-model="newItem.price_historic" type="money"/> <input name="price_historic" id="price_historic"
v-model="newItem.price_historic"
@change="changeHandler('price_historic')"
type="number"/>
</div> </div>
</div> </div>
@ -134,8 +153,15 @@ export default {
default: false default: false
} }
}, },
emits: {
changedInput: (payload) => {
if(payload.field && payload.value) return true;
else return false;
}
},
data() { data() {
return { return {
edit: false,
newItem: { newItem: {
year_of_purchase: this.item.year_of_purchase, year_of_purchase: this.item.year_of_purchase,
price_current: this.item.price_current, price_current: this.item.price_current,
@ -147,7 +173,7 @@ export default {
}, },
computed: { computed: {
...mapGetters(["condition", "set"]), ...mapGetters(["condition", "conditions", "set"]),
getIconName() { getIconName() {
if (!this.edit) return "pen" if (!this.edit) return "pen"
else return "floppy-disk" else return "floppy-disk"
@ -156,6 +182,30 @@ export default {
return this.edit || this.globalEdit; return this.edit || this.globalEdit;
}, },
}, },
methods: {
toggleEdit() {
this.edit = !this.edit;
if(this.edit) {
this.newItem.key = this.item.key;
this.newItem.description = this.item.description;
this.newItem.work_done = this.item.work_done;
} else {
if(this.newItem.description.trim() != this.item.description) {
this.$store.dispatch("storeInventoryDescription", {
key: this.newItem.key,
description: this.newItem.description.trim()
});
}
}
},
changeHandler(field) {
console.log("changeHanlder", field);
this.$emit("changedInput", {field:field, value: this.newItem[field]});
}
}
} }
</script> </script>

View File

@ -39,18 +39,18 @@ export default {
type: InventoryItem, type: InventoryItem,
required: true required: true
}, },
emits: {
changedDescription: (payload) => {
if(payload.field && payload.value) return true;
else return false;
}
},
globalEdit: { globalEdit: {
type: Boolean, type: Boolean,
required: false, required: false,
default: false default: false
} }
}, },
emits: {
changedDescription: (payload) => {
if(payload.field && payload.value) return true;
else return false;
}
},
data() { data() {
return { return {
edit: false, edit: false,

View File

@ -179,15 +179,15 @@ export default class InventoryItem {
} }
set price_purchased(value: number) { set price_purchased(value: number) {
this._price_purchased = value; this._price_purchased = Number(value);
} }
set price_historic(value: number) { set price_historic(value: number) {
this._price_historic = value; this._price_historic = Number(value);
} }
set price_current(value: number) { set price_current(value: number) {
this._price_current = value; this._price_current = Number(value);
} }
set year_of_production(value: number) { set year_of_production(value: number) {