Skip to content

Commit

Permalink
Add visibility edit options to plan details
Browse files Browse the repository at this point in the history
The former implementation did not have the ability to change the plan
visibility when it was being edited. This is a required action for our
current platform.
  • Loading branch information
lagoan committed Mar 8, 2021
1 parent 5042cae commit 681bcdb
Show file tree
Hide file tree
Showing 11 changed files with 369 additions and 335 deletions.
4 changes: 2 additions & 2 deletions app/helpers/plans_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def display_visibility(val)
when 'privately_visible'
return "<span title=\"#{ visibility_tooltip(val) }\">#{_('Private')}</span>"
when 'is_test'
return "<span>#{_('Test')}</span>"
return "<span title=\"#{ visibility_tooltip(val) }\">#{_('Test')}</span>"
else
return "<span>N/A</span>"
end
Expand All @@ -38,7 +38,7 @@ def visibility_tooltip(val)
when 'privately_visible'
_('Private: restricted to me and people I invite.')
when 'is_test'
_('mock project for testing, practice, or educational purposes')
_('Test: mock project for testing, practice, or educational purposes.')
else
_('N/A')
end
Expand Down
4 changes: 3 additions & 1 deletion app/models/plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class Plan < ActiveRecord::Base
privately_visible: _("private")
}

VISIBILITY_ORDER = %i[privately_visible publicly_visible organisationally_visible
is_test]

# ==============
# = Attributes =
# ==============
Expand All @@ -65,7 +68,6 @@ class Plan < ActiveRecord::Base
enum visibility: %i[organisationally_visible publicly_visible
is_test privately_visible]


alias_attribute :name, :title


Expand Down
10 changes: 9 additions & 1 deletion app/views/plans/_edit_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@
</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])) %>
<% visibility_radio_options = Plan::VISIBILITY_ORDER.map {|visibility| {value: visibility, label: visibility_tooltip(visibility.to_s)} } %>
<% visibility_radio_options.each do |radio_option| %>
<div>
<%= f.radio_button :visibility, radio_option[:value] %>
<%= _(radio_option[:label]) %>
</div>
<% end %>

</div>
</div>

Expand Down
Loading

0 comments on commit 681bcdb

Please sign in to comment.