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: SAVE MAPPING button saves empty mapping when file not uploaded(#326re7p) #114

Merged
merged 5 commits into from
Dec 8, 2022

Conversation

shashwatbangar
Copy link
Contributor

@shashwatbangar shashwatbangar commented Dec 5, 2022

Related Issues

Closes #110

Short Description and Why It's Useful

Now user can only save mapping if file is uploaded, a mapping name is provided & all fields are selected.

Screenshots of Visual Changes before/after (If There Are Any)

Screen.Recording.2022-12-05.at.12.25.02.PM.mov

IMPORTANT NOTICE - Remember to add changelog entry

Contribution and Currently Important Rules Acceptance

@@ -133,11 +133,20 @@ export default defineComponent({
return !this.fieldMappings[id] ? id : this.generateUniqueMappingPrefId();
},
saveMapping() {
if (this.mappingName) {
if (this.mappingName && this.file && this.areAllFieldsSelected()) {
showToast(translate("Mapping saved successfully"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should after the operation completion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes sir. Fixed it

const mappingPrefId = this.generateUniqueMappingPrefId();
this.store.dispatch('user/updateFieldMappings', { mappingPrefId, mappingPrefName: this.mappingName, mappingPrefValue: JSON.parse(JSON.stringify(this.fieldMapping)) })
} else {
showToast(translate("Enter mapping name"));
if(!this.mappingName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add these conditions at the top and return control, if they are fulfilled. The code if then doesn't need any if else

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done sir.

@@ -198,6 +207,9 @@ export default defineComponent({
this.mappingName = fieldMapping.mappingPrefName;
}
},
areAllFieldsSelected() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use it for other use cases in the page

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sir.

… name, earlier we were having two checks for missing mapping name, imcomplete field mapping or missing file upload in IF & ELSE block, now optimised code to do it in a single scope(#326re7p)
@adityasharma7 adityasharma7 merged commit 84b63cd into hotwax:main Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SAVE MAPPING button saves empty mapping when file not uploaded
2 participants