Skip to content

Commit 5ff2b87

Browse files
Rename policy + Copy remaining rails views over to Strata namespace (#200)
## Changes Rename ApplicationPolicy under Strata namespace. Move rails views to Strata namepace, leave flex views alone until end for cleanup.
1 parent 301d5b8 commit 5ff2b87

20 files changed

Lines changed: 285 additions & 7 deletions

app/policies/flex/application_form_policy.rb renamed to app/policies/strata/application_form_policy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Flex
1+
module Strata
22
# Common policy for application forms
33
#
44
# @note All actions require a logged-in user
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Strata</title>
5+
<%= csrf_meta_tags %>
6+
<%= csp_meta_tag %>
7+
8+
<%= stylesheet_link_tag "application", media: "all" %>
9+
</head>
10+
<body>
11+
12+
<%= yield %>
13+
14+
</body>
15+
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<tr>
2+
<td>
3+
<% # TODO show in local time %>
4+
<%= link_to application_form[:created_at], application_form[:path] %>
5+
</td>
6+
<td>
7+
<%= t("strata.application_forms.statuses.#{application_form[:status]}") %>
8+
</td>
9+
<td>
10+
TODO
11+
</td>
12+
</tr>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<%# Index view for displaying a list of application forms
2+
Required locals:
3+
- title: String - Page title
4+
- intro: String - Introduction text
5+
- new_button_text: String - Text for the "New" button
6+
- new_path: String - Path for the "New" button
7+
- in_progress_applications_heading: String - Heading for the in-progress section
8+
- application_forms: Array<Hash> - List of application form data with keys:
9+
- created_at: String
10+
- path: String
11+
- status: Symbol
12+
13+
Example usage:
14+
render template: "flex/application_forms/index", locals: {
15+
title: t(".title"),
16+
intro: t(".intro"),
17+
new_button_text: t(".new_button"),
18+
in_progress_applications_heading: t(".in_progress_applications.heading"),
19+
application_forms: @application_forms.map { |form| {
20+
created_at: form.created_at.strftime("%B %d, %Y at %I:%M %p"),
21+
path: application_form_path(form),
22+
status: form.status
23+
}}
24+
}
25+
%>
26+
27+
<% content_for :title, title %>
28+
29+
<h1>
30+
<%= title %>
31+
</h1>
32+
33+
<p class="usa-intro">
34+
<%= intro %>
35+
</p>
36+
37+
<%= link_to new_button_text, new_path, class: class_names("usa-button") %>
38+
39+
<% if not application_forms.empty? %>
40+
<h2 class="margin-top-6"><%= in_progress_applications_heading %></h2>
41+
42+
<section class="d-flex flex-column flex-md-row gap-4 align-items-start justify-content-between">
43+
<table class="usa-table usa-table--borderless width-full">
44+
<thead>
45+
<tr>
46+
<th scope="col">
47+
<%= t("strata.application_forms.index.col_created_at") %>
48+
</th>
49+
<th scope="col">
50+
<%= t("strata.application_forms.index.col_status") %>
51+
</th>
52+
<th scope="col">
53+
<%= t("strata.application_forms.index.col_actions") %>
54+
</th>
55+
</tr>
56+
</thead>
57+
<tbody>
58+
<% application_forms.each do |application_form| %>
59+
<% if local_assigns.key?(:row_view) %>
60+
<%= render partial: row_view, locals: { application_form: } %>
61+
<% else %>
62+
<%= render partial: "strata/application_forms/row", locals: { application_form: } %>
63+
<% end %>
64+
<% end %>
65+
</tbody>
66+
</table>
67+
</section>
68+
<% end %>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<%# Show view for displaying a single application form
2+
Required locals:
3+
- title: String - Page title
4+
- back_link_text: String - Text for the back link
5+
- index_path: String - Path to return to index
6+
- created_at: String - Formatted creation timestamp
7+
- current_status: Symbol - Current application status
8+
- next_step: String - Text describing the next step
9+
- submitted_on_text: String - Label for submission date
10+
11+
Example usage:
12+
render template: "strata/application_forms/show", locals: {
13+
title: t(".title"),
14+
back_link_text: t(".back"),
15+
index_path: application_forms_path,
16+
created_at: application_form.created_at.strftime("%B %d, %Y at %I:%M %p"),
17+
submitted_at: pplication_form&.submitted_at&.strftime("%B %d, %Y at %I:%M %p"),
18+
current_status: application_form.status,
19+
next_step: t(".next_step.status.#{application_form.status}"),
20+
submitted_on_text: t(".submitted_on")
21+
}
22+
%>
23+
24+
<% content_for :title, title %>
25+
26+
<%= link_to back_link_text, index_path %>
27+
28+
<h1><%= title %></h1>
29+
30+
<%= render partial: "strata/shared/step_indicator", locals: {
31+
type: :counters,
32+
steps: [:in_progress, :submitted, :decision_made],
33+
current_step: current_status
34+
} %>
35+
36+
<p class="usa-intro">
37+
<%= next_step %>
38+
</p>
39+
40+
<% if current_status == "submitted" && local_assigns.key?(:submitted_at) %>
41+
<p>
42+
<%= submitted_on_text %>: <%= submitted_at %>
43+
</p>
44+
<% end %>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
<%#
3+
Sidenav partial for case pages
4+
5+
Required parameters:
6+
- sidenav: Array of navigation items, each with:
7+
- text: Display text for the navigation item
8+
- link: URL path for the navigation item
9+
10+
Example usage:
11+
render partial: "strata/cases/sidenav", locals: { sidenav: custom_nav_items }
12+
%>
13+
<% if content_for?(:sidenav) %>
14+
<%= yield :sidenav %>
15+
<% else %>
16+
<nav aria-label="Side navigation,">
17+
<ul class="usa-sidenav">
18+
<% sidenav.each do |item| %>
19+
<li class="usa-sidenav__item">
20+
<%= link_to item[:text], item[:link], class: { "usa-current" => request.path == item[:link] } %>
21+
</li>
22+
<% end %>
23+
</ul>
24+
</nav>
25+
<% end %>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<span class="usa-tag text-ink bg-yellow"><%= status %></span></p>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Cases#create</h1>
2+
<p>Find me in app/views/strata/cases/create.html.erb</p>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Cases#edit</h1>
2+
<p>Find me in app/views/strata/cases/edit.html.erb</p>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<%= content_for :title, model_class.name.titleize %>
2+
3+
<!-- Main content -->
4+
<h1 class="usa-heading-xl"><%= model_class.name.titleize.sub('Case', ' Cases') %></h1>
5+
6+
<% tabs = [
7+
{ name: "Open", path: polymorphic_path(model_class), active: action_name == "index" },
8+
{ name: "Closed", path: polymorphic_path(model_class, action: "closed"), active: action_name == "closed" }
9+
] %>
10+
11+
<nav class="display-flex border-bottom-1px border-base-light">
12+
<% tabs.each do |tab| %>
13+
<%= render partial: "strata/cases/nav_tab", locals: tab %>
14+
<% end %>
15+
</nav>
16+
17+
<!-- Cases -->
18+
<table class="usa-table usa-table--borderless usa-table--striped">
19+
<thead>
20+
<tr>
21+
<th scope="col">Case ID</th>
22+
<th scope="col">Created</th>
23+
<th scope="col">Action</th>
24+
</tr>
25+
</thead>
26+
<tbody>
27+
<% if @cases.any? %>
28+
<% @cases.each do |kase| %>
29+
<tr>
30+
<td><%= kase.id %></td>
31+
<td><%= kase.created_at.strftime('%m/%d/%Y') %></td>
32+
<td>
33+
<%= link_to "View", polymorphic_path(kase), class: "usa-button usa-button--outline" %>
34+
</td>
35+
</tr>
36+
<% end %>
37+
<% else %>
38+
<tr>
39+
<td colspan="3" class="text-center">No cases</td>
40+
</tr>
41+
<% end %>
42+
</tbody>
43+
</table>

0 commit comments

Comments
 (0)