-
Notifications
You must be signed in to change notification settings - Fork 34
Fixed : added empty states and reset mapping chip after file is re-uploaded (#307) #355
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,6 +113,11 @@ export default defineComponent({ | |
| try { | ||
| if (file) { | ||
| this.file = file; | ||
| this.selectedMappingId = ""; | ||
| this.fieldMapping = Object.keys(this.fields).reduce((map, field) => { | ||
| map[field] = ""; | ||
| return map; | ||
| }, {}); | ||
| this.content = await this.parseCsv(this.file); | ||
| this.fileColumns = Object.keys(this.content[0]); | ||
| showToast(translate("File uploaded successfully")); | ||
|
|
@@ -121,6 +126,7 @@ export default defineComponent({ | |
| } | ||
| } catch { | ||
| this.content = [] | ||
| this.selectedMappingId = ""; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case of an error during file parsing, it's good practice to reset the entire mapping state for consistency, not just |
||
| showToast(translate("Please upload a valid purchase order csv to continue")); | ||
| } | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic to reset the mapping state is also present in the
ionViewDidEnterlifecycle hook (lines 103-107). To improve maintainability and adhere to the Don't Repeat Yourself (DRY) principle, consider extracting this block of code into a separate method and calling it from bothparseandionViewDidEnter.For example, you could create a
resetMappingStatemethod:Then you can simply call
this.resetMappingState();here and in other places where this logic is needed, like thecatchblock.