This repository has been archived by the owner on Apr 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from LBHackney-IT/ajax-related-repairs
Ajaxify the related repairs tab
- Loading branch information
Showing
5 changed files
with
61 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<h2 class="govuk-heading-l"> | ||
Related repairs | ||
</h2> | ||
<% if @work_order.related_properties.any? %> | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-full hackney-work-order-related__flex"> | ||
<% @work_order.related_properties.sort_by(&:address).each do |property| %> | ||
<div class="hackney-work-order-related__property"> | ||
<p class="address"> | ||
<%= property.address %><%= '*' if property == @work_order.property %> | ||
</p> | ||
<ul> | ||
<% @work_order.related_for_property(property).sort_by(&:created).reverse.each do |work_order| %> | ||
<li> | ||
<%= link_to work_order.reference, | ||
work_order_path(work_order.reference) %> | ||
<p class="date"><%= work_order.created.to_date.to_s(:govuk_date_short) %></p> | ||
<p class="description"><%= work_order.problem_description %></p> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% else %> | ||
<p class="govuk-body-s">There are no work orders related to this work order.</p> | ||
<% end %> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,12 @@ | ||
<div class="govuk-tabs__panel hackney-work-order-tabs-info" id="related-tab"> | ||
<h2 class="govuk-heading-l"> | ||
Related repairs | ||
</h2> | ||
<% if work_order.related_properties.any? %> | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-full hackney-work-order-related__flex"> | ||
<% work_order.related_properties.sort_by(&:address).each do |property| %> | ||
<div class="hackney-work-order-related__property"> | ||
<p class="address"> | ||
<%= property.address %><%= '*' if property == @work_order.property %> | ||
</p> | ||
<ul> | ||
<% work_order.related_for_property(property).sort_by(&:created).reverse.each do |work_order| %> | ||
<li> | ||
<%= link_to work_order.reference, | ||
work_order_path(work_order.reference) %> | ||
<p class="date"><%= work_order.created.to_date.to_s(:govuk_date_short) %></p> | ||
<p class="description"><%= work_order.problem_description %></p> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% else %> | ||
<p class="govuk-body-s">There are no work orders related to this work order.</p> | ||
<% end %> | ||
<p class="govuk-caption-m ajax-loading">Loading related work orders data</p> | ||
</div> | ||
|
||
<script> | ||
window.addEventListener("load", function() { | ||
var endpoint = "/api/work_orders/<%= work_order.reference %>/related_work_orders" | ||
var ajaxTab = document.getElementById('related-tab'); | ||
|
||
handleAjaxResponse(endpoint, ajaxTab); | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters