|
3 | 3 | # @param tasks [Array<Strata::Task>] Array of tasks to display |
4 | 4 | # @param unassigned_tasks [Array<Strata::Task>] Array of unassigned tasks for button state |
5 | 5 | # @param task_types [Array<String>] Array of task types for filtering |
| 6 | + # @param task_row_component_class [Class] ViewComponent subclass of {Strata::Tasks::TaskRowComponent} |
| 7 | + # @param task_row_component_options [Hash] Extra keyword arguments passed to each row component |
6 | 8 | # |
7 | 9 | # @example Task types array |
8 | 10 | # ["Strata::Task", "Strata::OtherTask", "MyCustomTask"] |
|
13 | 15 | # - strata.tasks.index.tabs.completed: Label for the completed tasks tab |
14 | 16 | # |
15 | 17 | %> |
| 18 | +<% task_row_component_class = local_assigns.fetch(:task_row_component_class, Strata::Tasks::TaskRowComponent) %> |
| 19 | +<% task_row_component_options = local_assigns.fetch(:task_row_component_options, {}) %> |
16 | 20 | <!-- Main content --> |
17 | 21 | <div class="grid-container"> |
18 | 22 | <h1 class="usa-heading-xl"><%= t("strata.tasks.index.title") %></h1> |
|
31 | 35 | <%= render partial: 'strata/tasks/due_date_filter' %> |
32 | 36 | </div> |
33 | 37 | <div class="grid-col-12 tablet:grid-col-3"> |
34 | | - <label class="usa-label" for="next-task-button" style="margin-bottom: 0.5rem">Actions:</label> |
| 38 | + <label class="usa-label" for="next-task-button" style="margin-bottom: 0.5rem"><%= t("strata.tasks.index.actions_label") %></label> |
35 | 39 | <%= button_to t("strata.tasks.actions.pick_next"), url_for(only_path: true, action: :pick_up_next_task), |
36 | 40 | id: "next-task-button", |
37 | 41 | disabled: !unassigned_tasks&.any?, |
|
44 | 48 | <!-- Tasks --> |
45 | 49 | <%= render Strata::US::TableComponent.new(striped: true, sticky_header: true, sortable: true, classes: "width-full") do |table| %> |
46 | 50 | <% table.with_caption do %><span class="usa-sr-only"><%= t("strata.tasks.index.title") %></span><% end %> |
47 | | - <% table.with_header(sortable: true) { t("strata.tasks.index.columns.col_due_date") } %> |
48 | | - <% table.with_header(sortable: true) { t("strata.tasks.index.columns.col_type") } %> |
49 | | - <% table.with_header(sortable: true) { t("strata.tasks.index.columns.col_case_id") } %> |
50 | | - <% table.with_header(sortable: true, aria_sort: "descending") { t("strata.tasks.index.columns.col_created_date") } %> |
| 51 | + <% task_row_component_class.columns.each do |column| %> |
| 52 | + <% table.with_header(sortable: true, **task_row_component_class.header_options_for(column)) do %> |
| 53 | + <%= task_row_component_class.header_translation_for(column) %> |
| 54 | + <% end %> |
| 55 | + <% end %> |
51 | 56 |
|
52 | 57 | <% tasks.each do |task| %> |
53 | | - <% table.with_row do |row| %> |
54 | | - <% row.with_cell(sort_value: time_since_epoch(task.due_on)) { local_en_us(task.due_on) } %> |
55 | | - <% row.with_cell(sort_value: task.type) do %> |
56 | | - <%= link_to t("tasks.types.#{task.type.underscore}"), url_for(only_path: true, action: :show, id: task.id.to_s) %> |
57 | | - <% end %> |
58 | | - <% row.with_cell(sort_value: task.case_id) { task.case_id } %> |
59 | | - <% row.with_cell(sort_value: time_since_epoch(task.created_at)) { local_en_us(task.created_at.to_date) } %> |
| 58 | + <% row_component = task_row_component_class.new(task: task, **task_row_component_options) %> |
| 59 | + <% table.with_row(classes: row_component.row_classes) do %> |
| 60 | + <%= render row_component %> |
60 | 61 | <% end %> |
61 | 62 | <% end %> |
62 | 63 | <% end %> |
|
0 commit comments