Browse Source

Log list skeleton

pull/21/head
baarkerlounger 3 years ago
parent
commit
57e0edbccb
  1. 11
      app/controllers/case_logs_controller.rb
  2. 3
      app/controllers/form_controller.rb
  3. 27
      app/views/case_logs/_log_list.html.erb
  4. 2
      app/views/case_logs/_tasklist.html.erb
  5. 2
      app/views/case_logs/edit.html.erb
  6. 15
      app/views/case_logs/index.html.erb
  7. 8
      app/views/case_logs/new.html.erb
  8. 2
      spec/features/form_spec.rb

11
app/controllers/case_logs_controller.rb

@ -1,7 +1,16 @@
class CaseLogsController < ApplicationController class CaseLogsController < ApplicationController
def index; end def index
@submitted_case_logs = CaseLog.where(status: 1)
@in_progress_case_logs = CaseLog.where(status: 0)
end
def show def show
@case_log = CaseLog.find(params[:id]) @case_log = CaseLog.find(params[:id])
end end
def edit
end
def new
end
end end

3
app/controllers/form_controller.rb

@ -1,3 +0,0 @@
class FormController < ApplicationController
def index; end
end

27
app/views/case_logs/_log_list.html.erb

@ -0,0 +1,27 @@
<table class="govuk-table">
<caption class="govuk-table__caption govuk-table__caption--m"><%= title %></caption>
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" class="govuk-table__header">Log reference</th>
<th scope="col" class="govuk-table__header">Postcode</th>
<th scope="col" class="govuk-table__header">Tenant code</th>
<th scope="col" class="govuk-table__header"><%= date_title %></th>
</tr>
</thead>
<tbody class="govuk-table__body">
<% case_logs.map do |log| %>
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header">
<%= link_to log.id, case_log_path(log) %>
</th>
<td class="govuk-table__cell govuk-table__cell">
</td>
<td class="govuk-table__cell govuk-table__cell">
</td>
<td id="last-changed" class="govuk-table__cell">
<%= log.updated_at.strftime("%d %b %Y") %>
</td>
</tr>
<% end %>
</tbody>
</table>

2
app/views/case_logs/_tasklist.html.erb

@ -18,7 +18,7 @@
<ul class="app-task-list__items"> <ul class="app-task-list__items">
<% subsections.map do |subsection| %> <% subsections.map do |subsection| %>
<li class="app-task-list__item"> <li class="app-task-list__item">
<a class="task-name" href="#"><%= subsection %></a> <%= link_to subsection, edit_case_log_path, class: "task-name" %>
<strong class="govuk-tag govuk-tag--grey app-task-list__tag">Not started</strong> <strong class="govuk-tag govuk-tag--grey app-task-list__tag">Not started</strong>
</li> </li>
<% end %> <% end %>

2
app/views/form/index.html.erb → app/views/case_logs/edit.html.erb

@ -1,4 +1,4 @@
<%= form_with builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> <%= form_with model: @case_log, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_number_field :age, <%= f.govuk_number_field :age,
hint: { text: "More detail" }, hint: { text: "More detail" },
label: { text: "What is the tenant's age?", size: "l"}, label: { text: "What is the tenant's age?", size: "l"},

15
app/views/case_logs/index.html.erb

@ -0,0 +1,15 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<h1 class="govuk-heading-xl">Your logs</h1>
</div>
<div class="govuk-grid-column-two-thirds">
<a href="tasklist" class="govuk-button">Create new Log</a>
<%= render partial: "log_list", locals: { case_logs: @in_progress_case_logs, title: "Logs you need to complete", date_title: "Last Changed" } %>
<%= render partial: "log_list", locals: { case_logs: @submitted_case_logs, title: "Logs you've submitted", date_title: "Date Submitted" } %>
<p><a href="#" class="govuk-link">See all completed logs (<%= @submitted_case_logs.count %>)</a></p>
</div>
</div>

8
app/views/case_logs/new.html.erb

@ -0,0 +1,8 @@
<%= form_with model: @case_log, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_number_field :age,
hint: { text: "More detail" },
label: { text: "What is the tenant's age?", size: "l"},
min: 0, max: 150, step: 1, width: 20
%>
<%= f.govuk_submit %>
<% end %>

2
spec/features/form_spec.rb

@ -1,7 +1,7 @@
require "rails_helper" require "rails_helper"
RSpec.describe "Test Features" do RSpec.describe "Test Features" do
it "Displays the name of the app" do it "Displays the name of the app" do
visit("/form") visit("/case_logs/new")
expect(page).to have_field("age") expect(page).to have_field("age")
expect(page).to have_button("Continue") expect(page).to have_button("Continue")
end end

Loading…
Cancel
Save