Browse Source

Create merge requests details page

pull/2565/head
Manny Dinssa 2 years ago
parent
commit
410d891618
  1. 6
      app/controllers/merge_requests_controller.rb
  2. 5
      app/helpers/merge_requests_helper.rb
  3. 158
      app/views/merge_requests/details.html.erb
  4. 4
      app/views/organisations/_merge_request_list.html.erb
  5. 1
      config/routes.rb

6
app/controllers/merge_requests_controller.rb

@ -11,6 +11,7 @@ class MergeRequestsController < ApplicationController
new_organisation_telephone_number
new_organisation_type
merge_date
details
]
before_action :authenticate_user!
before_action :authenticate_scope!, except: [:create]
@ -47,6 +48,11 @@ class MergeRequestsController < ApplicationController
end
end
def details
@merge_request = MergeRequest.find(params[:id])
render :details
end
def update_organisations
merge_request_organisation = MergeRequestOrganisation.new(merge_request_organisation_params)
@answer_options = organisations_answer_options

5
app/helpers/merge_requests_helper.rb

@ -0,0 +1,5 @@
module MergeRequestsHelper
def display_value_or_placeholder(value, placeholder = "You didn't answer this question")
value.presence || content_tag(:span, placeholder, class: "app-!-colour-muted")
end
end

158
app/views/merge_requests/details.html.erb

