Skip to content

Commit

Permalink
Make public plans downloadable
Browse files Browse the repository at this point in the history
  • Loading branch information
lagoan committed Mar 5, 2021
1 parent f8dcfd9 commit 5042cae
Show file tree
Hide file tree
Showing 18 changed files with 449 additions and 424 deletions.
2 changes: 1 addition & 1 deletion app/controllers/org_admin/templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def template_export
},
font_size: 8,
spacing: (@formatting[:margin][:bottom] / 2) - 4,
right: "[page] of [topage]",
right: _("[page] of [topage]"),
encoding: "utf8"
}
# rubocop:enable Metrics/LineLength
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/public_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def template_export
},
font_size: 8,
spacing: (@formatting[:margin][:bottom] / 2) - 4,
right: "[page] of [topage]",
right: _("[page] of [topage]"),
encoding: "utf8"
}
# rubocop:enable Metrics/LineLength
Expand Down
31 changes: 26 additions & 5 deletions app/helpers/plans_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,40 @@ def display_visibility(val)
return "<span title=\"#{ visibility_tooltip(val) }\">#{_('Public')}</span>"
when 'privately_visible'
return "<span title=\"#{ visibility_tooltip(val) }\">#{_('Private')}</span>"
else
return "<span>#{_('Private')}</span>" # Test Plans
when 'is_test'
return "<span>#{_('Test')}</span>"
else
return "<span>N/A</span>"
end
end

def visibility_tooltip(val)
case val
when 'organisationally_visible'
return _('Organisation: anyone at my organisation can view.')
_('Organisation: anyone at my organisation can view.')
when 'publicly_visible'
_('Public: anyone can view.')
when 'privately_visible'
_('Private: restricted to me and people I invite.')
when 'is_test'
_('mock project for testing, practice, or educational purposes')
else
_('N/A')
end
end

def visibility_options(val)
case val
when 'organisationally_visible'
_('Organisation')
when 'publicly_visible'
return _('Public: anyone can view.')
_('Public')
when 'privately_visible'
_('Private')
when 'is_test'
_('Test')
else
return _('Private: restricted to me and people I invite.')
_('N/A')
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/paginable/plans/_org_admin.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<td><%= plan.owner.name(false) %></td>
<td><%= l(plan.updated_at.to_date, formats: :short) %></td>
<td class="plan-visibility">
<%= plan.visibility === 'is_test' ? _('Test') : sanitize(display_visibility(plan.visibility)) %>
<%= sanitize(display_visibility(plan.visibility)) %>
</td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/paginable/plans/_org_admin_other_user.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<td><%= plan.owner.name(false) %></td>
<td><%= l(plan.updated_at.to_date, formats: :short) %></td>
<td class="plan-visibility">
<%= plan.visibility === 'is_test' ? _('Test') : sanitize(display_visibility(plan.visibility)) %>
<%= sanitize(display_visibility(plan.visibility)) %>
</td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/paginable/plans/_privately_visible.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<% end %>
</td>
<td class="plan-visibility">
<%= plan.visibility === 'is_test' ? _('N/A') : sanitize(display_visibility(plan.visibility)) %>
<%= sanitize(display_visibility(plan.visibility)) %>
</td>
<td>
<% if plan.shared? %>
Expand Down
15 changes: 9 additions & 6 deletions app/views/plans/_edit_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
<%= f.text_field(:title, class: "form-control", "aria-required": true,
'data-toggle': 'tooltip', spellcheck: true,
title: project_title_tooltip) %>
<div class="checkbox">
<%= f.hidden_field :visibility %>
<%= f.label(:is_test, class: 'control-label') do %>
<%= check_box_tag(:is_test, 1, @plan.is_test?, "aria-label": "is_test") %>
<%= _('mock project for testing, practice, or educational purposes') %>
<% end %>
</div>
</div>

<div class="form-group"><!-- visibility -->
<div class="col-md-12">
<%= f.label(:visibility, _('Visibility'), class: 'control-label') %>
</div>
<div class="col-md-8">
<%= f.select(:visibility, options_for_select(Plan.visibilities.map {|k, v| [visibility_options(k), k]}, [@plan.visibility])) %>
</div>
</div>

<div class="form-group"><!-- funder_name -->
<div class="col-md-12">
<%= f.label(:funder_name, _('Funder'), class: 'control-label') %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/export/_plan.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<% end %>
<% section[:questions].each do |question| %>
<div class="question">
<% if !@public_plan && @show_sections_questions%>
<% if @show_sections_questions%>
<%# Hack: for DOCX export - otherwise, bold highlighting of question inconsistent. %>
<% if local_assigns[:export_format] && export_format == 'docx' %>
<strong><%= sanitize question[:text].to_s, scrubber: TableFreeScrubber.new %></strong>
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@ class Application < Rails::Application
config.default_plan_visibility = 'privately_visible'

# The percentage of answered questions needed to enable the plan visibility section of the Share plan page
config.default_plan_percentage_answered = 50
config.default_plan_percentage_answered = 0
end
end
Loading

0 comments on commit 5042cae

Please sign in to comment.