-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Improved: Added support to show errors for the erroneous uploads and to view the uploaded file (#525).
- Loading branch information
Showing
7 changed files
with
233 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<template> | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-buttons slot="start"> | ||
<ion-button @click="closeModal"> | ||
<ion-icon :icon="close" /> | ||
</ion-button> | ||
</ion-buttons> | ||
<ion-title>{{ translate("Import Error") }}</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content> | ||
<ion-list> | ||
<ion-item lines="full"> | ||
<ion-icon :icon="bookOutline" slot="start"/> | ||
{{ translate("View upload guide") }} | ||
<ion-button color="medium" fill="clear" slot="end" @click="viewUploadGuide"> | ||
<ion-icon slot="icon-only" :icon="openOutline"/> | ||
</ion-button> | ||
</ion-item> | ||
<ion-item lines="none"> | ||
<ion-label class="ion-text-wrap"> | ||
<template v-if="systemMessageError.errorText"> | ||
{{ systemMessageError.errorText }} | ||
</template> | ||
<template v-else> | ||
{{ translate("No data found") }} | ||
</template> | ||
</ion-label> | ||
</ion-item> | ||
</ion-list> | ||
</ion-content> | ||
</template> | ||
|
||
<script setup> | ||
import { | ||
IonButtons, | ||
IonButton, | ||
IonContent, | ||
IonHeader, | ||
IonIcon, | ||
IonItem, | ||
IonLabel, | ||
IonTitle, | ||
IonToolbar, | ||
IonList, | ||
modalController | ||
} from '@ionic/vue'; | ||
import { bookOutline, close, openOutline } from "ionicons/icons"; | ||
import { useStore } from "vuex"; | ||
import { defineProps, onMounted, ref } from 'vue'; | ||
import { translate } from "@hotwax/dxp-components"; | ||
import { CountService } from "@/services/CountService" | ||
import { hasError } from "@/utils"; | ||
import logger from "@/logger"; | ||
const store = useStore(); | ||
Check warning on line 59 in src/components/BulkUploadErrorModal.vue GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)
Check warning on line 59 in src/components/BulkUploadErrorModal.vue GitHub Actions / call-workflow-in-another-repo / build_and_deploy
|
||
let systemMessageError = ref({}) | ||
const props = defineProps(["systemMessage"]) | ||
onMounted(async() => { | ||
await fetchCycleCountImportErrors() | ||
}) | ||
function viewUploadGuide() { | ||
window.open('https://docs.hotwax.co/documents/retail-operations/inventory/introduction/draft-cycle-count', '_blank'); | ||
} | ||
function closeModal() { | ||
modalController.dismiss({ dismissed: true }); | ||
} | ||
async function fetchCycleCountImportErrors () { | ||
try { | ||
const resp = await CountService.fetchCycleCountImportErrors({ | ||
systemMessageId: props.systemMessage.systemMessageId, | ||
}); | ||
if (!hasError(resp)) { | ||
systemMessageError.value = resp?.data[0] | ||
} else { | ||
throw resp.data; | ||
} | ||
} catch (err) { | ||
logger.error(err); | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<template> | ||
<ion-content> | ||
<ion-list> | ||
<ion-list-header>{{ systemMessage.systemMessageId }}</ion-list-header> | ||
<ion-item v-if="systemMessage.statusId === 'SmsgReceived'" lines="none" button @click="cancelUpload()"> | ||
<ion-icon slot="end" /> | ||
{{ translate("Cancel") }} | ||
</ion-item> | ||
<ion-item v-if="systemMessage.statusId === 'SmsgError'" lines="none" button @click="viewErrorModal()"> | ||
<ion-icon slot="end"/> | ||
{{ translate("View error") }} | ||
</ion-item> | ||
<ion-item lines="none" button @click="viewFile()"> | ||
<ion-icon slot="end"/> | ||
{{ translate("View file") }} | ||
</ion-item> | ||
</ion-list> | ||
</ion-content> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { | ||
IonContent, | ||
IonIcon, | ||
IonItem, | ||
IonList, | ||
IonListHeader, | ||
modalController, | ||
popoverController | ||
} from "@ionic/vue" | ||
import { defineProps } from "vue"; | ||
import { translate } from "@/i18n" | ||
import store from "@/store"; | ||
import { CountService } from "@/services/CountService" | ||
import { downloadCsv, hasError, showToast } from "@/utils"; | ||
import logger from "@/logger"; | ||
import BulkUploadErrorModal from "./BulkUploadErrorModal.vue"; | ||
const props = defineProps(["systemMessage", "fileName"]) | ||
function closePopover() { | ||
popoverController.dismiss() | ||
} | ||
async function viewFile() { | ||
try { | ||
const resp = await CountService.fetchCycleCountUploadedFileData({ | ||
systemMessageId: props.systemMessage.systemMessageId, | ||
}); | ||
if (!hasError(resp)) { | ||
downloadCsv(resp.data.csvData, props.fileName) | ||
} else { | ||
throw resp.data; | ||
} | ||
} catch (err) { | ||
showToast(translate('Failed to download uploaded cycle count file.')) | ||
logger.error(err); | ||
} | ||
closePopover() | ||
} | ||
async function viewErrorModal() { | ||
const bulkUploadErrorModal = await modalController.create({ | ||
component: BulkUploadErrorModal, | ||
componentProps: { systemMessage: props.systemMessage } | ||
}); | ||
// dismissing the popover once the picker modal is closed | ||
bulkUploadErrorModal.onDidDismiss().finally(() => { | ||
closePopover(); | ||
}); | ||
return bulkUploadErrorModal.present(); | ||
} | ||
async function cancelUpload () { | ||
try { | ||
const resp = await CountService.cancelCycleCountFileProcessing({ | ||
systemMessageId: props.systemMessage.systemMessageId, | ||
statusId: 'SmsgCancelled' | ||
}); | ||
if (!hasError(resp)) { | ||
showToast(translate('Cycle count cancelled successfully.')) | ||
await store.dispatch('count/fetchCycleCountImportSystemMessages') | ||
} else { | ||
throw resp.data; | ||
} | ||
} catch (err) { | ||
showToast(translate('Failed to cancel uploaded cycle count.')) | ||
logger.error(err); | ||
} | ||
closePopover() | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters