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

Improved: column labels for import functionality and removed some unused imports #157

Merged
merged 5 commits into from
Jun 22, 2023
Merged
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
1 change: 0 additions & 1 deletion src/components/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
} from "@ionic/vue";
import { defineComponent, ref } from "vue";
import { mapGetters } from "vuex";

import { mailUnreadOutline, mailOpenOutline, checkmarkDoneOutline, settingsOutline, swapVerticalOutline } from "ionicons/icons";
import { useStore } from "@/store";

Expand Down
40 changes: 15 additions & 25 deletions src/views/UploadImportOrders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import { useStore } from "vuex";
import { defineComponent } from 'vue';
import { useRouter } from 'vue-router';
import { IonPage, IonSelect, IonSelectOption, IonHeader, IonList, IonListHeader, IonToolbar, IonBackButton, IonTitle, IonContent, IonItem, IonLabel, IonButton, alertController } from '@ionic/vue'
import { ellipsisVerticalOutline, businessOutline, shirtOutline, sendOutline, checkboxOutline, calculatorOutline, cloudUploadOutline, arrowUndoOutline, chevronForwardOutline, timeOutline } from 'ionicons/icons'
import { parseCsv, showToast } from '@/utils';
import { translate } from "@/i18n";
import { UploadService } from "@/services/UploadService"
Expand Down Expand Up @@ -77,17 +75,23 @@ export default defineComponent({
ionViewDidEnter() {
this.file = {}
this.content = []
this.fieldMapping = Object.keys(this.fields).reduce((fieldMapping: any, field: string) => {
fieldMapping[field] = ""
return fieldMapping;
}, {})
this.generateFieldMapping();
// this.$refs.file.value = null;
},
methods: {
generateFieldMapping() {
this.fieldMapping = Object.keys(this.fields).reduce((fieldMapping: any, field: string) => {
fieldMapping[field] = ""
return fieldMapping;
}, {})
},
async parse(event: any) {
const file = event.target.files[0];
try {
if (file) {
// recreate fieldMapping object when the file is changed
this.generateFieldMapping();

this.file = file;
this.content = await parseCsv(file).then(res => res);
this.fileColumns = Object.keys(this.content[0]);
Expand All @@ -109,9 +113,9 @@ export default defineComponent({
}

const uploadData = this.content.map((order: any) => ({
orderId: order[this.fieldMapping.orderId],
facilityId: order[this.fieldMapping.facilityId],
trackingCode: order[this.fieldMapping.trackingCode]
'orderIdValue': order[this.fieldMapping.orderId],
'externalFacilityId': order[this.fieldMapping.facilityId],
'trackingNumber': order[this.fieldMapping.trackingCode]
}))

const fileName = this.file.name.replace(".csv", ".json");
Expand Down Expand Up @@ -154,23 +158,9 @@ export default defineComponent({
},
setup() {
const router = useRouter();
const store = useStore();
const segmentSelected = ref('all');

return {
checkboxOutline,
calculatorOutline,
ellipsisVerticalOutline,
sendOutline,
arrowUndoOutline,
businessOutline,
cloudUploadOutline,
chevronForwardOutline,
timeOutline,
shirtOutline,
segmentSelected,
router,
store,
router
}
}
});
Expand Down