Skip to content

Commit

Permalink
Merge pull request #5 from ukparliament/development
Browse files Browse the repository at this point in the history
Development merge
  • Loading branch information
j-corry authored Aug 14, 2023
2 parents 8c1ae7b + 362ee20 commit d61733a
Show file tree
Hide file tree
Showing 19 changed files with 535 additions and 350 deletions.
311 changes: 140 additions & 171 deletions app/assets/stylesheets/primary.css

Large diffs are not rendered by default.

83 changes: 83 additions & 0 deletions app/models/edm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,83 @@ def template
'search/objects/edm'
end

def amendments
# number of signatures won't necessarily match - need to confirm how to handle missing data
# initial suggestion is that where missing, use the previous one (as that seems to be why they're missing)

# Title is the title of the motion itself, with 'Amendment N' on the front
# Reference is taken from identifier_t, after removing the first item

# TODO: genericise this approach

return if content_object_data['amendmentText_t'].blank?
return if content_object_data['amendment_numberOfSignatures_s'].blank?
return if content_object_data['amendment_primarySponsorPrinted_t'].blank?
return if content_object_data['amendment_primarySponsorParty_ses'].blank?
return if content_object_data['identifier_t'].blank?
return if content_object_data['amendment_dateTabled_dt'].blank?

original_hash = {
text: content_object_data['amendmentText_t'],
number_of_signatures: content_object_data['amendment_numberOfSignatures_s'],
primary_sponsor: content_object_data['amendment_primarySponsorPrinted_t'],
primary_sponsor_party: content_object_data['amendment_primarySponsorParty_ses'],
reference: content_object_data['identifier_t'].drop(1),
date_tabled: content_object_data['amendment_dateTabled_dt'],
}

result_hashes = original_hash[:text].zip(
original_hash[:number_of_signatures],
original_hash[:primary_sponsor],
original_hash[:primary_sponsor_party],
original_hash[:reference],
original_hash[:date_tabled],
).map.with_index do |values, index|
{
index: index,
text: values[0],
number_of_signatures: values[1],
primary_sponsor: values[2],
primary_sponsor_party: values[3],
reference: values[4],
date_tabled: values[5],
}
end

result_hashes
end

def amendment_text
return if content_object_data['amendmentText_t'].blank?

content_object_data['amendmentText_t']
end

def other_supporters
# requires a SES lookup to fetch names
return if content_object_data['signedMember_ses'].blank?

content_object_data['signedMember_ses']
end

def registered_interest_declared
return if content_object_data['registeredInterest_b'].blank?

content_object_data['registeredInterest_b'].first == 'true' ? 'Yes' : 'No'
end

def session
return if content_object_data['session_t'].blank?

content_object_data['session_t'].first
end

def reference
return if content_object_data['identifier_t'].blank?

content_object_data['identifier_t'].first
end

def motion_text
return if content_object_data['motionText_t'].blank?

Expand Down Expand Up @@ -38,6 +115,12 @@ def subjects
content_object_data['subject_sesrollup']
end

def legislation
return if content_object_data['legislature_ses'].blank?

content_object_data['legislature_ses']
end

def external_location_uri
return if content_object_data['externalLocation_uri'].blank?

