Skip to content

Commit

Permalink
Merge pull request #455 from hotwax/#453_inventory_count_bulk_upload
Browse files Browse the repository at this point in the history
Fixed: 1) Validation to check all the required fields are mapped. 2) Reset fields after successful upload. 3) Disabled cancel button to avoid cancelling of processed file.
  • Loading branch information
ravilodhi authored Sep 19, 2024
2 parents 538c138 + 63a8935 commit b5c68f9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/views/BulkUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
</ion-label>
<div class="system-message-action">
<ion-note slot="end">{{ getFileProcessingStatus(systemMessage) }}</ion-note>
<ion-button :disabled="systemMessage.statusId === 'SmsgCancelled'" slot="end" fill="clear" color="medium" @click="cancelUpload(systemMessage)">
<ion-button :disabled="systemMessage.statusId !== 'SmsgReceived'" slot="end" fill="clear" color="medium" @click="cancelUpload(systemMessage)">
<ion-icon slot="icon-only" :icon="trashBinOutline" />
</ion-button>
</div>
Expand All @@ -97,11 +97,8 @@ import {
IonLabel,
IonList,
IonListHeader,
IonMenuButton,
IonNote,
IonPage,
IonSegment,
IonSegmentButton,
IonSelect,
IonSelectOption,
IonTitle,
Expand Down Expand Up @@ -149,7 +146,15 @@ onIonViewDidEnter(async() => {
await store.dispatch('user/getFieldMappings')
await store.dispatch('count/fetchCycleCountImportSystemMessages')
})
function resetDefaults() {
fieldMapping.value = Object.keys(fields).reduce((fieldMapping, field) => {
fieldMapping[field] = ""
return fieldMapping;
}, {})
uploadedFile.value = {}
content.value = []
fileName.value = null
}
function extractFilename(filePath) {
if (!filePath) {
return;
Expand Down Expand Up @@ -259,6 +264,8 @@ async function save(){
if (hasError(resp)) {
throw resp.data
}
resetDefaults()
file.value.value = ''
await store.dispatch('count/fetchCycleCountImportSystemMessages')
showToast(translate("The cycle counts file uploaded successfully."))
}).catch(() => {
Expand Down Expand Up @@ -290,7 +297,10 @@ function mapFields(mapping) {
fieldMapping.value = fieldMappingData.value;
}
function areAllFieldsSelected() {
return Object.values(fieldMapping).every(field => field !== "");
const requiredFields = Object.keys(getFilteredFields(fields, true));
const selectedFields = Object.keys(fieldMapping.value).filter(key => fieldMapping.value[key] !== '')
return requiredFields.every(field => selectedFields.includes(field));
}
async function addFieldMapping() {
const createMappingModal = await modalController.create({
Expand Down

0 comments on commit b5c68f9

Please sign in to comment.