-
Notifications
You must be signed in to change notification settings - Fork 7
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
Feature/1814 upload csv with new box #1903
Conversation
I need further help with this (cc @ysbaddaden) In Capybara, even if being able to attach the file (adding the
Some lead (that could be not the good one) to make the template to be included, I have to click the |
If this gets complicated, we'll leave it on a pause. |
It's just the Capybara tests, besides that works well (and the controller its tested). |
@leandroradusky what about uploading the CSV & validate it on the server and let it render the HTML to inject into the page? That would help rid of most of the JS. |
Hi @ysbaddaden (cc @diegoliberman) IMO these are important validations to be done in client side: There is at least these ways to uniquely identify batches on their mind:
for me in this case is quite important to inform the batches which were not found to guide them (the actual validations don't do that) Also, this file is made to be as similar as possible to the one that they use to compute the concentrations:
That's why I added the "not samples found" validation below. |
@leandroradusky I'm suggesting that we do all these validations but on the backend transparently (in the background, no page reload). You select a CSV file to upload. JS will display a "validating (spinner)" message, upload the CSV to You currently have to ask the backend if each batch exists, which results in N requests, but with the above approach we'd only have one request and avoid most of the JS, while still doing all the validation (win-win-win). |
Great! I didn't get it before, its a great hint thanks <3 |
@ysbaddaden @leandroradusky could it be possible to merge this one as is, and create a new issue for doing the validations in the backend? |
@diegoliberman Is the feature that important to have now? I'd prefer to avoid pushing tech-debt if possible. |
@ysbaddaden if the budget gets approved 2 months from now (we don't know), then the users will be very thankful to have the feature already available during this time. |
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.
We can probably live with the JS, but the handleFileSelect
is too big and nests too many closures.
I believe we can skip the "add files" button and always render the upload CSV file input instead. We could then simplify a bunch of things in the JS, extract methods out of the handleFileSelect
callback.
For example:
- extract the part that parses & validates the CSV into functions (pass it
load_event.target.result
and let it returnsamples
,found_batches
¬_found_batches
); - extract the rendering of the row template;
- make
removeFileRow
global (not closured); - since we're only rendering one row: we can assume the DOM elements to be there, and don't need to pass references anymore;
- ...
9f61816
to
f22e1e6
Compare
Voila. I've move the validation in backend. Let me know what do you think @leandroradusky @ysbaddaden |
f22e1e6
to
b88da4c
Compare
b88da4c
to
0d31e46
Compare
The values in FoundBatches were wrong. It was a list uuid instead of batche_values Reset CSVFile when applySampleSourceChange is called
Despite the integration tests to be fixed, I've tested the functionality locally to demo it with UCSD and it works as expected :) |
hey @leandroradusky @ysbaddaden In addition, I've made the Box#create method more consistent and concise. I removed the redundant valid? check for BoxForm, as the BoxForm.save method already performs the necessary validations. What do you think? |
They broke the creation of boxes from batches and samples, and prevented the creation in a single transaction of the box and its samples, leading to the possibility of creating a box without samples or worse with only a few of the expected samples in case of a database error.
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.
I pushed a couple commits to fix the broken spec suites (unit & integration). I explained why they broke as comments to this review.
@@ -17,7 +17,7 @@ | |||
.col.form-field__label | |||
%label Samples | |||
.col.radiotoggle | |||
= f.radio_button :option, "add_batches" | |||
= f.radio_button :option, "add_batches", required: true |
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.
Why make one radio button required out of the set?
@bolom yes, I fixed it ysterday as @leandroradusky wanted to have it today in staging. |
Closes #1814
Now a box can be created from a CSV file. To agree with the excel files that they use in order to define box samples concentrations, they should look like this.
This is the file that you can download as a template file when you choose the new option in the boxes form:
If the file is correct, it will respect the mockups done for the sample's upload results page:
If, within the file, some rows have inexistent batches, they will be informed:
While this message will be shown if no samples have been parsed (because they are not, or because the file has a wrong file format, etc):
Comments on the code:
box_form
, the file is parsed and the same parameters as if the user has chosen the optionCreate new samples
options are fulfilled and saved (initialize_csv_box
method)add_csv
option is tested on the controller (as previously discussed).