Skip to content
Closed
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion src/components/PurchaseOrderDetail.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div v-for="(poItems, index) in itemsByPoId" :key="index">
<div v-if="!itemsByPoId || Object.keys(itemsByPoId).length === 0" class="empty-state ion-margin-top">
{{ translate("No purchase orders found") }}
</div>
<div v-else v-for="(poItems, index) in itemsByPoId" :key="index">
<ion-item lines="none">
<h3>{{ index }}</h3>
</ion-item>
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
"No logs found": "No logs found",
"No product found": "No product found",
"No products found": "No products found",
"No purchase orders found": "No purchase orders found",
"No results found": "No results found",
"No time zone found": "No time zone found",
"No shop selected": "No shop selected",
Expand Down
15 changes: 10 additions & 5 deletions src/views/PurchaseOrder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,23 @@ export default defineComponent({
ionViewDidEnter() {
this.file = {}
this.content = []
this.selectedMappingId = ""
this.fieldMapping = Object.keys(this.fields).reduce((fieldMapping, field) => {
fieldMapping[field] = ""
return fieldMapping;
}, {})
this.resetMappingState();
this.$refs.file.value = null;
},
methods: {
resetMappingState() {
this.selectedMappingId = "";
this.fieldMapping = Object.keys(this.fields).reduce((map, field) => {
map[field] = "";
return map;
}, {});
},
async parse(event) {
const file = event.target.files[0];
try {
if (file) {
this.file = file;
this.resetMappingState();
this.content = await this.parseCsv(this.file);
this.fileColumns = Object.keys(this.content[0]);
showToast(translate("File uploaded successfully"));
Expand All @@ -121,6 +125,7 @@ export default defineComponent({
}
} catch {
this.content = []
this.selectedMappingId = "";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For consistency, it would be better to call this.resetMappingState() here instead of just resetting this.selectedMappingId. The new resetMappingState method handles resetting both selectedMappingId and fieldMapping, which is appropriate for a parsing error scenario.

          this.resetMappingState();

showToast(translate("Please upload a valid purchase order csv to continue"));
}
},
Expand Down
Loading