diff --git a/app/previews/flex/cases/index_preview.rb b/app/previews/flex/cases/index_preview.rb new file mode 100644 index 00000000..09f5c4c8 --- /dev/null +++ b/app/previews/flex/cases/index_preview.rb @@ -0,0 +1,41 @@ +module Flex + module Cases + class IndexPreview < Lookbook::Preview + def default + render template: "flex/cases/index", locals: { + action_name: "index", + cases_path: "/cases", + closed_cases_path: "/cases/closed", + cases: [ + { id: 1, created_at: "3/14/2025", path: "/cases/1" }, + { id: 2, created_at: "3/15/2025", path: "/cases/2" }, + ], + title: "Cases", + } + end + + def empty + render template: "flex/cases/index", locals: { + action_name: "index", + cases_path: "/cases", + closed_cases_path: "/cases/closed", + cases: [], + title: "Cases", + } + end + + def closed + render template: "flex/cases/index", locals: { + action_name: "closed", + cases_path: "/cases", + closed_cases_path: "/cases/closed", + cases: [ + { id: 1, created_at: "3/14/2025", path: "/cases/1" }, + { id: 2, created_at: "3/15/2025", path: "/cases/2" }, + ], + title: "Cases", + } + end + end + end +end diff --git a/app/previews/flex/cases/show_preview.rb b/app/previews/flex/cases/show_preview.rb new file mode 100644 index 00000000..311c6e31 --- /dev/null +++ b/app/previews/flex/cases/show_preview.rb @@ -0,0 +1,17 @@ +module Flex + module Cases + class ShowPreview < Lookbook::Preview + def default + render template: "flex/previews/cases/show", locals: { + status: :open + } + end + + def closed + render template: "flex/previews/cases/show", locals: { + status: :closed + } + end + end + end +end diff --git a/app/views/flex/cases/index.html.erb b/app/views/flex/cases/index.html.erb index 469d69fe..06034786 100644 --- a/app/views/flex/cases/index.html.erb +++ b/app/views/flex/cases/index.html.erb @@ -1,13 +1,13 @@ -<%= content_for :title, model_class.name.titleize %> +<%= content_for :title, title %>
-

<%= model_class.name.titleize.sub('Case', ' Cases') %>

+

<%= title %>

<% tabs = [ - { name: "Open", path: polymorphic_path(model_class), active: action_name == "index" }, - { name: "Closed", path: polymorphic_path(model_class, action: "closed"), active: action_name == "closed" } + { name: "Open", path: cases_path, active: action_name == "index" }, + { name: "Closed", path: closed_cases_path, active: action_name == "closed" } ] %> - +
@@ -26,13 +26,13 @@ - <% if @cases.any? %> - <% @cases.each do |kase| %> + <% if cases.any? %> + <% cases.each do |kase| %> - - + + <% end %> diff --git a/app/views/flex/cases/show.html.erb b/app/views/flex/cases/show.html.erb index f767b1e9..f4d6f493 100644 --- a/app/views/flex/cases/show.html.erb +++ b/app/views/flex/cases/show.html.erb @@ -4,16 +4,16 @@ -

Case ID: <%= @case.id %>

+

Case ID: <%= kase[:id] %>

<%= yield :case_summary %> -

Status: <%= render partial: "flex/cases/status_tag", locals: { status: @case.status } %>

+

Status: <%= render partial: "flex/cases/status_tag", locals: { status: kase[:status] } %>

diff --git a/app/views/flex/previews/cases/show.html.erb b/app/views/flex/previews/cases/show.html.erb new file mode 100644 index 00000000..f8dc540e --- /dev/null +++ b/app/views/flex/previews/cases/show.html.erb @@ -0,0 +1,15 @@ +<% content_for :case_summary do %> +

Customizable case summary

+<% end %> + +<% content_for :case_details do %> + Customizable case details +<% end %> + +<%= render template: 'flex/cases/show', locals: { + cases_path: "/cases", + kase: { + id: 1, + status: status, + }, +} %> diff --git a/spec/dummy/app/views/passport_cases/index.html.erb b/spec/dummy/app/views/passport_cases/index.html.erb index d299b97e..0269b1ca 100644 --- a/spec/dummy/app/views/passport_cases/index.html.erb +++ b/spec/dummy/app/views/passport_cases/index.html.erb @@ -1 +1,10 @@ -<%= render template: 'flex/cases/index', locals: { model_class: PassportCase } %> +<%= render template: 'flex/cases/index', locals: { + cases: @cases.map { |kase| { + id: kase.id, + created_at: kase.created_at.strftime("%m/%d/%Y"), + path: polymorphic_path(kase), + } }, + cases_path: "/cases", + closed_cases_path: "/cases/closed", + title: "Passport Cases", +} %> diff --git a/spec/dummy/app/views/passport_cases/show.html.erb b/spec/dummy/app/views/passport_cases/show.html.erb index de413bac..45e2c559 100644 --- a/spec/dummy/app/views/passport_cases/show.html.erb +++ b/spec/dummy/app/views/passport_cases/show.html.erb @@ -8,4 +8,10 @@ <% end %> -<%= render template: 'flex/cases/show', locals: { model_class: PassportCase } %> +<%= render template: 'flex/cases/show', locals: { + cases_path: passport_cases_path, + kase: { + id: @case.id, + status: @case.status, + }, +} %>
Case ID
<%= kase.id %><%= kase.created_at.strftime('%m/%d/%Y') %><%= kase[:id] %><%= kase[:created_at] %> - <%= link_to "View", polymorphic_path(kase), class: "usa-button usa-button--outline" %> + <%= link_to "View", kase[:path], class: "usa-button usa-button--outline" %>