Skip to content

Commit

Permalink
Merge pull request #2992 from DMPRoadmap/madmp-research-outputs
Browse files Browse the repository at this point in the history
New maDMP Research Outputs tab
  • Loading branch information
briri authored Apr 6, 2022
2 parents a8e1b8a + e93dbb9 commit f1110b1
Show file tree
Hide file tree
Showing 86 changed files with 4,466 additions and 164 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ gem 'httparty'
# Autoload dotenv in Rails. (https://github.com/bkeepers/dotenv)
gem 'dotenv-rails'

gem 'activerecord_json_validator'

# ================================= #
# ENVIRONMENT SPECIFIC DEPENDENCIES #
# ================================= #
Expand Down
13 changes: 13 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ GEM
activemodel (= 5.2.6.2)
activesupport (= 5.2.6.2)
arel (>= 9.0)
activerecord_json_validator (2.1.0)
activerecord (>= 4.2.0, < 8)
json_schemer (~> 0.2.18)
activestorage (5.2.6.2)
actionpack (= 5.2.6.2)
activerecord (= 5.2.6.2)
Expand Down Expand Up @@ -130,6 +133,8 @@ GEM
dragonfly-s3_data_store (1.3.0)
dragonfly (~> 1.0)
fog-aws
ecma-re-validator (0.4.0)
regexp_parser (~> 2.2)
erubi (1.10.0)
excon (0.91.0)
execjs (2.8.1)
Expand Down Expand Up @@ -207,6 +212,7 @@ GEM
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
hana (1.3.7)
hashdiff (1.0.1)
hashie (5.0.0)
highline (2.0.3)
Expand All @@ -223,6 +229,11 @@ GEM
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
json (2.6.1)
json_schemer (0.2.19)
ecma-re-validator (~> 0.3)
hana (~> 1.3)
regexp_parser (~> 2.0)
uri_template (~> 0.7)
jwt (2.3.0)
kaminari (1.2.2)
activesupport (>= 4.1.0)
Expand Down Expand Up @@ -474,6 +485,7 @@ GEM
thread_safe (~> 0.1)
unicode-display_width (2.1.0)
uniform_notifier (1.14.2)
uri_template (0.7.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (3.7.0)
Expand Down Expand Up @@ -515,6 +527,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
activerecord_json_validator
annotate
annotate_gem
api-pagination
Expand Down
75 changes: 75 additions & 0 deletions app/assets/stylesheets/blocks/_modal_search.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
.modal-search-block {
border: 1px solid $color-grey;
margin-bottom: 10px;
padding: 10px 5px;
}

.modal-search .modal-dialog {
/* Make the dialog 80% of the screen height/width */
width: 80%;
// height: 80%;
}
.modal-search .modal-body {
/* 100% = dialog height, 50px = header (27.5px) + footer (21px) */
// max-height: calc(80% - 50px);
max-height: 450px;
overflow-y: scroll;
}

.modal-search-results-pagination {
margin-bottom: 10px;
}

.modal-search-result {
margin-top: 5px;
padding-bottom: 5px;

.modal-search-result-label {
font-size: 1.6rem;
font-weight: 500;
}

.tags > .tag {
display: inline-block;
margin: 5px 2px;
}
.tags .facet {
border: 1px solid $color-blue;
border-radius: 25px;
padding: 2px 5px;
}

div {
margin-bottom: 5px;
}

dl {
margin-left: 20px;

dd {
margin-bottom: 5px;
}
}
}

.modal-search-results .modal-search-result {
border-bottom: 1px solid $color-grey;
}

/* the 'Select' button displayed in the modal dialog */
.modal-search-result .modal-search-result-selector,
.modal-search-result .modal-search-result-unselector {
display: inline-block;
background-color: $color-white;
border-radius: 25px;
padding: 2px 5px;
font-size: 1.3rem;
}
.modal-search-result .modal-search-result-selector {
background-color: $color-green;
color: $color-white;
}
.modal-search-result .modal-search-result-unselector {
border: 1px solid $color-red;
color: $color-red;
}
1 change: 1 addition & 0 deletions app/assets/stylesheets/variables/_colours.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$color-black: #000;
$color-white: #FFF;
$color-red: #b94a48;
$color-green: #4c8d3f;
$color-grey: #4F5253;
$color-grey-darkest: #222;
$color-grey-darker: #333;
Expand Down
15 changes: 10 additions & 5 deletions app/controllers/plan_exports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ class PlanExportsController < ApplicationController

include ConditionsHelper

# rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
# rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
def show
@plan = Plan.includes(:answers, { template: { phases: { sections: :questions } } })
.find(params[:plan_id])
Expand All @@ -17,6 +18,7 @@ def show
@show_sections_questions = export_params[:question_headings].present?
@show_unanswered = export_params[:unanswered_questions].present?
@show_custom_sections = export_params[:custom_sections].present?
@show_research_outputs = export_params[:research_outputs].present?
@public_plan = false

elsif publicly_authorized?
Expand All @@ -25,6 +27,7 @@ def show
@show_sections_questions = true
@show_unanswered = true
@show_custom_sections = true
@show_research_outputs = @plan.research_outputs&.any? || false
@public_plan = true

else
Expand All @@ -49,7 +52,8 @@ def show
format.json { show_json }
end
end
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
# rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity

private

Expand Down Expand Up @@ -124,8 +128,9 @@ def privately_authorized?
end

def export_params
params.require(:export).permit(:form, :project_details, :question_headings,
:unanswered_questions, :custom_sections,
:formatting)
params.require(:export)
.permit(:form, :project_details, :question_headings, :unanswered_questions,
:custom_sections, :research_outputs,
formatting: [:font_face, :font_size, { margin: %i[top right bottom left] }])
end
end
28 changes: 1 addition & 27 deletions app/controllers/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,7 @@ def update
funder_attrs[:org_id] = plan_params[:funder][:id]
funder = org_from_params(params_in: funder_attrs)
@plan.funder_id = funder&.id
attrs.delete(:funder)

process_grant(grant_params: plan_params[:grant])
@plan.grant = plan_params[:grant]
attrs.delete(:grant)
attrs = remove_org_selection_params(params_in: attrs)

Expand Down Expand Up @@ -537,29 +535,5 @@ def render_phases_edit(plan, phase, guidance_groups)
guidance_presenter: GuidancePresenter.new(plan)
})
end

# Update, destroy or add the grant
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
def process_grant(grant_params:)
return false unless grant_params.present?

grant = @plan.grant

# delete it if it has been blanked out
if grant_params[:value].blank? && grant.present?
grant.destroy
@plan.grant = nil
elsif grant_params[:value] != grant&.value
if grant.present?
grant.update(value: grant_params[:value])
elsif grant_params[:value].present?
@plan.grant = Identifier.new(identifier_scheme: nil, identifiable: @plan,
value: grant_params[:value])
end
end
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
end
# rubocop:enable Metrics/ClassLength
Loading

0 comments on commit f1110b1

Please sign in to comment.