@ -0,0 +1,158 @@
<% content_for :before_content do %>
<% title = "Merge details: #{@merge_request.absorbing_organisation_name}" %>
<% content_for :title, title %>
<%= govuk_back_link href: "#{organisations_path}#merge-requests" %>
<% end %>
<% unless @merge_request.signed_dsa %>
<div class="govuk-notification-banner" role="region" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
Important
</h2>
</div>
<div class="govuk-notification-banner__content">
<strong>The absorbing organisation must accept the Data Sharing Agreement before merging.</strong>
<p>Contact the Data Protection Officer:
<% if @merge_request.dpo_user %>
<%= link_to @merge_request.dpo_user.name, user_path(@merge_request.dpo_user.id) %>
<% else %>
None belong to the organisation
<% end %>
</p>
</div>
</div>
<% end %>
<h1 class="govuk-heading-l">
<span class="govuk-caption-l">Merge details</span>
<%= @merge_request.absorbing_organisation_name %>
</h1>
<div class="govuk-button-group">
<button type="submit" <%= @merge_request.status == "ready_to_merge" ? "" : "disabled aria-disabled=\"true\"" %> class="govuk-button" data-module="govuk-button">
Begin merge
</button>
<button type="submit" <%= @merge_request.status != "request_merged" ? "" : "disabled aria-disabled=\"true\"" %> class="govuk-button govuk-button--warning" data-module="govuk-button">
Delete merge request
</button>
</div>
<table class="govuk-table govuk-!-width-three-quarters" style="border: 1px solid #b1b4b6;">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" colspan="3" class="govuk-table__header govuk-!-font-weight-regular govuk-!-padding-3" style="background-color:#f3f2f1">Request details</th>
</tr>
</thead>
<tbody class="govuk-table__body app-table-group">
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header govuk-!-padding-2 govuk-!-padding-right-9 govuk-!-padding-top-4">Requester</th>
<td class="govuk-table__cell govuk-!-width-one-half govuk-!-padding-2 govuk-!-padding-right-9 govuk-!-padding-top-4"><%= display_value_or_placeholder(@merge_request.requesting_user&.name) %></td>
<td class="govuk-table__cell govuk-!-width-one-quarter-width govuk-!-padding-2 govuk-!-padding-top-4 govuk-!-text-align-right" style="width: 10%;"></td>
</tr>
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header govuk-!-padding-2 govuk-!-padding-right-9">Helpdesk ticket</th>
<% ticket_base_url = "https://dluhcdigital.atlassian.net/browse/" %>
<td class="govuk-table__cell govuk-!-padding-2 govuk-!-padding-right-9">
<% if @merge_request.helpdesk_ticket.blank? %>
<%= display_value_or_placeholder(nil) %>
<% else %>
<a href="<%= ticket_base_url + @merge_request.helpdesk_ticket %>" target="_blank" rel="noopener noreferrer" title="<%= @merge_request.helpdesk_ticket %> (opens in a new tab)">
<%= @merge_request.helpdesk_ticket %> (opens in a new tab)
</a>
<% end %>
</td>
<td class="govuk-table__cell govuk-!-padding-2 govuk-!-text-align-right" style="width: 10%;"><a href="#" aria-label="Change helpdesk ticket">Change</a></td>
</tr>
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header govuk-!-padding-2 govuk-!-padding-right-9 govuk-!-padding-bottom-5">Status</th>
<td class="govuk-table__cell govuk-!-padding-2 govuk-!-padding-right-9"><%= status_tag(@merge_request.status) %></td>
<td class="govuk-table__cell govuk-!-padding-2 govuk-!-text-align-right" style="width: 10%;"></td>
</tr>
</tbody>
</table>
<table class="govuk-table govuk-!-width-three-quarters" style="border: 1px solid #b1b4b6;">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" colspan="3" class="govuk-table__header govuk-!-font-weight-regular govuk-!-padding-3" style="background-color:#f3f2f1">Merge details</th>
</tr>
</thead>
<tbody class="govuk-table__body app-table-group">
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header govuk-!-padding-2 govuk-!-padding-right-9 govuk-!-padding-top-4">Absorbing organisation</th>
<td class="govuk-table__cell govuk-!-width-one-half govuk-!-padding-2 govuk-!-padding-right-9 govuk-!-padding-top-4"><%= display_value_or_placeholder(@merge_request.absorbing_organisation_name) %></td>
<td class="govuk-table__cell govuk-!-width-one-quarter-width govuk-!-padding-2 govuk-!-padding-top-4 govuk-!-text-align-right" style="width: 10%;"><a href="#" aria-label="Change absorbing organisation">Change</a></td>
</tr>
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header govuk-!-padding-2 govuk-!-padding-right-9">Merging organisations</th>
<td class="govuk-table__cell govuk-!-padding-2 govuk-!-padding-right-9">
<% if @merge_request.other_merging_organisations.blank? %>
<%= display_value_or_placeholder(nil) %>
<% else %>
<% @merge_request.other_merging_organisations.split(',').each do |organisation| %>
<p class="govuk-!-padding-bottom-1 govuk-!-margin-0"><%= organisation.strip %></p>
<% end %>
<% end %>
</td>
<td class="govuk-table__cell govuk-!-padding-2 govuk-!-text-align-right" style="width: 10%;"><a href="#" aria-label="Change merging organisations">Change</a></td>
</tr>
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header govuk-!-padding-2 govuk-!-padding-right-9 govuk-!-padding-bottom-5">Merge date</th>
<td class="govuk-table__cell govuk-!-padding-2 govuk-!-padding-right-9"><%= display_value_or_placeholder(@merge_request.merge_date) %></td>
<td class="govuk-table__cell govuk-!-padding-2 govuk-!-text-align-right" style="width: 10%;"><a href="#" aria-label="Change merge date">Change</a></td>
</tr>
</tbody>
</table>
<table class="govuk-table govuk-!-width-three-quarters" style="border: 1px solid #b1b4b6;">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" colspan="3" class="govuk-table__header govuk-!-font-weight-regular govuk-!-padding-3" style="background-color:#f3f2f1">Merge outcomes</th>
</tr>
</thead>
<tbody class="govuk-table__body app-table-group">
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header govuk-!-padding-2 govuk-!-padding-right-9 govuk-!-padding-top-4">Total users after merge</th>
<td class="govuk-table__cell govuk-!-width-one-half govuk-!-padding-2 govuk-!-padding-right-9 govuk-!-padding-top-4"><%= display_value_or_placeholder(@merge_request.total_users) %></td>
<td class="govuk-table__cell govuk-!-width-one-quarter-width govuk-!-padding-2 govuk-!-padding-top-4 govuk-!-text-align-right" style="width: 10%;"><a href="#" aria-label="View all users after merge">View</a></td>
</tr>
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header govuk-!-padding-2 govuk-!-padding-right-9">Total schemes after merge</th>
<td class="govuk-table__cell govuk-!-padding-2 govuk-!-padding-right-9"><%= display_value_or_placeholder(@merge_request.total_schemes) %></td>
<td class="govuk-table__cell govuk-!-padding-2 govuk-!-text-align-right" style="width: 10%;"><a href="#" aria-label="View all schemes after merge">View</a></td>
</tr>
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header govuk-!-padding-2 govuk-!-padding-right-9">Total logs after merge</th>
<td class="govuk-table__cell govuk-!-padding-2 govuk-!-padding-right-9">
<% if @merge_request.total_lettings_logs.blank? && @merge_request.total_sales_logs.blank? %>
<%= display_value_or_placeholder(nil) %>
<% else %>
<% unless @merge_request.total_lettings_logs.blank? %>
<%= @merge_request.total_lettings_logs %> lettings logs
<% end %>
<br>
<% unless @merge_request.total_sales_logs.blank? %>
<%= @merge_request.total_sales_logs %> sales logs
<% end %>
<% end %>
</td>
<td class="govuk-table__cell govuk-!-padding-2 govuk-!-text-align-right" style="width: 10%;"><a href="#" aria-label="View all lettings and sales logs after merge">View</a></td>
</tr>
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header govuk-!-padding-2 govuk-!-padding-right-9 govuk-!-padding-bottom-5">Total stock owners & managing agents after merge</th>
<td class="govuk-table__cell govuk-!-padding-2 govuk-!-padding-right-9">
<% if @merge_request.total_stock_owners.blank? && @merge_request.total_managing_agents.blank? %>
<%= display_value_or_placeholder(nil) %>
<% else %>
<% unless @merge_request.total_stock_owners.blank? %>
<%= @merge_request.total_stock_owners %> stock owners
<% end %>
<br>
<% unless @merge_request.total_managing_agents.blank? %>
<%= @merge_request.total_managing_agents %> managing agents
<% end %>
<% end %>
</td>
<td class="govuk-table__cell govuk-!-padding-2 govuk-!-text-align-right" style="width: 10%;"><a href="#" aria-label="View all stock owners and managing agents after merge">View</a></td>
</tr>
</tbody>
</table>

4
app/views/organisations/_merge_request_list.html.erb

@ -3,7 +3,7 @@
<p>No merge requests</p>
<% else %>
<%= govuk_table do |table| %>
<%= table.with_caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
<%= table.with_caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do %>
<strong><%= @merge_requests.where.not(status: 4).count %></strong> unresolved merge requests
<% end %>
<%= table.with_head do |head| %>
@ -48,7 +48,7 @@
<% row.with_cell(html_attributes: {
scope: "row",
}) do %>
<%= govuk_link_to("View details", "/merge-request/#{merge_request.id}/organisations") %>
<%= govuk_link_to("View details", "/merge-request/#{merge_request.id}/details") %>
<% end %>
<% end %>
<% end %>

1
config/routes.rb

@ -205,6 +205,7 @@ Rails.application.routes.draw do
get "new-organisation-telephone-number"
get "new-organisation-type"
get "merge-date"
get "details", to: "merge_requests#details"
end
end

Loading…
Cancel
Save