|
1 | 1 | module Flex |
2 | | - class ApplicationFormPresenter < Flex::Presenter |
3 | | - attr_reader :application_form |
4 | | - |
| 2 | + class ApplicationFormPresenter |
5 | 3 | def initialize(view_context, application_form) |
6 | | - super(view_context) |
| 4 | + @view_context = view_context |
7 | 5 | @application_form = application_form |
| 6 | + @i18n_path = view_context.controller_path.gsub("/", ".") |
8 | 7 | end |
9 | 8 |
|
10 | 9 | def index |
11 | 10 | { |
12 | 11 | created_at: created_at, |
13 | | - path: view_context.polymorphic_path(application_form), |
| 12 | + path: @view_context.polymorphic_path(@application_form), |
14 | 13 | status: status |
15 | 14 | } |
16 | 15 | end |
17 | 16 |
|
18 | 17 | def show |
19 | 18 | { |
20 | | - title: t("show.title"), |
21 | | - back_link_text: t("show.back"), |
22 | | - index_path: view_context.polymorphic_path(application_form.class), |
| 19 | + title: I18n.t("#{@i18n_path}.show.title"), |
| 20 | + back_link_text: I18n.t("#{@i18n_path}.show.back"), |
| 21 | + index_path: @view_context.polymorphic_path(@application_form.class), |
23 | 22 | created_at: created_at, |
24 | | - current_status: application_form.status, |
25 | | - next_step: t("show.next_step.status.#{application_form.status}"), |
26 | | - submitted_on_text: t("show.submitted_on"), |
| 23 | + current_status: @application_form.status, |
| 24 | + next_step: I18n.t("#{@i18n_path}.show.next_step.status.#{@application_form.status}"), |
| 25 | + submitted_on_text: I18n.t("#{@i18n_path}.show.submitted_on"), |
27 | 26 | status: status |
28 | 27 | } |
29 | 28 | end |
30 | 29 |
|
31 | 30 | private |
32 | 31 |
|
33 | 32 | def created_at |
34 | | - application_form.created_at.strftime("%B %d, %Y at %I:%M %p") |
| 33 | + @application_form.created_at.strftime("%B %d, %Y at %I:%M %p") |
35 | 34 | end |
36 | 35 |
|
37 | 36 | def status |
38 | | - I18n.t("flex.application_forms.status.#{application_form.status}") |
| 37 | + I18n.t("flex.application_forms.status.#{@application_form.status}") |
39 | 38 | end |
40 | 39 | end |
41 | 40 | end |
0 commit comments