diff --git a/app/views/guidances/_guidance_form.html.erb b/app/views/guidances/_guidance_form.html.erb index 0dcb766..cf5f333 100644 --- a/app/views/guidances/_guidance_form.html.erb +++ b/app/views/guidances/_guidance_form.html.erb @@ -2,16 +2,13 @@ <%= f.label :text, class: 'control-label' %> <%= text_area_tag("guidance-text", guidance.text, class: "tinymce form-control", 'aria-required': true, rows: 10) %> -
- <%= f.label _('Themes'), for: :theme_ids, class: 'control-label' %> - <%= f.collection_select(:theme_ids, themes, - :id, :title, {prompt: false}, {multiple: true, 'data-toggle': 'tooltip', title: _('Select which theme(s) this guidance relates to.'), class: 'form-control', 'aria-required': true}) %> -
+<% render partial: 'org_admin/shared/theme_selector', locals: { f: f, all_themes: themes } %>
<%= f.label _('Guidance group'), for: :guidance_group_id, class: 'control-label' %> <%= f.collection_select(:guidance_group_id, guidance_groups, :id, :name, {prompt: false}, {multiple: false, 'data-toggle': 'tooltip', title: _('Select which group this guidance relates to.'), class: 'form-control', 'aria-required': true})%>
+
<%= f.label :published, raw("#{f.check_box :published, as: :check_boxes, 'data-toggle': 'tooltip', title: _("Check this box when you are ready for this guidance to appear on user's plans.")} #{_('Published?')}") %>
diff --git a/app/views/guidances/new_edit.html.erb b/app/views/guidances/new_edit.html.erb index a9fc547..09d3aca 100644 --- a/app/views/guidances/new_edit.html.erb +++ b/app/views/guidances/new_edit.html.erb @@ -12,11 +12,7 @@ <%= f.label :text, class: 'control-label' %> <%= text_area_tag("guidance-text", guidance.text, class: "tinymce form-control", 'aria-required': true, rows: 10) %> -
- <%= f.label _('Themes'), for: :theme_ids, class: 'control-label' %> - <%= f.collection_select(:theme_ids, themes, - :id, :title, {prompt: false}, {multiple: true, 'data-toggle': 'tooltip', title: _('Select which theme(s) this guidance relates to.'), class: 'form-control', 'aria-required': true}) %> -
+ <%= render partial: 'org_admin/shared/theme_selector', locals: { f: f, all_themes: themes } %>
<%= f.label _('Guidance group'), for: :guidance_group_id, class: 'control-label' %> <%= f.collection_select(:guidance_group_id, guidance_groups, diff --git a/app/views/org_admin/shared/_theme_selector.html.erb b/app/views/org_admin/shared/_theme_selector.html.erb new file mode 100644 index 0000000..b68c502 --- /dev/null +++ b/app/views/org_admin/shared/_theme_selector.html.erb @@ -0,0 +1,28 @@ +<%# locals: all_themes %> +
+ <%= f.label _('Themes'), for: :theme_ids, class: 'control-label' %> +
+ <% if all_themes.length > 0 %> + <% + cntr = 0 + nbr_of_cols = (all_themes.length.to_f / MAX_NUMBER_THEMES_PER_COLUMN.to_f).ceil + col_size = (12 / (nbr_of_cols > 4 ? 3 : nbr_of_cols)).round + %> +
+ <% all_themes.each do |theme| %> + <% if cntr >= MAX_NUMBER_THEMES_PER_COLUMN %> +
+
+ <% cntr = 0 %> + <% end %> +
+ <%= f.label :theme_ids, raw("#{f.check_box :theme_ids, {multiple: true}, theme.id, nil} #{theme.title}") %> +
+ <% cntr += 1 %> + <% end %> +
+ <% else %> +

<%= _('No themes have been defined. Please contact your administrator for assistance.') %>

+ <% end %> +
+
\ No newline at end of file diff --git a/app/views/questions/_add_question.html.erb b/app/views/questions/_add_question.html.erb index 158a51d..654aa97 100644 --- a/app/views/questions/_add_question.html.erb +++ b/app/views/questions/_add_question.html.erb @@ -78,13 +78,9 @@
-
- <%= f.label(:theme_ids, _('Themes'), class: "control-label") %> - <%= f.collection_select(:theme_ids, - Theme.all.order("title"), - :id, :title, {prompt: false}, {multiple: true, 'data-toggle': 'tooltip', 'data-html': true, title: _("

Select themes that are relevant to this question.

This allows your generic institution-level guidance to be drawn in, as well as that from other sources e.g. the %{organisation_abbreviation} or any Schools/Departments that you provide guidance for.

You can select multiple themes by using the CTRL button.

"), class: 'form-control'}) %> +
+ <%= render partial: 'org_admin/shared/theme_selector', locals: { f: f, all_themes: Theme.all.order("title") } %>
-
<%= f.submit _('Save'), class: "btn btn-default", role:'button' %> diff --git a/app/views/questions/_edit_question.html.erb b/app/views/questions/_edit_question.html.erb index e42ff2a..70d06fe 100644 --- a/app/views/questions/_edit_question.html.erb +++ b/app/views/questions/_edit_question.html.erb @@ -86,13 +86,9 @@
-
- <%= f.label(:theme_ids, _('Themes'), class: "control-label") %> - <%= f.collection_select(:theme_ids, - Theme.all.order("title"), - :id, :title, {prompt: false}, {multiple: true, 'data-toggle': 'tooltip', 'data-html': true, title: _("

Select themes that are relevant to this question.

This allows your generic institution-level guidance to be drawn in, as well as that from other sources e.g. the %{organisation_abbreviation} or any Schools/Departments that you provide guidance for.

You can select multiple themes by using the CTRL button.

"), class: 'form-control'}) %> +
+ <%= render partial: 'org_admin/shared/theme_selector', locals: { f: f, all_themes: Theme.all.order("title") } %>
-
<%= f.submit _('Save'), class: "btn btn-default", role:'button' %> diff --git a/config/initializers/constants.rb b/config/initializers/constants.rb index 51d0993..0b64627 100644 --- a/config/initializers/constants.rb +++ b/config/initializers/constants.rb @@ -3,3 +3,4 @@ TABLE_FILTER_MIN_ROWS = 10 MAX_NUMBER_LINKS_FUNDER = 5 MAX_NUMBER_LINKS_SAMPLE_PLAN = 5 +MAX_NUMBER_THEMES_PER_COLUMN = 5