|
1 | 1 | <%# Index view for displaying a list of tasks |
2 | | - Required locals: |
3 | | - - model_class: Flex::Task or subclass - The model class for the tasks |
4 | | -
|
5 | | - Example usage: |
6 | | - render template: "flex/application_forms/index", locals: { |
7 | | - model_class: PassportTask |
8 | | - } |
9 | | -%> |
10 | | -<%= content_for :title, model_class.name.titleize %> |
| 2 | + Required locals: |
| 3 | + - tasks: Flex::Task[] - Array of tasks to display |
| 4 | + %> |
11 | 5 | <!-- Main content --> |
12 | 6 | <main class="usa-section"> |
13 | 7 | <div class="grid-container"> |
14 | 8 | <h1 class="usa-heading-xl"><%= t("flex.tasks.index.title") %></h1> |
15 | 9 | <nav class="display-flex border-bottom-1px border-base-light"> |
16 | 10 | <% |
| 11 | + filter_params = params.permit(:filter_date, :filter_type, :filter_status) |
17 | 12 | [ |
18 | | - { name: t("flex.tasks.index.tabs.assigned"), path: polymorphic_path(model_class, filter_status: nil, filter_date: params[:filter_date], filter_type: params[:filter_type]), active: params[:filter_status] != "completed" }, |
19 | | - { name: t("flex.tasks.index.tabs.completed"), path: polymorphic_path(model_class, filter_status: "completed", filter_date: params[:filter_date], filter_type: params[:filter_type]), active: params[:filter_status] == "completed" } |
| 13 | + { |
| 14 | + name: t("flex.tasks.index.tabs.assigned"), |
| 15 | + path: url_for(filter_params.merge(filter_status: nil)), |
| 16 | + active: params[:filter_status] != "completed" |
| 17 | + }, |
| 18 | + { |
| 19 | + name: t("flex.tasks.index.tabs.completed"), |
| 20 | + path: url_for(filter_params.merge(filter_status: "completed")), |
| 21 | + active: params[:filter_status] == "completed" |
| 22 | + } |
20 | 23 | ].each do |tab| |
21 | 24 | %> |
22 | 25 | <%= render partial: "flex/cases/nav_tab", locals: tab %> |
|
25 | 28 | <!-- Filters --> |
26 | 29 | <div class="grid-row grid-gap-4 margin-bottom-4"> |
27 | 30 | <div class="grid-col-12 tablet:grid-col-3"> |
28 | | - <%= render partial: 'flex/tasks/type_filter' %> |
| 31 | + <%= render partial: 'flex/tasks/type_filter', locals: { task_types: task_types } %> |
29 | 32 | </div> |
30 | 33 | <div class="grid-col-12 tablet:grid-col-3"> |
31 | 34 | <%= render partial: 'flex/tasks/due_date_filter' %> |
32 | 35 | </div> |
33 | 36 | </div> |
34 | | - <% if @tasks.any? %> |
| 37 | + <% if tasks.any? %> |
35 | 38 | <!-- Tasks --> |
36 | 39 | <table class="usa-table usa-table--striped usa-table--sticky-header width-full"> |
37 | 40 | <thead> |
|
52 | 55 | </thead> |
53 | 56 | <tbody> |
54 | 57 | <% |
55 | | - @tasks.each do |task| |
| 58 | + tasks.each do |task| |
56 | 59 | %> |
57 | 60 | <tr> |
58 | 61 | <td data-sort-value="<%= time_since_epoch task.due_on %>"> |
59 | 62 | <%= local_en_us task.due_on %> |
60 | 63 | </td> |
61 | 64 | <td data-sort-value="<%= task.type %>"> |
62 | | - <%= link_to t("tasks.types.#{task.type.underscore}"), passport_task_path(task) %> |
| 65 | + <%= link_to t("tasks.types.#{task.type.underscore}"), task_path(task) %> |
63 | 66 | </td> |
64 | 67 | <td data-sort-value="<%= task.case_id %>"><%= task.case_id %></td> |
65 | 68 | <td data-sort-value="<%= time_since_epoch task.created_at %>"> |
|
0 commit comments