diff --git a/src/components/BulkUploadErrorModal.vue b/src/components/BulkUploadErrorModal.vue new file mode 100644 index 00000000..49baedfa --- /dev/null +++ b/src/components/BulkUploadErrorModal.vue @@ -0,0 +1,88 @@ + + + \ No newline at end of file diff --git a/src/components/CycleCountUploadActionPopover.vue b/src/components/CycleCountUploadActionPopover.vue new file mode 100644 index 00000000..20d292a2 --- /dev/null +++ b/src/components/CycleCountUploadActionPopover.vue @@ -0,0 +1,90 @@ + + + \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json index 23f0f3e2..486fa78d 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -122,6 +122,7 @@ "Go to OMS": "Go to OMS", "If a file includes multiple facilities, a count is created for every facility. All items with no facility location will be added to the same count.": "If a file includes multiple facilities, a count is created for every facility. All items with no facility location will be added to the same count.", "Import CSV": "Import CSV", + "Import Error": "Import Error", "In stock": "In stock", "inventory variance": "inventory variance", "Instance Url": "Instance Url", @@ -154,6 +155,7 @@ "New Count": "New Count", "New mapping": "New mapping", "No cycle counts found": "No cycle counts found", + "No data found": "No data found", "No items found": "No items found", "No new file upload. Please try again.": "No new file upload. Please try again.", "No products found.": "No products found.", @@ -297,6 +299,9 @@ "Variance updated successfully": "Variance updated successfully", "Version:": "Version: {appVersion}", "View": "View", + "View error": "View error", + "View file": "View file", + "View upload guide": "View upload guide", "You do not have permission to access the app.": "You do not have permission to access the app.", "You do not have permission to access this page": "You do not have permission to access this page", "3 rejections in the last week": "3 rejections in the last week" diff --git a/src/services/CountService.ts b/src/services/CountService.ts index 51704a6a..aae9db06 100644 --- a/src/services/CountService.ts +++ b/src/services/CountService.ts @@ -137,6 +137,22 @@ const cancelCycleCountFileProcessing = async (payload: any): Promise => { }); } +const fetchCycleCountImportErrors = async (payload: any): Promise => { + return api({ + url: `cycleCounts/systemMessages/${payload.systemMessageId}/errors`, + method: "get", + data: payload + }); +} + +const fetchCycleCountUploadedFileData = async (payload: any): Promise => { + return api({ + url: `cycleCounts/systemMessages/${payload.systemMessageId}/downloadFile`, + method: "get", + data: payload + }); +} + export const CountService = { acceptItem, addProductToCount, @@ -145,7 +161,9 @@ export const CountService = { createCycleCount, deleteCycleCountItem, fetchBulkCycleCountItems, + fetchCycleCountImportErrors, fetchCycleCountImportSystemMessages, + fetchCycleCountUploadedFileData, fetchCycleCount, fetchCycleCountStats, fetchCycleCounts, diff --git a/src/store/modules/count/actions.ts b/src/store/modules/count/actions.ts index 5c530de8..357257d4 100644 --- a/src/store/modules/count/actions.ts +++ b/src/store/modules/count/actions.ts @@ -187,12 +187,12 @@ const actions: ActionTree = { async fetchCycleCountImportSystemMessages({commit} ,payload) { let systemMessages; try { - const fifteenMinutesEarlier = DateTime.now().minus({ minutes: 15 }); + const twentyFourHoursEarlier = DateTime.now().minus({ hours: 24 }); const resp = await CountService.fetchCycleCountImportSystemMessages({ systemMessageTypeId: "ImportInventoryCounts", - initDate_from: fifteenMinutesEarlier.toMillis(), + initDate_from: twentyFourHoursEarlier.toMillis(), orderByField: 'initDate desc, processedDate desc', - pageSize: 10 + pageSize: 100 }) if (!hasError(resp)) { systemMessages = resp.data diff --git a/src/utils/index.ts b/src/utils/index.ts index f81696da..4d30ff32 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -157,4 +157,11 @@ const jsonToCsv = (file: any, options: JsonToCsvOption = {}) => { return blob; }; -export { jsonToCsv, showToast, hasError, handleDateTimeInput, getCycleCountStats, getDateTime, getDateWithOrdinalSuffix, getDerivedStatusForCount, getFacilityName, getPartyName, getProductIdentificationValue, timeFromNow, parseCsv } +const downloadCsv = (csv: any, fileName: any) => { + const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' }); + saveAs(blob, fileName ? fileName : "CycleCountImport.csv"); + + return blob; +}; + +export { downloadCsv, jsonToCsv, showToast, hasError, handleDateTimeInput, getCycleCountStats, getDateTime, getDateWithOrdinalSuffix, getDerivedStatusForCount, getFacilityName, getPartyName, getProductIdentificationValue, timeFromNow, parseCsv } diff --git a/src/views/BulkUpload.vue b/src/views/BulkUpload.vue index ee620309..b0868a3e 100644 --- a/src/views/BulkUpload.vue +++ b/src/views/BulkUpload.vue @@ -72,8 +72,8 @@
{{ getFileProcessingStatus(systemMessage) }} - - + +
@@ -105,20 +105,19 @@ import { IonToolbar, onIonViewDidEnter, alertController, - modalController + modalController, + popoverController } from '@ionic/vue'; -import { addOutline, cloudUploadOutline, trashBinOutline } from "ionicons/icons"; +import { addOutline, cloudUploadOutline, ellipsisVerticalOutline, trashBinOutline } from "ionicons/icons"; import { translate } from '@/i18n'; import { computed, ref } from "vue"; import { useStore } from 'vuex'; -import { useRouter } from 'vue-router' import { hasError, jsonToCsv, parseCsv, showToast } from "@/utils"; import CreateMappingModal from "@/components/CreateMappingModal.vue"; import { CountService } from "@/services/CountService" -import logger from "@/logger"; +import CycleCountUploadActionPopover from "@/components/CycleCountUploadActionPopover.vue" const store = useStore(); -const router = useRouter() const fieldMappings = computed(() => store.getters["user/getFieldMappings"]) const systemMessages = computed(() => store.getters["count/getCycleCountImportSystemMessages"]) @@ -187,26 +186,25 @@ function getFileProcessingStatus(systemMessage) { processingStatus = "processing" } else if (systemMessage.statusId === 'SmsgCancelled') { processingStatus = 'cancelled' + } else if (systemMessage.statusId === 'SmsgError') { + processingStatus = 'error' } return processingStatus; } -async function cancelUpload (systemMessage) { - try { - const resp = await CountService.cancelCycleCountFileProcessing({ - systemMessageId: 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); - } + +async function openUploadActionPopover(event, systemMessage){ + const popover = await popoverController.create({ + component: CycleCountUploadActionPopover, + event, + componentProps: { + systemMessage, + fileName: extractFilename(systemMessage.messageText) + }, + showBackdrop: false, + }); + await popover.present(); } + async function parse(event) { const file = event.target.files[0]; try {