Module: Glib::JsonUi::PageHelper

Defined in:
app/helpers/glib/json_ui/page_helper.rb

Defined Under Namespace

Classes: Page

Instance Method Summary collapse

Instance Method Details

#json_ui_action(json) ⇒ Object



50
51
52
53
# File 'app/helpers/glib/json_ui/page_helper.rb', line 50

def json_ui_action(json)
  @__json_ui_action ||= Page.new(json, self)
  @__json_ui_action.action_builder
end

#json_ui_action_payload(&block) ⇒ Object

def json_ui_view(json)

@__json_ui_view ||= Page.new(json, self)
@__json_ui_view.view_builder

end



60
61
62
63
64
# File 'app/helpers/glib/json_ui/page_helper.rb', line 60

def json_ui_action_payload(&block)
  dataJson = Jbuilder.new
  block&.call Page.new(dataJson, self).action_builder
  dataJson.attributes!
end

#json_ui_garage_current_url(options = {}) ⇒ Object



13
14
15
# File 'app/helpers/glib/json_ui/page_helper.rb', line 13

def json_ui_garage_current_url(options = {})
  json_ui_garage_url(options.merge(path: params[:path]))
end

#json_ui_garage_url(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
# File 'app/helpers/glib/json_ui/page_helper.rb', line 4

def json_ui_garage_url(options = {})
  Glib::Web::Engine.routes.url_helpers.json_ui_garage_url(options.merge(
                                                            protocol: request.protocol,
                                                            host: request.host,
                                                            port: request.port,
                                                            _render: params[:_render], format: params[:format])
  )
end

#json_ui_page(json, &block) ⇒ Object

TODO: Remove the block



18
19
20
21
22
23
24
25
# File 'app/helpers/glib/json_ui/page_helper.rb', line 18

def json_ui_page(json, &block)
  @__json_ui_page ||= Page.new(json, self)

  __json_ui_analytics(json)

  block&.call @__json_ui_page
  @__json_ui_page
end

#json_ui_section(json) ⇒ Object

# Use this only if you need to generate json independently from the current `json_ui_page` def json_ui_panel(&block)

@__json_ui_panel_page ||= Page.new(Jbuilder.new, self)
json = @__json_ui_panel_page.json
json.nil!
block&.call @__json_ui_panel_page.view_builder
json.attributes!

end



45
46
47
48
# File 'app/helpers/glib/json_ui/page_helper.rb', line 45

def json_ui_section(json)
  @__json_ui_section ||= Page.new(json, self)
  @__json_ui_section.list_section_builder
end