-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #781 from TGAC/existing-plant-lines-upload
Existing plant lines upload
- Loading branch information
Showing
13 changed files
with
364 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
$ -> | ||
new PlantPopulationSubmission('.edit-population-submission').init() | ||
window.pp = new PlantPopulationSubmission('.edit-population-submission') | ||
window.pp.init() | ||
new PlantTrialSubmission('.edit-trial-submission').init() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,30 @@ | ||
class SubmissionPlantLinesUploadDecorator < SubmissionUploadDecorator | ||
def as_json(*) | ||
super.merge(uploaded_plant_lines: uploaded_plant_lines) | ||
super.merge(uploaded_existing_plant_lines: uploaded_existing_plant_lines, | ||
uploaded_new_plant_lines: uploaded_new_plant_lines) | ||
end | ||
|
||
private | ||
|
||
def uploaded_plant_lines | ||
submission.content.uploaded_plant_lines | ||
submission.content.uploaded_plant_lines || [] | ||
end | ||
|
||
def new_plant_lines | ||
submission.content.new_plant_lines || [] | ||
end | ||
|
||
def uploaded_existing_plant_lines | ||
PlantLine. | ||
visible(submission.user_id). | ||
where(plant_line_name: uploaded_plant_lines). | ||
pluck(:id, :plant_line_name). | ||
map { |id, plant_line_name| { id: id, plant_line_name: plant_line_name } } | ||
end | ||
|
||
def uploaded_new_plant_lines | ||
new_plant_lines.select do |plant_line_attrs| | ||
uploaded_plant_lines.include?(plant_line_attrs.fetch("plant_line_name")) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.