Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed the id and added conditions for rendering the detailed page i… #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 12 additions & 27 deletions receipt-web/src/components/pages/ReceiptPage/index.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
<template>
<div class="container">
<div class="row">
<div class="row" v-if="notFound">
<div class="col-12 col-sm-8">
<form class="form-inline" v-on:submit.prevent>
<label class="sr-only" for="ReceiptPageReceiptIdInput">Name</label>
<input type="text"
class="form-control mb-2 mr-sm-2"
id="ReceiptPageReceiptIdInput"
v-model="receiptId"
placeholder="Receipt ID">
</form>
</div>
</div>
<div class="row">
<div class="col-12 col-sm-8">
<p v-if="notFound">
<p>
Receipt #{{receiptId}} was not found
</p>
</div>
</div>
<div class="row">
<div class="row" v-else>
<div class="col-12">
<receipt-items v-bind:items="items"/>
<receipt-items :items="items"/>
<div style="margin-bottom: 20px"></div>
<receipt-meta v-bind:meta="meta"/>
<receipt-meta :meta="meta"/>
</div>
</div>
</div>
Expand All @@ -37,14 +25,14 @@
export default {
name: "ReceiptPage",
props: ["receiptId"],
data: function () {
data() {
return {
items: [],
meta: {}
}
},
computed: {
notFound: function () {
notFound() {
return this.receiptId && Object.keys(this.meta).length === 0;
}
},
Expand All @@ -53,17 +41,16 @@
ReceiptMeta
},
watch: {
receiptId: function (newValue, oldValue) {
receiptId(newValue, oldValue) {
if (newValue && newValue !== oldValue) {
this.$router.replace(`/receipt/${newValue}`);
this.reloadReceipt();
}
}
Comment on lines +44 to 49
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ты удалил форму которая пользовалась этим свойством

},
methods: {
reloadReceipt: function () {
axios
.put("/api/receipts", {ids: [this.receiptId]})
reloadReceipt() {
axios.put("/api/receipts", {ids: [this.receiptId]})
.then(result => {
let data = result.data;
if (data.length > 0) {
Expand All @@ -73,16 +60,14 @@
}
});

axios
.put("/api/items", {receiptIds: [this.receiptId]})
axios.put("/api/items", {receiptIds: [this.receiptId]})
.then(result => {
this.items = result.data;
});
}
},
created: function () {
created() {
this.reloadReceipt();
}
}
</script>