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

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. #455

Merged
merged 1 commit into from
Sep 19, 2024
Merged
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
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
Loading