Class: Voom::Presenters::DSL::UserInterface
- Inherits:
-
Object
- Object
- Voom::Presenters::DSL::UserInterface
- Extended by:
- Pluggable
- Includes:
- Components::Mixins::Attaches, Components::Mixins::Common, Components::Mixins::DateTimeFields, Components::Mixins::Dialogs, Components::Mixins::Event, Components::Mixins::Helpers, Components::Mixins::Icons, Components::Mixins::Snackbars, Components::Mixins::TextFields, Definer, ProtectFromForgery, Serializer, Trace
- Defined in:
- lib/voom/presenters/dsl/user_interface.rb
Constant Summary
Constants included from ProtectFromForgery
ProtectFromForgery::AUTHENTICITY_TOKEN_LENGTH
Instance Attribute Summary collapse
-
#components ⇒ Object
readonly
Returns the value of attribute components.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes included from Components::Mixins::Event
Instance Method Summary collapse
- #attach(presenter, **params, &yield_block) ⇒ Object
- #csrf_meta_tags ⇒ Object
- #drawer(name = nil, **attribs, &block) ⇒ Object
-
#expand_instance(freeze: true) ⇒ Object
Called by the definition.expand method to evaluate a user interface with a different context This should be made unavailable to the dsl.
- #footer(**attribs, &block) ⇒ Object
- #header(title = nil, **attribs, &block) ⇒ Object
-
#initialize(context:, parent: nil, router: nil, name: nil, namespace: [], &block) ⇒ UserInterface
constructor
A new instance of UserInterface.
- #page(title = nil, **attribs, &block) ⇒ Object
- #plugin(*plugin_names) ⇒ Object
- #plugins ⇒ Object (also: #_plugins_)
- #progress(**attributes, &block) ⇒ Object
- #type ⇒ Object
- #url(**context_) ⇒ Object
Methods included from Pluggable
include_plugins, plugin_module
Methods included from Serializer
Methods included from Components::Mixins::Event
Methods included from Namespace
Methods included from Components::Mixins::DateTimeFields
#date_field, #datetime_field, #time_field
Methods included from Components::Mixins::TextFields
#hidden_field, #number_field, #rich_text_area, #text_area, #text_field
Methods included from Components::Mixins::Icons
Methods included from Components::Mixins::Snackbars
Methods included from Components::Mixins::Dialogs
Methods included from Components::Mixins::Helpers
Methods included from Components::Mixins::Common
#avatar, #badge, #card, #form, #list, #table, #unordered_list
Methods included from Components::Mixins::Tables
Methods included from Components::Mixins::ImageLists
Methods included from Components::Mixins::Images
Methods included from Components::Mixins::TabBars
Methods included from Components::Mixins::Menus
Methods included from Components::Mixins::Content
Methods included from Components::Mixins::ExpansionPanels
Methods included from Components::Mixins::Buttons
Methods included from Components::Mixins::Grids
Methods included from Components::Mixins::Typography
#blank, #body, #body2, #caption, #headline, #headline1, #headline2, #headline3, #headline4, #headline5, #headline6, #link, #overline, #page_title, #separator, #subtitle, #subtitle2, #text, #title
Methods included from Components::Mixins::Append
Methods included from Components::Mixins::Toggles
#checkbox, #icon_toggle, #radio_button, #switch
Methods included from ProtectFromForgery
#authenticity_token_meta_tags, #form_authenticity_token, #xor_byte_strings
Constructor Details
#initialize(context:, parent: nil, router: nil, name: nil, namespace: [], &block) ⇒ UserInterface
Returns a new instance of UserInterface.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 28 def initialize(context:, parent: nil, router: nil, name: nil, namespace: [], &block) @parent = parent @router = router || @parent&.send(:router) @context = context || {} @block = block @header = nil @drawer = nil @components = [] @footer = nil @name = name @namespace = namespace @plugins = [] @csrf_meta_tags = (@context.fetch(:session, nil)) add_global_helpers initialize_plugins end |
Instance Attribute Details
#components ⇒ Object (readonly)
Returns the value of attribute components.
24 25 26 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 24 def components @components end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 24 def name @name end |
Instance Method Details
#attach(presenter, **params, &yield_block) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 73 def attach(presenter, **params, &yield_block) pom = super @header ||= pom.header @drawer ||= pom.drawer @footer ||= pom. end |
#csrf_meta_tags ⇒ Object
112 113 114 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 112 def Presenters::Settings.config.presenters.web_client.protect_from_forgery ? @csrf_meta_tags : nil end |
#drawer(name = nil, **attribs, &block) ⇒ Object
56 57 58 59 60 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 56 def drawer(name = nil, **attribs, &block) return @drawer if locked? @drawer = Components::Drawer.new(parent: self, title: name, **attribs, &block) end |
#expand_instance(freeze: true) ⇒ Object
Called by the definition.expand method to evaluate a user interface with a different context This should be made unavailable to the dsl
82 83 84 85 86 87 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 82 def (freeze: true) instance_eval(&@block) lock! deep_freeze if freeze self end |
#footer(**attribs, &block) ⇒ Object
63 64 65 66 67 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 63 def (**attribs, &block) return @footer if locked? @footer = Components::Footer.new(parent: self, **attribs, &block) end |
#header(title = nil, **attribs, &block) ⇒ Object
50 51 52 53 54 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 50 def header(title = nil, **attribs, &block) return @header if locked? @header = Components::Header.new(parent: self, title: title, **attribs, &block) end |
#page(title = nil, **attribs, &block) ⇒ Object
45 46 47 48 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 45 def page(title = nil, **attribs, &block) return @page if locked? @page = Components::Page.new(parent: self, **attribs, &block) end |
#plugin(*plugin_names) ⇒ Object
101 102 103 104 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 101 def plugin(*plugin_names) @plugins.push(*plugin_names) self.class.include_plugins(:DSLComponents, :DSLHelpers, plugins: plugin_names) end |
#plugins ⇒ Object Also known as: _plugins_
106 107 108 109 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 106 def plugins return @plugins if locked? return @plugins if @plugins end |
#progress(**attributes, &block) ⇒ Object
69 70 71 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 69 def progress(**attributes, &block) self << Components::Progress.new(parent: self, **attributes, &block) end |
#type ⇒ Object
97 98 99 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 97 def type :presenter end |
#url(**context_) ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/voom/presenters/dsl/user_interface.rb', line 89 def url(**context_) return '#' unless @router context = context_.dup link_to = context.delete(:link) post_to = context.delete(:command) @router.url(render: link_to, command: post_to, context: context) end |