From 9cdd38bc5f4a6d68ea1e8881956c492e28983d5d Mon Sep 17 00:00:00 2001 From: pengyin-shan Date: Fri, 8 Apr 2022 17:20:42 -0400 Subject: [PATCH 01/16] fix collapse function in org_admin -> template creation -> section creation --- app/javascript/src/utils/accordion.js | 10 ++++++---- app/views/org_admin/sections/_section.html.erb | 2 +- app/views/org_admin/sections/_section_group.html.erb | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/javascript/src/utils/accordion.js b/app/javascript/src/utils/accordion.js index d80ee9c5ee..253893bbd9 100644 --- a/app/javascript/src/utils/accordion.js +++ b/app/javascript/src/utils/accordion.js @@ -31,21 +31,23 @@ * */ $(() => { - $('body').on('click', '.accordion-controls', (e) => { + $('body').on('click', '.accordion-controls a', (e) => { e.preventDefault(); const currentTarget = $(e.currentTarget); const target = $(e.target); const direction = target.attr('data-toggle-direction'); + const parentTargetName = currentTarget.parent().attr('data-parent'); if (direction) { // Selects all .panel elements where the parent is currentTarget.attr('data-parent') and // after gets the immediately children whose class selector is panel-collapse - $(`#${currentTarget.attr('data-parent')} > .panel`).children('.panel-collapse').each((i, el) => { + const parentTarget = $(`#${parentTargetName}`).length ? $(`#${parentTargetName}`) : $(`.${parentTargetName}`); + $(parentTarget).find('.panel').find('.panel-collapse').each((i, el) => { const panelCollapse = $(el); // Expands or collapses the panel according to the // direction passed (e.g. show --> expands, hide --> collapses) if (direction === 'show') { - if (!panelCollapse.hasClass('in')) { - panelCollapse.prev().trigger('click'); + if (!panelCollapse.find('.panel-body').attr('data-loaded') || !panelCollapse.hasClass('in')) { + panelCollapse.prev()[0].click(); } } else { panelCollapse.collapse(direction); diff --git a/app/views/org_admin/sections/_section.html.erb b/app/views/org_admin/sections/_section.html.erb index ca7062ca7f..cb56aa07b2 100644 --- a/app/views/org_admin/sections/_section.html.erb +++ b/app/views/org_admin/sections/_section.html.erb @@ -46,4 +46,4 @@ <% end %> - + \ No newline at end of file diff --git a/app/views/org_admin/sections/_section_group.html.erb b/app/views/org_admin/sections/_section_group.html.erb index 4623c019b0..37a960ab59 100644 --- a/app/views/org_admin/sections/_section_group.html.erb +++ b/app/views/org_admin/sections/_section_group.html.erb @@ -1,5 +1,5 @@ -
@@ -12,4 +12,4 @@ data_parent: panel_id, draggable: draggable_for_section?(section) } %> <% end%> -
+ \ No newline at end of file From b4b4cfa04236e54e4ccfd789f05408e637ab3294 Mon Sep 17 00:00:00 2001 From: John Pinto Date: Wed, 13 Apr 2022 11:21:37 +0100 Subject: [PATCH 02/16] DCC Bug 698 - Fix for broken Template History functionality. DCC Issue https://github.com/DigitalCurationCentre/DMPonline-Service/issues/698 Changes: - added format: json and changed sort option to sort_field: 'templates.version', sort_direction: :desc to the paginable_renderise call in the history() method of paginable/templates_controller. --- app/controllers/paginable/templates_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/paginable/templates_controller.rb b/app/controllers/paginable/templates_controller.rb index 5ea6b552e8..4456ffa00b 100644 --- a/app/controllers/paginable/templates_controller.rb +++ b/app/controllers/paginable/templates_controller.rb @@ -105,8 +105,9 @@ def history paginable_renderise( partial: 'history', scope: @templates, - query_params: { sort_field: 'templates.title', sort_direction: :asc }, - locals: { current: @templates.maximum(:version) } + query_params: { sort_field: 'templates.version', sort_direction: :desc }, + locals: { current: @templates.maximum(:version) }, + format: :json ) end end From fa86f8ecaa8035192a22f73b2b7a0cedc322d420 Mon Sep 17 00:00:00 2001 From: John Pinto Date: Wed, 13 Apr 2022 12:45:33 +0100 Subject: [PATCH 03/16] Referenced in DCC Bug 698 - The School departments functionality broken. Referenced in a comment in DCC bug 698 https://github.com/DigitalCurationCentre/DMPonline-Service/issues/698#issuecomment-1096577463 Fix involved following change: - in app/policies/department_policy the index?() policy method reference @department (which does not exist). Even changing @department to @record fails as @record is the Department class (not an instance of Department). Inspect of @record in index?() shows "Department(id: integer, name: string, code: string, org_id: integer, created_at: datetime, updated_at: datetime)". So replaced (@user.can_org_admin? && @user.org.id == @department.org_id) || @user.can_super_admin? by @user.can_org_admin? || @user.can_super_admin? as @department is nil and @record.org_id id not defined for a Class object Department. --- app/policies/department_policy.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/policies/department_policy.rb b/app/policies/department_policy.rb index 95018eb5cf..ed98bbf3ce 100644 --- a/app/policies/department_policy.rb +++ b/app/policies/department_policy.rb @@ -6,8 +6,7 @@ class DepartmentPolicy < ApplicationPolicy # NOTE: @user is the signed_in_user and @record is an instance of Department def index? - (@user.can_org_admin? && @user.org.id == @department.org_id) || - @user.can_super_admin? + @user.can_org_admin? || @user.can_super_admin? end def new? From b61b670630b9e98efdaecba96621be8d2a0975da Mon Sep 17 00:00:00 2001 From: briri Date: Wed, 13 Apr 2022 09:42:45 -0700 Subject: [PATCH 04/16] remove margin settings from PDF stylesheet and set initial zoom level on wicked_pdf --- app/controllers/plan_exports_controller.rb | 3 +++ app/views/shared/export/_plan_styling.erb | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/plan_exports_controller.rb b/app/controllers/plan_exports_controller.rb index 41edc38212..46bcbef953 100644 --- a/app/controllers/plan_exports_controller.rb +++ b/app/controllers/plan_exports_controller.rb @@ -85,6 +85,9 @@ def show_docx def show_pdf render pdf: file_name, margin: @formatting[:margin], + # wkhtmltopdf behavior is based on the OS so force the zoom level + # See 'Gotchas' section of https://github.com/mileszs/wicked_pdf + zoom: 0.78125, footer: { center: format(_('Created using %{application_name}. Last modified %{date}'), application_name: ApplicationService.application_name, diff --git a/app/views/shared/export/_plan_styling.erb b/app/views/shared/export/_plan_styling.erb index 4eda615477..87dd494487 100644 --- a/app/views/shared/export/_plan_styling.erb +++ b/app/views/shared/export/_plan_styling.erb @@ -4,7 +4,6 @@ body { font-family: @font-face; font-size: <%= font_size %>; - margin: <%= margin %>; } h1 { font-size: 1.5rem; From d1a073aba0884a14801dbfffe94d107c1f7e57f6 Mon Sep 17 00:00:00 2001 From: John Pinto Date: Thu, 14 Apr 2022 11:17:52 +0100 Subject: [PATCH 05/16] DCC bug 406 - Download plan with coversheet is broken. DCC issue https://github.com/DigitalCurationCentre/DMPonline-Service/issues/703 Problem is that in concerns/exportable_plan.rb the method prepare_coversheet_for_csv(csv, _headings, hash) assumes hash[:attribution] is an ActiveRecord::Relation when it is always a string with a single author created in prepare_coversheet() method. Hence hash[:attribution].many? throws an error in csv << [if hash[:attribution].many?. Changes for fix: - in prepare_coversheet_for_csv(csv, _headings, hash) added csv << [_('Creator:'), format(_('%{author}'), author: hash[:attribution])] instead and removed csv << [if hash[:attribution].many?...] --- app/models/concerns/exportable_plan.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/models/concerns/exportable_plan.rb b/app/models/concerns/exportable_plan.rb index 0e39130a5a..c4df5fca17 100644 --- a/app/models/concerns/exportable_plan.rb +++ b/app/models/concerns/exportable_plan.rb @@ -133,13 +133,9 @@ def prepare_coversheet # rubocop:enable Metrics/AbcSize # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity - # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity + # rubocop:disable Metrics/MethodLength, Metrics/AbcSize def prepare_coversheet_for_csv(csv, _headings, hash) - csv << [if hash[:attribution].many? - _('Creators: ') - else - _('Creator:') - end, format(_('%{authors}'), authors: hash[:attribution].join(', '))] + csv << [_('Creator:'), format(_('%{author}'), author: hash[:attribution])] csv << ['Affiliation: ', format(_('%{affiliation}'), affiliation: hash[:affiliation])] csv << if hash[:funder].present? [_('Template: '), format(_('%{funder}'), funder: hash[:funder])] @@ -161,7 +157,7 @@ def prepare_coversheet_for_csv(csv, _headings, hash) csv << [] csv << [] end - # rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity + # rubocop:enable Metrics/MethodLength, Metrics/AbcSize # rubocop:disable Metrics/AbcSize, Metrics/BlockLength, Metrics/MethodLength # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity From 21e36b4bf53d6d9e255478e7417d7c8741250b63 Mon Sep 17 00:00:00 2001 From: John Pinto Date: Tue, 19 Apr 2022 15:05:08 +0100 Subject: [PATCH 06/16] DCC bug 722 - Fix for dealing with situation where Rest API call "/api/v0/plans?page=ALL" was timing out because the processing was taking too long. Fix for bug https://github.com/DigitalCurationCentre/DMPonline-Service/issues/722 The following change seems to make a difference: - in /api/v0/plans_controller.rb the index() method replaced includes() with preload(): @plans = org_admin_plans.includes([{ roles: :user }, { answers: :question_options }, template: [{ phases: { sections: { questions: %i[question_format themes] } } }, :org]]) --- app/controllers/api/v0/plans_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v0/plans_controller.rb b/app/controllers/api/v0/plans_controller.rb index f81c0e7f68..374d5401d9 100644 --- a/app/controllers/api/v0/plans_controller.rb +++ b/app/controllers/api/v0/plans_controller.rb @@ -73,10 +73,10 @@ def index # Get all the Org Admin plans org_admin_plans = @user.org.org_admin_plans - @plans = org_admin_plans.includes([{ roles: :user }, { answers: :question_options }, - template: [{ phases: { - sections: { questions: %i[question_format themes] } - } }, :org]]) + @plans = org_admin_plans.preload([{ roles: :user }, { answers: :question_options }, + template: [{ phases: { + sections: { questions: %i[question_format themes] } + } }, :org]]) # Filter on list of users user_ids = extract_param_list(params, 'user') From e7a6d4a8ef31336aaa645ee2dba43e7c29283f9b Mon Sep 17 00:00:00 2001 From: John Pinto Date: Wed, 27 Apr 2022 15:00:30 +0100 Subject: [PATCH 07/16] Roadmap bug #3163 - Fix for bug "Conditional question causing plans to disappear." Cause is commit bb5941e5d8998ba142be014c35bdb964f4fd86c5 "Added toggleable guidance/comments section" the following changes were made to file app/javascript/src/utils/sectionUpdate.js: the question containers classes were changed as follows .row -> .question-body & .col-md-8 -> .question-section: -
-
+
+
This broke the function getQuestionDiv() in app/javascript/src/utils/sectionUpdate.js. Fix for issue #3163. Changes: - in app/javascript/src/utils/sectionUpdate.js the function was updated as follows: -export const getQuestionDiv = (id) => $(`#answer-form-${id}`).closest('.row'); +export const getQuestionDiv = (id) => $(`#answer-form-${id}`).closest('.question-body'); --- app/javascript/src/utils/sectionUpdate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/src/utils/sectionUpdate.js b/app/javascript/src/utils/sectionUpdate.js index 5e470b2de2..d31ce3331a 100644 --- a/app/javascript/src/utils/sectionUpdate.js +++ b/app/javascript/src/utils/sectionUpdate.js @@ -19,4 +19,4 @@ export const updateSectionProgress = (id, numSecAnswers, numSecQuestions) => { // given a question id find the containing div // used inconditional questions -export const getQuestionDiv = (id) => $(`#answer-form-${id}`).closest('.row'); +export const getQuestionDiv = (id) => $(`#answer-form-${id}`).closest('.question-body'); From b16990e762298ff117ca3c9b5bf8d41ba489f711 Mon Sep 17 00:00:00 2001 From: pengyin-shan Date: Wed, 27 Apr 2022 16:57:44 -0400 Subject: [PATCH 08/16] fix font face of pdf download --- app/views/plans/_download_form.html.erb | 2 +- app/views/shared/export/_plan_styling.erb | 6 +++--- config/locales/localization.en-CA.yml | 14 ++++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/views/plans/_download_form.html.erb b/app/views/plans/_download_form.html.erb index d4fe9fae91..b9cb41799c 100644 --- a/app/views/plans/_download_form.html.erb +++ b/app/views/plans/_download_form.html.erb @@ -119,7 +119,7 @@ options_for_select(Settings::Template::VALID_MARGIN_RANGE.to_a, @export_settings.formatting[:margin][:right]), class: 'form-control', - "data-default": @plan.template.settings(:export).formatting[:margin][:rigth] %> + "data-default": @plan.template.settings(:export).formatting[:margin][:right] %>
diff --git a/app/views/shared/export/_plan_styling.erb b/app/views/shared/export/_plan_styling.erb index 4eda615477..4f9a3ec200 100644 --- a/app/views/shared/export/_plan_styling.erb +++ b/app/views/shared/export/_plan_styling.erb @@ -2,11 +2,11 @@ @import 'https://fonts.googleapis.com/css?family=<%= font_face.downcase.include?('times') ? 'Times' : 'Helvetica' %>'; body { - font-family: @font-face; + font-family: <%= font_face %>; font-size: <%= font_size %>; margin: <%= margin %>; } - h1 { + h1 { font-size: 1.5rem; font-weight: bold; padding: 0; @@ -59,5 +59,5 @@ } .bold { font-weight: bold; - } + } \ No newline at end of file diff --git a/config/locales/localization.en-CA.yml b/config/locales/localization.en-CA.yml index bdd7f16661..c176fa139c 100644 --- a/config/locales/localization.en-CA.yml +++ b/config/locales/localization.en-CA.yml @@ -14,12 +14,14 @@ en-CA: date: formats: default: "%d-%m-%Y" - long: "%B %d, %Y" + long: "%d %B, %Y" short: "%d %b" + csv: "%d/%m/%Y" + readable: "%B %d, %Y" order: - - :year - - :month - :day + - :month + - :year number: currency: format: @@ -62,6 +64,6 @@ en-CA: words_connector: ", " time: formats: - default: "%a, %d %b %Y %I:%M:%S %p %Z" - long: "%B %d, %Y %I:%M %p" - short: "%d %b %I:%M %p" + default: "%a, %d %b %Y %H:%M:%S %z" + long: "%d %B, %Y %H:%M" + short: "%d %b %H:%M" From e4df90a6b432ae198ed40f4c5bf9c91fb74d97bd Mon Sep 17 00:00:00 2001 From: pengyin-shan Date: Mon, 2 May 2022 16:02:14 -0400 Subject: [PATCH 09/16] update change in development branch --- app/models/concerns/exportable_plan.rb | 7 ++++++- app/views/shared/export/_plan_txt.erb | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/exportable_plan.rb b/app/models/concerns/exportable_plan.rb index c4df5fca17..4dc9bd35bc 100644 --- a/app/models/concerns/exportable_plan.rb +++ b/app/models/concerns/exportable_plan.rb @@ -135,7 +135,12 @@ def prepare_coversheet # rubocop:disable Metrics/MethodLength, Metrics/AbcSize def prepare_coversheet_for_csv(csv, _headings, hash) - csv << [_('Creator:'), format(_('%{author}'), author: hash[:attribution])] + ## csv << [_('Creator:'), format(_('%{author}'), author: hash[:attribution])] + if Array(hash[:attribution]).many? + csv << [_('Creators: '), format(_('%{authors}'), authors: Array(hash[:attribution]).join(', '))] + else + csv << [ _('Creator:'), format(_('%{authors}'), authors: hash[:attribution])] + end csv << ['Affiliation: ', format(_('%{affiliation}'), affiliation: hash[:affiliation])] csv << if hash[:funder].present? [_('Template: '), format(_('%{funder}'), funder: hash[:funder])] diff --git a/app/views/shared/export/_plan_txt.erb b/app/views/shared/export/_plan_txt.erb index 32f83e8303..ce479c16cd 100644 --- a/app/views/shared/export/_plan_txt.erb +++ b/app/views/shared/export/_plan_txt.erb @@ -1,7 +1,7 @@ <%= "#{@plan.title}" %> <%= "----------------------------------------------------------\n" %> <% if @show_coversheet %> -<%= @hash[:attribution].length > 1 ? _("Creators: ") : _('Creator:') %> <%= @hash[:attribution].join(', ') %> +<%= Array(@hash[:attribution]).many? ? _("Creators: ") + Array(@hash[:attribution]).join(", ") : _('Creator:') + @hash[:attribution] %> <%= _("Affiliation: ") + @hash[:affiliation] %> <% if @hash[:funder].present? %> <%= _("Template: ") + @hash[:funder] %> From 72f670ca670240db7e5de51a82364beacff4a795 Mon Sep 17 00:00:00 2001 From: pengyin-shan Date: Mon, 2 May 2022 16:05:39 -0400 Subject: [PATCH 10/16] remove commented line --- app/models/concerns/exportable_plan.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/concerns/exportable_plan.rb b/app/models/concerns/exportable_plan.rb index 4dc9bd35bc..24885ad986 100644 --- a/app/models/concerns/exportable_plan.rb +++ b/app/models/concerns/exportable_plan.rb @@ -135,7 +135,6 @@ def prepare_coversheet # rubocop:disable Metrics/MethodLength, Metrics/AbcSize def prepare_coversheet_for_csv(csv, _headings, hash) - ## csv << [_('Creator:'), format(_('%{author}'), author: hash[:attribution])] if Array(hash[:attribution]).many? csv << [_('Creators: '), format(_('%{authors}'), authors: Array(hash[:attribution]).join(', '))] else From 7b4f8995eaa7e7584d2404258ebc28b4a2aa086f Mon Sep 17 00:00:00 2001 From: pengyin-shan Date: Mon, 2 May 2022 16:15:13 -0400 Subject: [PATCH 11/16] fix rubocop issue --- app/models/concerns/exportable_plan.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/concerns/exportable_plan.rb b/app/models/concerns/exportable_plan.rb index 24885ad986..c625fec5a4 100644 --- a/app/models/concerns/exportable_plan.rb +++ b/app/models/concerns/exportable_plan.rb @@ -135,11 +135,11 @@ def prepare_coversheet # rubocop:disable Metrics/MethodLength, Metrics/AbcSize def prepare_coversheet_for_csv(csv, _headings, hash) - if Array(hash[:attribution]).many? - csv << [_('Creators: '), format(_('%{authors}'), authors: Array(hash[:attribution]).join(', '))] - else - csv << [ _('Creator:'), format(_('%{authors}'), authors: hash[:attribution])] - end + csv << if Array(hash[:attribution]).many? + [_('Creators: '), format(_('%{authors}'), authors: Array(hash[:attribution]).join(', '))] + else + [ _('Creator:'), format(_('%{authors}'), authors: hash[:attribution])] + end csv << ['Affiliation: ', format(_('%{affiliation}'), affiliation: hash[:affiliation])] csv << if hash[:funder].present? [_('Template: '), format(_('%{funder}'), funder: hash[:funder])] From 0e4237d1bcd7290bdf855a8e133e5e08acd3d043 Mon Sep 17 00:00:00 2001 From: pengyin-shan Date: Mon, 2 May 2022 16:26:24 -0400 Subject: [PATCH 12/16] auto-correct rubocop issue --- app/models/concerns/exportable_plan.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/concerns/exportable_plan.rb b/app/models/concerns/exportable_plan.rb index c625fec5a4..89868c5062 100644 --- a/app/models/concerns/exportable_plan.rb +++ b/app/models/concerns/exportable_plan.rb @@ -135,11 +135,11 @@ def prepare_coversheet # rubocop:disable Metrics/MethodLength, Metrics/AbcSize def prepare_coversheet_for_csv(csv, _headings, hash) - csv << if Array(hash[:attribution]).many? - [_('Creators: '), format(_('%{authors}'), authors: Array(hash[:attribution]).join(', '))] - else - [ _('Creator:'), format(_('%{authors}'), authors: hash[:attribution])] - end + csv << if Array(hash[:attribution]).many? + [_('Creators: '), format(_('%{authors}'), authors: Array(hash[:attribution]).join(', '))] + else + [_('Creator:'), format(_('%{authors}'), authors: hash[:attribution])] + end csv << ['Affiliation: ', format(_('%{affiliation}'), affiliation: hash[:affiliation])] csv << if hash[:funder].present? [_('Template: '), format(_('%{funder}'), funder: hash[:funder])] From ca859e7ac6906d19765ced4941d9bc8e220dae1d Mon Sep 17 00:00:00 2001 From: pengyin-shan Date: Mon, 2 May 2022 17:19:51 -0400 Subject: [PATCH 13/16] disable rubocop complexity check --- app/models/concerns/exportable_plan.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/models/concerns/exportable_plan.rb b/app/models/concerns/exportable_plan.rb index 89868c5062..b106db3a7a 100644 --- a/app/models/concerns/exportable_plan.rb +++ b/app/models/concerns/exportable_plan.rb @@ -131,7 +131,6 @@ def prepare_coversheet hash end # rubocop:enable Metrics/AbcSize - # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity # rubocop:disable Metrics/MethodLength, Metrics/AbcSize def prepare_coversheet_for_csv(csv, _headings, hash) @@ -164,7 +163,6 @@ def prepare_coversheet_for_csv(csv, _headings, hash) # rubocop:enable Metrics/MethodLength, Metrics/AbcSize # rubocop:disable Metrics/AbcSize, Metrics/BlockLength, Metrics/MethodLength - # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity # rubocop:disable Metrics/ParameterLists def show_section_for_csv(csv, phase, section, headings, unanswered, hash) section[:questions].each do |question| From 5a372e872ab98c287de5055c6e3f60b892df3103 Mon Sep 17 00:00:00 2001 From: John Pinto Date: Tue, 3 May 2022 11:47:07 +0100 Subject: [PATCH 14/16] Bug #3104 - Fix for pre-ticked answers do not appear in Template download. Fix for Roadmap issue #3104. Changes: - added <%= option.is_default? ? ' - ' + _('default') : '' %> to option text in export template in docx and pdf. --- app/views/template_exports/template_export.docx.erb | 2 +- app/views/template_exports/template_export.pdf.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/template_exports/template_export.docx.erb b/app/views/template_exports/template_export.docx.erb index 77de02ac05..3448fa4b7a 100644 --- a/app/views/template_exports/template_export.docx.erb +++ b/app/views/template_exports/template_export.docx.erb @@ -26,7 +26,7 @@ <% if q_format.option_based? %>
    <% question.question_options.each do |option| %> -
  • <%= option.text.chomp.strip %>
  • +
  • <%= option.text.chomp.strip %><%= option.is_default? ? ' - ' + _('default') : '' %>
  • <% end %>
<% end %> diff --git a/app/views/template_exports/template_export.pdf.erb b/app/views/template_exports/template_export.pdf.erb index be138d642d..55fcbe0763 100644 --- a/app/views/template_exports/template_export.pdf.erb +++ b/app/views/template_exports/template_export.pdf.erb @@ -70,7 +70,7 @@ <% if q_format.option_based? %>
    <% question.question_options.each do |option| %> -
  • <%= option.text.chomp.strip %>
  • +
  • <%= option.text.chomp.strip %><%= option.is_default? ? ' - ' + _('default') : '' %>
  • <% end %>
<% end %> From b5295cb3f988a4efaba05d3e5eba141020831eee Mon Sep 17 00:00:00 2001 From: Nicolas Franck Date: Tue, 10 May 2022 12:03:57 +0200 Subject: [PATCH 15/16] metadata standard does not always have locations --- .../research_outputs/metadata_standards/_search_result.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/research_outputs/metadata_standards/_search_result.html.erb b/app/views/research_outputs/metadata_standards/_search_result.html.erb index 099223e4ac..9d8ed5e102 100644 --- a/app/views/research_outputs/metadata_standards/_search_result.html.erb +++ b/app/views/research_outputs/metadata_standards/_search_result.html.erb @@ -5,7 +5,7 @@

<%= sanitize(result.description) %>

- <% website = result.locations.select { |loc| loc["type"] == "website" }.first %> + <% website = result&.locations&.select { |loc| loc["type"] == "website" }&.first %> <% if website.present? %>
<%= link_to website["url"], website["url"], target: "_blank", class: "has-new-window-popup-info" %> From 7031205ef1f487058aa9a15c08574b653b1d289a Mon Sep 17 00:00:00 2001 From: John Pinto Date: Tue, 10 May 2022 11:43:22 +0100 Subject: [PATCH 16/16] Roadmap bug 3086 - The share feature for Org plan visibility was broken: one could only share plan if it is 100% completed. When this is set in property config/initializers/_dmproadmap.rb, e.g., 188: config.x.plans.default_percentage_answered = 50. Fix for Roadmap bug #3086. In app/models/phase.rb method visibility_allowed?(plan) is broken because the first line in method always return 0 unless the Rational() is 1 in value = Rational(num_answered_questions(plan), plan.num_questions) * 100 Change: - we fix issue by converting the Rational() value to a float as follows value = Rational(num_answered_questions(plan), plan.num_questions).to_f * 100 --- app/models/phase.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/phase.rb b/app/models/phase.rb index 7b466b68b0..9dfd1b11cd 100644 --- a/app/models/phase.rb +++ b/app/models/phase.rb @@ -139,7 +139,7 @@ def num_answers_not_removed(plan) end def visibility_allowed?(plan) - value = Rational(num_answered_questions(plan), plan.num_questions) * 100 + value = Rational(num_answered_questions(plan), plan.num_questions).to_f * 100 value >= Rails.configuration.x.plans.default_percentage_answered.to_f end end