Skip to content

Commit e478c48

Browse files
committed
Revert "Create Presenter base class"
This reverts commit a91c3b3.
1 parent a91c3b3 commit e478c48

3 files changed

Lines changed: 20 additions & 34 deletions

File tree

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
11
module Flex
2-
class ApplicationFormPresenter < Flex::Presenter
3-
attr_reader :application_form
4-
2+
class ApplicationFormPresenter
53
def initialize(view_context, application_form)
6-
super(view_context)
4+
@view_context = view_context
75
@application_form = application_form
6+
@i18n_path = view_context.controller_path.gsub("/", ".")
87
end
98

109
def index
1110
{
1211
created_at: created_at,
13-
path: view_context.polymorphic_path(application_form),
12+
path: @view_context.polymorphic_path(@application_form),
1413
status: status
1514
}
1615
end
1716

1817
def show
1918
{
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),
2322
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"),
2726
status: status
2827
}
2928
end
3029

3130
private
3231

3332
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")
3534
end
3635

3736
def status
38-
I18n.t("flex.application_forms.status.#{application_form.status}")
37+
I18n.t("flex.application_forms.status.#{@application_form.status}")
3938
end
4039
end
4140
end

template/{{app_name}}/engines/flex/app/presenters/flex/application_forms_presenter.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
module Flex
2-
class ApplicationFormsPresenter < Flex::Presenter
2+
class ApplicationFormsPresenter
33
attr_reader :application_forms
44

55
def initialize(view_context, application_forms)
6-
super(view_context)
6+
@view_context = view_context
77
@application_forms = application_forms
8+
@i18n_path = view_context.controller_path.gsub("/", ".")
89
end
910

1011
def index
1112
{
12-
title: t("index.title"),
13-
intro: t("index.intro"),
14-
new_button_text: t("index.new_button"),
15-
in_progress_applications_heading: t("index.in_progress_applications.heading"),
16-
application_forms: application_forms.map { |application_form| Flex::ApplicationFormPresenter.new(view_context, application_form).index }
13+
title: I18n.t("#{@i18n_path}.index.title"),
14+
intro: I18n.t("#{@i18n_path}.index.intro"),
15+
new_button_text: I18n.t("#{@i18n_path}.index.new_button"),
16+
in_progress_applications_heading: I18n.t("#{@i18n_path}.index.in_progress_applications.heading"),
17+
application_forms: application_forms.map { |application_form| Flex::ApplicationFormPresenter.new(@view_context, application_form).index }
1718
}
1819
end
1920
end

template/{{app_name}}/engines/flex/app/presenters/flex/presenter.rb

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)