From c6f3371fbce0a0f8ba880c96b52d3290e8246cab Mon Sep 17 00:00:00 2001 From: j-corry Date: Mon, 25 Nov 2024 10:23:39 +0000 Subject: [PATCH 1/3] - Update EDM prelim sentence, removing other sponsors and changing to 'tabled' by --- app/views/search/preliminary_sentences/_edm.haml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/views/search/preliminary_sentences/_edm.haml b/app/views/search/preliminary_sentences/_edm.haml index 64dc14d..bc65cbf 100644 --- a/app/views/search/preliminary_sentences/_edm.haml +++ b/app/views/search/preliminary_sentences/_edm.haml @@ -2,12 +2,8 @@ .content-prelim-inner .content-prelim-text#prelim-text %span>= object_display_name_link(object.object_name) - - unless object.primary_sponsor.blank? && object.other_sponsors.blank? - %span=" sponsored by " - - if object.primary_sponsor.blank? - %span= render 'search/fragments/list', items: object.other_sponsors, terminator: '', singular: false - %span= " and " - - else object.primary_sponsor.blank? + - unless object.primary_sponsor.blank? + %span=" tabled by " %span>= search_link(object.primary_sponsor) - if object.primary_sponsor_party.blank? %span= " (primary sponsor)" @@ -15,8 +11,6 @@ %span= " (primary sponsor, " %span>= render 'search/fragments/list', items: object.primary_sponsor_party, terminator: '', singular: false %span= ")" - - unless object.other_sponsors.blank? - %span>= render 'search/fragments/edm_sponsor_list', items: object.other_sponsors, terminator: '', singular: false %span= " and " %span= " tabled on " %span>= format_date(object.date_tabled) From c709bf72d8d23b545ad29f06b7cfe4d80ff13d3a Mon Sep 17 00:00:00 2001 From: j-corry Date: Mon, 25 Nov 2024 11:43:28 +0000 Subject: [PATCH 2/3] - Show category_ses for research breifing type, with subtype_ses as a fallback - Add a 'category or subtype' partial to handle research briefing 'type' in results (required due to difference in singularisation depending on which data ends up being used) --- app/models/research_briefing.rb | 4 ++++ .../search/results/_research_briefing.html.erb | 2 +- .../results/item_details/_category_or_subtype.haml | 13 +++++++++++++ ...pe_and_type.html.haml => _subtype_and_type.haml} | 0 ...type_or_type.html.haml => _subtype_or_type.haml} | 0 5 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 app/views/search/results/item_details/_category_or_subtype.haml rename app/views/search/results/item_details/{_subtype_and_type.html.haml => _subtype_and_type.haml} (100%) rename app/views/search/results/item_details/{_subtype_or_type.html.haml => _subtype_or_type.haml} (100%) diff --git a/app/models/research_briefing.rb b/app/models/research_briefing.rb index f767d8c..49a2bc5 100644 --- a/app/models/research_briefing.rb +++ b/app/models/research_briefing.rb @@ -40,6 +40,10 @@ def series get_first_from('category_ses') end + def category + get_first_from('category_ses') + end + def creator_party get_first_from('creatorParty_ses') end diff --git a/app/views/search/results/_research_briefing.html.erb b/app/views/search/results/_research_briefing.html.erb index dcd137f..38675ec 100644 --- a/app/views/search/results/_research_briefing.html.erb +++ b/app/views/search/results/_research_briefing.html.erb @@ -25,7 +25,7 @@
- <%= render 'search/results/item_details/type', type: object.object_name %> + <%= render 'search/results/item_details/category_or_subtype', category: object.category, subtype: object.subtype %>
diff --git a/app/views/search/results/item_details/_category_or_subtype.haml b/app/views/search/results/item_details/_category_or_subtype.haml new file mode 100644 index 0000000..d7aba6a --- /dev/null +++ b/app/views/search/results/item_details/_category_or_subtype.haml @@ -0,0 +1,13 @@ +- unless category.blank? && subtype.blank? + %div.item-details + %div.item-details-label= "Type" + - unless category.blank? + - if category.is_a?(Array) + = render 'search/fragments/simple_list', items: category, separator: ';', terminator: '', singular: false + - else + = object_display_name(category, singular: false) + - if category.blank? + - if subtype.is_a?(Array) + = render 'search/fragments/simple_list', items: subtype, separator: ';', terminator: '', singular: false + - else + = object_display_name(subtype, singular: true) \ No newline at end of file diff --git a/app/views/search/results/item_details/_subtype_and_type.html.haml b/app/views/search/results/item_details/_subtype_and_type.haml similarity index 100% rename from app/views/search/results/item_details/_subtype_and_type.html.haml rename to app/views/search/results/item_details/_subtype_and_type.haml diff --git a/app/views/search/results/item_details/_subtype_or_type.html.haml b/app/views/search/results/item_details/_subtype_or_type.haml similarity index 100% rename from app/views/search/results/item_details/_subtype_or_type.html.haml rename to app/views/search/results/item_details/_subtype_or_type.haml From 0719b9d0cba085bc321f15770574b344f03d98db Mon Sep 17 00:00:00 2001 From: j-corry Date: Mon, 25 Nov 2024 12:09:26 +0000 Subject: [PATCH 3/3] - Apply Nokogiri-based html formatting to all truncated fields throughout the app, to fix and instance where unclosed html tags were causing issues with a research briefing --- app/views/search/results/item_details/_abstract.html.erb | 2 +- .../results/item_details/_contribution_text.html.erb | 2 +- .../search/results/item_details/_correction_text.html.erb | 2 +- .../search/results/item_details/_description.html.erb | 8 ++++---- .../search/results/item_details/_motion_text.html.erb | 2 +- .../search/results/item_details/_petition_text.html.erb | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/search/results/item_details/_abstract.html.erb b/app/views/search/results/item_details/_abstract.html.erb index 04c86e9..a2a0d4a 100644 --- a/app/views/search/results/item_details/_abstract.html.erb +++ b/app/views/search/results/item_details/_abstract.html.erb @@ -1,7 +1,7 @@ <% unless abstract.blank? %>
- <%= raw abstract[:value].truncate_words(50) %> + <%= raw format_html(abstract[:value], 50) %>
<% end %> \ No newline at end of file diff --git a/app/views/search/results/item_details/_contribution_text.html.erb b/app/views/search/results/item_details/_contribution_text.html.erb index 26f82a9..3ed3ec6 100644 --- a/app/views/search/results/item_details/_contribution_text.html.erb +++ b/app/views/search/results/item_details/_contribution_text.html.erb @@ -1,7 +1,7 @@ <% unless contribution_text.blank? %>
- <%= raw contribution_text[:value].truncate_words(50) %> + <%= raw format_html(contribution_text[:value], 50) %>
<% end %> \ No newline at end of file diff --git a/app/views/search/results/item_details/_correction_text.html.erb b/app/views/search/results/item_details/_correction_text.html.erb index 72b2856..2e54982 100644 --- a/app/views/search/results/item_details/_correction_text.html.erb +++ b/app/views/search/results/item_details/_correction_text.html.erb @@ -1,7 +1,7 @@ <% unless correction_text.blank? %>
- <%= raw correction_text[:value].truncate_words(50) %> + <%= raw format_html(correction_text[:value], 50) %>
<% end %> \ No newline at end of file diff --git a/app/views/search/results/item_details/_description.html.erb b/app/views/search/results/item_details/_description.html.erb index 1ad0b1d..a228277 100644 --- a/app/views/search/results/item_details/_description.html.erb +++ b/app/views/search/results/item_details/_description.html.erb @@ -2,10 +2,10 @@
<% if full_text == true %> - <%= raw description[:value] %> - <% else %> - <%= raw description[:value].truncate_words(50) %> - <% end %> + <%= raw format_html(description[:value], false) %> + <% else %> + <%= raw format_html(description[:value], 50) %> + <% end %>
<% end %> \ No newline at end of file diff --git a/app/views/search/results/item_details/_motion_text.html.erb b/app/views/search/results/item_details/_motion_text.html.erb index bca93f4..68dc4fa 100644 --- a/app/views/search/results/item_details/_motion_text.html.erb +++ b/app/views/search/results/item_details/_motion_text.html.erb @@ -1,7 +1,7 @@ <% unless motion_text.blank? %>
- <%= raw motion_text[:value].truncate_words(50) %> + <%= raw format_html(motion_text[:value], 50) %>
<% end %> \ No newline at end of file diff --git a/app/views/search/results/item_details/_petition_text.html.erb b/app/views/search/results/item_details/_petition_text.html.erb index 2166da4..2244496 100644 --- a/app/views/search/results/item_details/_petition_text.html.erb +++ b/app/views/search/results/item_details/_petition_text.html.erb @@ -1,7 +1,7 @@ <% unless petition_text.blank? %>
- <%= raw petition_text[:value]&.truncate_words(50) %> + <%= raw format_html(petition_text[:value], 50) %>
<% end %> \ No newline at end of file