You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.4 KiB
40 lines
1.4 KiB
# frozen_string_literal: true
|
|
|
|
module QuestionsCrafter
|
|
module Ui
|
|
module Components
|
|
class QuestionsPage < ::Phlex::HTML
|
|
include Phlex::Rails::Helpers::FormWith
|
|
include ActionView::Helpers::TextHelper # For pluralize
|
|
|
|
def initialize(questions_object:, form_url:, form_method:, read_only:)
|
|
@questions_object = questions_object
|
|
@form_url = form_url
|
|
@form_method = form_method
|
|
@read_only = read_only
|
|
@custom_html_classes = @questions_object.class.custom_html_classes
|
|
@css_manager = QuestionsCrafter::Ui::CssClassesManager.new(@custom_html_classes)
|
|
@class_prefix = QuestionsCrafter::Utils.html_class_name_prefix(questions: questions_object)
|
|
end
|
|
|
|
def view_template
|
|
div(class: css_classes(:page, :main)) do
|
|
h1(class: css_classes(:page, :title)) { @questions_object.class.title }
|
|
p(class: css_classes(:page, :description)) { @questions_object.class.description }
|
|
render QuestionsCrafter::Ui::Components::FormBuilder.new(
|
|
questions_object: @questions_object,
|
|
form_url: @form_url,
|
|
form_method: @form_method,
|
|
read_only: @read_only,
|
|
custom_html_classes: @custom_html_classes
|
|
)
|
|
end
|
|
end
|
|
|
|
def css_classes(section, key = nil)
|
|
@css_manager.get(section, key)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|