Expand Down
10 changes: 7 additions & 3 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
<%= render '/layouts/head' %>
<body>
<%= render '/layouts/nav' %>
<main style="max-width: 1200px;">
<%= yield :before_title if content_for?(:before_title) %>
<%= yield :title if content_for?(:title) %>
<main>
<header>
<%= yield :before_title if content_for?(:before_title) %>
<h1>
<%= yield :title if content_for?(:title) %>
</h1>
</header>
<%= yield %>
</main>
<%#= render '/layouts/footer' %>
Expand Down
19 changes: 19 additions & 0 deletions app/views/search/fragments/_amendments.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div class="about-item">
<h3 class="content-heading">Amendments</h3>
<div>
<ul>
<% amendments.each do |amendment| %>
<li>
<div class="amendment-title">
<strong>Amendment <%= amendment[:index] + 1 %> - <%= title %></strong>
<span class="amendment-title-ref">(<%= amendment[:reference] %>)</span>
</div>
<div class="amendment-text"><%= amendment[:text] %></div>
Sponsored by <%= amendment[:primary_sponsor] %> (primary, <%= amendment[:primary_sponsor_party] %>)
on <%= amendment[:date_tabled]&.to_date&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %>. It has
been signed by <%= amendment[:number_of_signatures] %> members total.<br><br>
</li>
<% end %>
</ul>
</div>
</div>
12 changes: 3 additions & 9 deletions app/views/search/fragments/_back_to_top_button.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<div style="height: 92px; padding-left: 32px; padding-right: 32px; flex-direction: column; justify-content: center; align-items: center; display: flex">
<div style="align-self: stretch; height: 92px; padding-top: 16px; padding-bottom: 32px; border-bottom: 0.50px #AAAAAA solid; flex-direction: column; justify-content: flex-start; align-items: center; gap: 10px; display: flex">
<div style="padding-left: 16px; padding-right: 16px; padding-top: 8px; padding-bottom: 8px; border-radius: 4px; overflow: hidden; border: 1px #2B57AB solid; justify-content: center; align-items: center; gap: 8px; display: inline-flex">
<div style="color: #2B57AB; font-size: 20px; font-family: Helvetica; font-weight: 400; line-height: 28px; word-wrap: break-word">Back
to top
</div>
</div>
</div>
</div>
<div class="button-container">
<a class="button-link" href="#top">Back to top</a>
</div>
4 changes: 2 additions & 2 deletions app/views/search/fragments/_copy_text_button.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<div style="width: 16px; height: 18px; flex-direction: column; justify-content: center; align-items: center; display: inline-flex">
<div style="width: 16px; height: 18px; color: #2B57AB; font-size: 18px; font-family: Font Awesome 5 Free; font-weight: 400; line-height: 27px; word-wrap: break-word"></div>
</div>
<div style="color: #2B57AB; font-size: 20px; font-family: Helvetica; font-weight: 400; line-height: 28px; word-wrap: break-word">Copy
text to clipboard
<div style="color: #2B57AB; font-size: 20px; font-family: Helvetica; font-weight: 400; line-height: 28px; word-wrap: break-word">
Copy text to clipboard
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/search/fragments/_edm_prelim.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="content-prelim-inner">
<div class="content-prelim-text">
An <%= object_link('Early Day Motion', '/') %> tabled by <%= object_link(object.primary_sponsor, '/') %>
on <%= object.date_tabled&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %>.
on <strong><%= object.date_tabled&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>.
</div>
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions app/views/search/fragments/_legislation.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="about-item">
<h3 class="content-heading">Legislation</h3>
<% legislation.each do |legislation| %>
<%= link_to legislation.to_s.titleize, '/' %>
<% end %>
</div>
4 changes: 4 additions & 0 deletions app/views/search/fragments/_links.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="about-item">
<h3 class="content-heading">Links</h3>
<%= link_to 'View this early day motion on edm.parliament.uk', object.external_location_uri %>
</div>
8 changes: 8 additions & 0 deletions app/views/search/fragments/_other_supporters.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="about-item">
<h3 class="content-heading">Other supporters</h3>
<ul>
<% supporters.each do |supporter| %>
<li>- <%= link_to supporter, '/' %></li>
<% end %>
</ul>
</div>
13 changes: 13 additions & 0 deletions app/views/search/fragments/_related_items.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!--No data currently available to test-->

<div class="about-item">
<h3 class="content-heading">Related items</h3>
<div>
<%= link_to 'Food and Drink Act 2023', '/' %><br/>
Thursday, 2 February 2023 | Public acts
</div>
<div>
<%= link_to 'Privacy Act 2023', '/' %><br/>
Thursday, 2 February 2023 | Public acts
</div>
</div>
12 changes: 7 additions & 5 deletions app/views/search/fragments/_subjects.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<div id="subjects">
<h2>Subjects</h2>
<ul>
<div class="about-item">
<h3 class="content-heading">Subjects</h3>
<div class="pill-section">
<% subjects.each do |subject| %>
<li><%= object_link(subject, '/') %></li>
<div class="pill-wrapper">
<div class="subject-pill"><%= subject.to_s.titleize %></div>
</div>
<% end %>
</ul>
</div>
</div>
Loading

0 comments on commit d61733a

Please sign in to comment.