diff --git a/Gemfile b/Gemfile index 2d9b5b9..77acae3 100644 --- a/Gemfile +++ b/Gemfile @@ -60,7 +60,6 @@ gem 'less-rails' # WE SHOULD PROBABLY USE SASS OR LESS NOT BOTH gem 'jquery-rails' gem 'font-awesome-rails' -gem 'twitter-bootstrap-rails', '2.2.8' gem 'tinymce-rails' # WYSIWYG EDITOR gem 'contact_us', '>= 1.2.0' # COULD BE EASILY REPLACED WITH OUR OWN CODE gem 'recaptcha', '>= 4.0' diff --git a/Gemfile.lock b/Gemfile.lock index 53bf3cf..8e7f5a7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -174,7 +174,7 @@ activerecord (>= 3.1) less (2.6.0) commonjs (~> 0.2.7) - less-rails (2.7.1) + less-rails (2.8.0) actionpack (>= 4.0) less (~> 2.6.0) sprockets (> 2, < 4) @@ -322,11 +322,6 @@ tilt (2.0.5) tinymce-rails (4.4.3) railties (>= 3.1.1) - twitter-bootstrap-rails (2.2.8) - actionpack (>= 3.1) - execjs - rails (>= 3.1) - railties (>= 3.1) tzinfo (1.2.2) thread_safe (~> 0.1) uglifier (3.0.2) @@ -399,7 +394,6 @@ therubyracer (>= 0.11.4) thin tinymce-rails - twitter-bootstrap-rails (= 2.2.8) uglifier web-console (~> 2.0) webmock diff --git a/app/controllers/guidances_controller.rb b/app/controllers/guidances_controller.rb index 2356ef0..2bbf7ec 100644 --- a/app/controllers/guidances_controller.rb +++ b/app/controllers/guidances_controller.rb @@ -10,13 +10,6 @@ @guidance_groups = GuidanceGroup.where(org_id: current_user.org_id) end - ## - # GET /guidances/1 - def admin_show - @guidance = Guidance.eager_load(:guidance_group, :themes).find(params[:id]) - authorize @guidance - end - def admin_new @guidance = Guidance.new authorize @guidance @@ -54,7 +47,7 @@ end if @guidance.save - redirect_to admin_show_guidance_path(@guidance), notice: _('Guidance was successfully created.') + redirect_to admin_edit_guidance_path(@guidance), notice: _('Guidance was successfully created.') else flash[:notice] = failed_create_error(@guidance, _('guidance')) @themes = Theme.all.order('title') @@ -71,7 +64,7 @@ @guidance.text = params["guidance-text"] if @guidance.save(guidance_params) - redirect_to admin_show_guidance_path(params[:guidance]), notice: _('Guidance was successfully updated.') + redirect_to admin_edit_guidance_path(params[:guidance]), notice: _('Guidance was successfully updated.') else flash[:notice] = failed_update_error(@guidance, _('guidance')) @themes = Theme.all.order('title') diff --git a/app/controllers/orgs_controller.rb b/app/controllers/orgs_controller.rb index 7b4397e..43f2c54 100644 --- a/app/controllers/orgs_controller.rb +++ b/app/controllers/orgs_controller.rb @@ -3,13 +3,6 @@ respond_to :html ## - # GET /organisations/1 - def admin_show - @org = Org.find(params[:id]) - authorize @org - end - - ## # GET /organisations/1/edit def admin_edit @org = Org.find(params[:id]) @@ -28,18 +21,19 @@ begin if @org.update_attributes(org_params) - redirect_to admin_show_org_path(params[:id]), notice: _('Organisation was successfully updated.') + flash[:notice] = _('Organisation was successfully updated.') + render action: "admin_edit" else # For some reason our custom validator returns as a string and not a hash like normal activerecord # errors. We followed the example provided in the Rails guides when building the validator so # its unclear why its doing this. Placing a check here for the data type. We should reasses though # when doing a broader eval of the look/feel of the site and we come up with a standardized way of # displaying errors - flash[:notice] = failed_update_error(@org, _('organisation')) + flash[:alert] = failed_update_error(@org, _('organisation')) render action: "admin_edit" end rescue Dragonfly::Job::Fetch::NotFound => dflye - flash[:notice] = _('There seems to be a problem with your logo. Please upload it again.') + flash[:alert] = _('There seems to be a problem with your logo. Please upload it again.') render action: "admin_edit" end end @@ -89,6 +83,6 @@ private def org_params params.require(:org).permit(:name, :abbreviation, :target_url, :is_other, :banner_text, :language_id, - :region_id, :logo, :contact_email) + :region_id, :logo, :contact_email, :remove_logo) end end diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 0a4ae70..41e502d 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -28,6 +28,7 @@ # Get the current user's org @default_org = current_user.org if @orgs.include?(current_user.org) + flash[:notice] = "#{_('This is a')} #{_('test plan')}" if params[:test] @is_test = params[:test] ||= false respond_to :html @@ -141,7 +142,6 @@ end - # we can go into this with the user able to edit or not able to edit # the same edit form gets rendered but then different partials get used # to render the answers depending on whether it is readonly or not @@ -156,7 +156,30 @@ authorize @plan # If there was no phase specified use the template's 1st phase @phase = (params[:phase].nil? ? @plan.template.phases.first : Phase.find(params[:phase])) - @readonly = !@plan.editable_by?(current_user.id) + + # Get all Guidance Groups applicable for the plan and group them by org + @all_guidance_groups = @plan.get_guidance_group_options + @all_ggs_grouped_by_org = @all_guidance_groups.sort.group_by(&:org) + + # Important ones come first on the page - we grab the user's org's GGs and "Organisation" org type GGs + @important_ggs = [] + @important_ggs << [current_user.org, @all_ggs_grouped_by_org.delete(current_user.org)] + @all_ggs_grouped_by_org.each do |org, ggs| + if org.organisation? + @important_ggs << [org,ggs] + @all_ggs_grouped_by_org.delete(org) + end + end + + # Sort the rest by org name for the accordion + @all_ggs_grouped_by_org = @all_ggs_grouped_by_org.sort_by {|org,gg| org.name} + + @selected_guidance_groups = @plan.guidance_groups.pluck(:id) + @based_on = (@plan.template.customization_of.nil? ? @plan.template : Template.where(dmptemplate: @plan.template.customization_of).first) + + flash[:notice] = "#{_('This is a')} #{_('test plan')}" if params[:test] + @is_test = params[:test] ||= false + respond_to :html end diff --git a/app/helpers/plans_helper.rb b/app/helpers/plans_helper.rb index 1575bce..2377439 100644 --- a/app/helpers/plans_helper.rb +++ b/app/helpers/plans_helper.rb @@ -39,11 +39,11 @@ def display_visibility(val) case val when 'organisationally_visible' - return "#{_('Institutional')}" + return "#{_('Institution: anyone at my institution can view')}" when 'publicly_visible' - return "#{_('Public')}" + return "#{_('Public: anyone can view')}" else - return "#{_('Private')}" # Both Test and Private + return "#{_('Private: restricted to me and people I invite')}" # Both Test and Private end end diff --git a/app/views/contact_us/contacts/new.html.erb b/app/views/contact_us/contacts/new.html.erb index 4d704f0..645fa50 100644 --- a/app/views/contact_us/contacts/new.html.erb +++ b/app/views/contact_us/contacts/new.html.erb @@ -1,99 +1,95 @@ -<% javascript "contacts/new_contact.js" %> +<% javascript "views/contacts/new_contact.js" %>
- <%= raw _('%{application_name} is provided by the %{organisation_name}. You can find out more about us on our website. If you would like to contact us about %{application_name}, please fill out the form below.') % {organisation_name: Rails.configuration.branding[:organisation][:name],
+ <%= raw _('%{application_name} is provided by the %{organisation_name}.
You can find out more about us on our website. If you would like to contact us about %{application_name}, please fill out the form below.') % {organisation_name: Rails.configuration.branding[:organisation][:name],
organisation_url: Rails.configuration.branding[:organisation][:url],
application_name: Rails.configuration.branding[:application][:name]} %>
Helpline: %{organisation_telephone}
-Email %{organisation_email}
") % - { organisation_name: Rails.configuration.branding[:organisation][:name], - organisation_address_line1: Rails.configuration.branding[:organisation][:address_line1], - organisation_address_line2: Rails.configuration.branding[:organisation][:address_line2], - organisation_address_line3: Rails.configuration.branding[:organisation][:address_line3], - organisation_address_line4: Rails.configuration.branding[:organisation][:address_line4], - organisation_address_country: Rails.configuration.branding[:organisation][:address_country], - organisation_telephone: Rails.configuration.branding[:organisation][:telephone], - organisation_email: Rails.configuration.branding[:organisation][:email], - application_name: Rails.configuration.branding[:application][:name]} %> - -<%= "#{_('Helpline')} #{Rails.configuration.branding[:organisation][:telephone]}" %>
+<%= _('Email') %> <%= Rails.configuration.branding[:organisation][:email] %>
-<%= _('The email address you entered is not registered.') %>
@@ -8,14 +8,14 @@<%= _('Please enter your email below and we will send you instructions on how to reset your password.') %>
-| <%= _('Name') %> | -
-
- <%= f.text_field :name,
- as: :string,
- class: 'text_field' %>
-
-
-
- <%= link_to(image_tag('help_button.png'), '#', class: 'guidance_group_title_popover', rel: "popover", 'data-html' => "true", 'data-content' => _('Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. "[guidance group name]: guidance on data sharing" so we suggest you just use the institution or department name.')) %>
-
- |
-
| <%= _('Published') %> | -
-
- <%= f.check_box :published %>
-
-
-
-
- |
-
| <%= _('Optional subset') %> | -
-
- <%= f.check_box :optional_subset %> <%= _('e.g. School/ Department') %>
-
-
- <%= link_to(image_tag('help_button.png'), '#', class: 'guidance_group_subset_popover', rel: "popover", 'data-html' => "true", 'data-content' => _("If the guidance is only meant for a subset of users e.g. those in a specific college or institute, check this box. Users will be able to select to display this subset guidance when answering questions in the 'create plan' wizard.")) %>
-
- |
-
| <%= _('Name') %> | -
- <%= f.text_field :name, as: :string, class: "text_field" %>
-
-
- <%= link_to( image_tag("help_button.png"), "#", class: 'guidance_group_title_popover', rel: "popover", 'data-html' => "true", 'data-content' => _('Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. "[guidance group name]: guidance on data sharing" so we suggest you just use the institution or department name.'))%>
-
- |
-
| <%= _('Optional subset') %> | -
- <%= f.check_box :optional_subset %> <%= _('e.g. School/ Department') %>
-
-
- <%= link_to( image_tag('help_button.png'), '#', class: 'guidance_group_subset_popover', rel: "popover", 'data-html' => "true", 'data-content' => _("If the guidance is only meant for a subset of users e.g. those in a specific college or institute, check this box. Users will be able to select to display this subset guidance when answering questions in the 'create plan' wizard."))%>
-
- |
-
| <%= _('Name') %> | -<%= raw @guidance_group.name %> | -
| <%= _('Published') %> | -- <% if @guidance_group.published.nil? || !@guidance_group.published then %> - <%= _('No') %> - <% else %> - <%= _('Yes') %> - <% end %> - | -
| <%= _('Optional subset') %> | -- <% if @guidance_group.optional_subset.nil? || !@guidance_group.optional_subset then %> - <%= _('No') %> - <% else %> - <%= _('Yes') %> - <% end %> - | -
| <%= _('Created') %> | -<%= l @guidance_group.created_at.to_date, formats: :short %> | -
| <%= _('Last updated') %> | -<%= l @guidance_group.updated_at.to_date, formats: :short %> | -
| <%= _('Text') %> | -
-
- <%= text_area_tag("guidance-text", @guidance.text, class: "tinymce") %>
-
-
- <%= link_to( image_tag('help_button.png'), '#', class: 'guidance_text_popover', rel: "popover", 'data-html' => "true", 'data-content' => _('Enter your guidance here. You can include links where needed.'))%>
-
-
- |
-
| <%= _('Themes') %> | -
-
-
- <%= f.collection_select(:theme_ids, @themes, :id, :title,
+
+ <%= form_for(@guidance, url: admin_update_guidance_path(@guidance), html: { method: :put , id: 'edit_guidance_form', class: 'roadmap-form bordered'}) do |f| %>
+
- |
+
| <%= _('Published') %> | -
- <%= f.check_box :published , as: :check_boxes%>
-
- |
-
| <%= _('Guidance group') %> | -
-
- <%= f.collection_select(:guidance_group_id, @guidance_groups,
- :id, :name, {prompt: false, include_blank: 'None'}, {multiple: false})%>
-
-
- <%= link_to( image_tag('help_button.png'), '#', class: 'guidance_group_select_popover', rel: "popover", 'data-html' => "true", 'data-content' => _('Select which group this guidance relates to.'))%>
-
-
-
- |
-
First create a guidance group. This could be institution wide or a subset e.g. a particular College / School, Institute or department. When you create guidance you'll be asked to assign it to a guidance group.
")%> -+ <%= _("First create a guidance group. This could be institution wide or a subset e.g. a particular College / School, Institute or department. When you create guidance you'll be asked to assign it to a guidance group.") %> +
- -<% if @guidance_groups.length > 0 then%> -| <%= _('Name') %> | -<%= _('Published') %> | -<%= _('Optional subset') %> | -<%= _('Last updated') %> | -<%= _('Actions') %> | -
|---|---|---|---|---|
| - <%= guidance_gr.name %> - | -- <% if guidance_gr.published.nil? || guidance_gr.published == false then%> - <%= _('No')%> - <% else %> - <%= _('Yes')%> - <% end %> - | -- <% if guidance_gr.optional_subset.nil? || guidance_gr.optional_subset == false then%> - <%= _('No')%> - <% else %> - <%= _('Yes')%> - <% end %> - | - -- <%= l guidance_gr.updated_at.to_date, formats: :short %> - | -
- <%= link_to _('View'), admin_show_guidance_group_path(guidance_gr), class: "dmp_table_link"%> - <%= link_to _('Edit'), admin_edit_guidance_group_path(guidance_gr), class: "dmp_table_link"%> - <%= link_to _('Delete'), admin_destroy_guidance_group_path(guidance_gr), data: {confirm: _("You are about to delete '%{guidance_group_name}'. This will affect guidance. Are you sure?") % { :guidance_group_name => guidance_gr.name }}, method: :delete, class: "dmp_table_link"%> - |
-
You can write pieces of guidance to be displayed by theme (e.g. generic guidance on storage and backup that should present across the board). Writing generic guidance by theme saves you time and effort as your advice will be automatically displayed across all templates rather than having to write guidance to accompany each.
If you do have a need to provide guidance for specific funders that would not be useful to a wider audience (e.g. if you have specific instructions for applicants to BBSRC for example), you can do so by adding guidance to a specific question when you edit your template.
')%> -| <%= _('Text') %> | -<%= _('Themes') %> | -<%= _('Guidance group') %> | -<%= _('Last updated') %> | -<%= _('Actions') %> | -||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| - <%= guidance.text.html_safe%> - | - <% if guidance.themes.present? then %> -- <% guidance.themes.each do |th| %> - <%= th.title %> - <% end %> - | - <% else %> -- - - | - <% end %> - <% if guidance.guidance_group.present? then %> -
- <%= guidance.guidance_group.name %>
+
+ <%= _('Guidance group list') %>+ + + <% if @guidance_groups.length > 0 then%> +
+ <% if guidance_gr.published.nil? || guidance_gr.published == false then%>
+ <%= _('No')%>
+ <% else %>
+ <%= _('Yes')%>
+ <% end %>
+ |
+
+ <% if guidance_gr.optional_subset.nil? || guidance_gr.optional_subset == false then%>
+ <%= _('No')%>
+ <% else %>
+ <%= _('Yes')%>
+ <% end %>
+ |
+
+
+ <%= l guidance_gr.updated_at.to_date, formats: :short %>
+ |
+
+ <%= link_to _('Edit'), admin_edit_guidance_group_path(guidance_gr), class: "dmp_table_link"%> |
+ + <%= link_to _('Delete'), admin_destroy_guidance_group_path(guidance_gr), data: {confirm: _("You are about to delete '%{guidance_group_name}'. This will affect guidance. Are you sure?") % { :guidance_group_name => guidance_gr.name }}, method: :delete, class: "dmp_table_link"%> + |
+ <%= _('You can write pieces of guidance to be displayed by theme (e.g. generic guidance on storage and backup that should present across the board). Writing generic guidance by theme saves you time and effort as your advice will be automatically displayed across all templates rather than having to write guidance to accompany each.') %> +
++ <%= _('If you do have a need to provide guidance for specific funders that would not be useful to a wider audience (e.g. if you have specific instructions for applicants to BBSRC for example), you can do so by adding guidance to a specific question when you edit your template.') %> +
+ + + <% if @guidances.length > 0 then%> +| + <%= render(partial: "shared/table_filter", + locals: {path: admin_index_guidance_path, + placeholder: _('Filter guidance')}) %> + | +||||||
| <%= _('Text') %> | +<%= _('Themes') %> | +<%= _('Guidance group') %> | +<%= _('Last updated') %> | +<%= _('Actions') %> + | ||
|---|---|---|---|---|---|---|
| + <%= guidance.text.html_safe%> + | + <% if guidance.themes.present? then %> ++ <% guidance.themes.each do |th| %> + <%= th.title %> + <% end %> + | + <% else %> ++ - + | + <% end %> + <% if guidance.guidance_group.present? then %> ++ <%= guidance.guidance_group.name %> + | + <% else %> ++ - + | + <% end %> ++ <%= l guidance.updated_at.to_date, formats: :short %> + | +
+ <%= link_to _('Edit'), admin_edit_guidance_path(guidance), class: "dmp_table_link"%> + <%= link_to _('Delete'), admin_destroy_guidance_path(guidance), + data: {confirm: _("You are about to delete '%{guidance_summary}'. Are you sure?") % { :guidance_summary => truncate(sanitize(guidance.text,tags: %w(br a)), length: 20 , omission: _('... (continued)'))} }, method: :delete, class: "dmp_table_link"%> + |
+
| <%= _('Text') %> | -
-
- <%= text_area_tag("guidance-text", "", class: "tinymce") %>
-
-
- <%= link_to( image_tag('help_button.png'), '#', class: 'guidance_text_popover', rel: "popover", 'data-html' => "true", 'data-content' => _('Enter your guidance here. You can include links where needed.'))%>
-
-
- |
-
| <%= _('Themes') %> | -
-
-
-
-
- <%= f.collection_select(:theme_ids, @themes,
- :id, :title, {prompt: false, include_blank: 'None'}, {multiple: true})%>
-
-
- <%= link_to( image_tag('help_button.png'), '#', class: 'guidance_by_themes_popover', rel: "popover", 'data-html' => "true", 'data-content' => _('Select which theme(s) this guidance relates to.'))%>
-
-
- |
-
| <%= _('Published') %> | -
- <%= f.check_box :published , as: :check_boxes%>
-
-
- <%= link_to( image_tag('help_button.png'), '#', class: 'guidance_group_subset_popover', rel: "popover", 'data-html' => "true", 'data-content' => _("Check this box when you are ready for this guidance to appear on user's plans."))%>
-
- |
-
| <%= _('Guidance group') %> | -
- <%= f.collection_select(:guidance_group_id, @guidance_groups,
- :id, :name, {prompt: false, include_blank: 'None'}, {multiple: false})%>
-
-
- <%= link_to( image_tag('help_button.png'), '#', class: 'guidance_group_select_popover', rel: "popover", 'data-html' => "true", 'data-content' => _('Select which group this guidance relates to.'))%>
-
-
-
- |
-