-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
Cache file upload original names #35429
base: master
Are you sure you want to change the base?
Conversation
a978dd1
to
f8e93c5
Compare
When deleting a repeat group we need to rebuild all the following groups because the IDs are reassigned by formplayer. Unfortunatly FP does not keep track of the original filename automatically and only sends the uuid based generated filename for the upload in the delete-repeat response. To be able to still display the original filename we store it in a map with the generated name as the key. That way we can figure out what it is when we rebuild that part of the UI.
f8e93c5
to
751629b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Not blocking, but is it possible to add a test/assert that checks the filename is cached and/or reassigned after a repeat is deleted?
self.fileNameDisplay(fixedNewValue); | ||
self.answer(fixedNewValue); | ||
} else if (cachedFilename) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know what the code above is doing? What situation is newValue
an empty string vs constants.NO_ANSWER
(null)?
if (newValue === "" && self.question.filename) {
self.question.hasAnswered = true;
self.fileNameDisplay(self.question.filename());
It looks like Minha added this previously here to solve a similar issue with the file question being rebuilt for question tiles. I'm not understanding why that doesn't solve the same issue here.
@@ -938,7 +938,8 @@ hqDefine("cloudcare/js/form_entry/entries", [ | |||
FileEntry.prototype = Object.create(EntrySingleAnswer.prototype); | |||
FileEntry.prototype.constructor = EntrySingleAnswer; | |||
FileEntry.prototype.onPreProcess = function (newValue) { | |||
var self = this; | |||
const self = this; | |||
const cachedFilename = self.question.form().fileNameCache[self.answer()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the distinction between self.answer()
and self.question.answer()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is none. self.answer just references to self. question.answer
commitAdd condition I missed in last commitAdd condition I missed in last commitAdd condition I missed in last commitAdd condition I missed in last commitAdd condition I missed in last commitAdd condition I missed in last commit
Product Description
When deleting a repeat group we need to rebuild all the following groups because the IDs are reassigned by formplayer. Unfortunately FP does not keep track of the original filename automatically and only sends the uuid based generated filename for the upload in the delete-repeat response. To be able to still display the original filename we store it in a map with the generated name as the key. That way we can figure out what it is when we rebuild that part of the UI.
Technical Summary
https://dimagi.atlassian.net/browse/USH-5078
Feature Flag
Safety Assurance
tested locally and on staging
Safety story
Automated test coverage
corehq/apps/cloudcare/static/cloudcare/js/form_entry/spec/form_ui_spec.js
QA Plan
Rollback instructions
Labels & Review