lib/voom/presenters/dsl/user_interface.rb in voom-presenters-0.1.13 vs lib/voom/presenters/dsl/user_interface.rb in voom-presenters-0.2.0
- old
+ new
@@ -1,14 +1,15 @@
require 'ice_nine'
-require_relative 'definer'
-require_relative 'components/mixins/common'
-require_relative 'components/mixins/helpers'
-require_relative 'components/mixins/dialogs'
-require_relative 'components/mixins/snackbars'
-require_relative 'components/mixins/text_fields'
-require_relative 'components/mixins/date_time_fields'
-require_relative 'invalid_presenter'
+require 'voom/presenters/dsl/definer'
+require 'voom/presenters/dsl/components/mixins/common'
+require 'voom/presenters/dsl/components/mixins/helpers'
+require 'voom/presenters/dsl/components/mixins/dialogs'
+require 'voom/presenters/dsl/components/mixins/snackbars'
+require 'voom/presenters/dsl/components/mixins/text_fields'
+require 'voom/presenters/dsl/components/mixins/date_time_fields'
+require 'voom/presenters/dsl/components/mixins/attaches'
+require 'voom/presenters/dsl/invalid_presenter'
require 'voom/serializer'
require 'voom/trace'
@@ -22,66 +23,61 @@
include Components::Mixins::Dialogs
include Components::Mixins::Snackbars
include Components::Mixins::Icons
include Components::Mixins::TextFields
include Components::Mixins::DateTimeFields
+ include Components::Mixins::Attaches
-
include Voom::Serializer
include Voom::Trace
- attr_reader :router, :context, :components
- private :context, :router
+ attr_reader :router, :context, :components, :namespace
+ private :context, :router, :namespace
alias params context
- def initialize(parent: nil, router: nil, context:, &block)
+ def initialize(context:, parent: nil, router: nil, namespace: [], &block)
@parent = parent
@router = router || @parent&.send(:router)
@context = context
@block = block
@header = nil
@drawer = nil
@components = []
@footer = nil
+ @namespace = namespace
add_global_helpers
end
def page(title=nil, **attribs, &block)
return @page if locked?
- @page = Components::Page.new(parent: self, context: context,
- **attribs, &block)
+ @page = Components::Page.new(parent: self, **attribs, &block)
end
def header(title=nil, **attribs, &block)
return @header if locked?
@header = Components::Header.new(parent: self, title: title,
- context: context,
**attribs, &block)
end
def drawer(name=nil, **attribs, &block)
return @drawer if locked?
@drawer = Components::Drawer.new(parent: self, title: name,
- context: context,
**attribs, &block)
end
def footer(**attribs, &block)
return @footer if locked?
@footer = Components::Footer.new(parent: self,
- context: context,
**attribs, &block)
end
- def attach(presenter, **context_, &yield_block)
- @_yield_block_ = yield_block
- pom = Voom::Presenters::App[presenter].call.expand_child(parent: self, context: context.merge(context_))
+ def attach(presenter, **params, &yield_block)
+ pom = super
@header ||= pom.header
@drawer ||= pom.drawer
@footer ||= pom.footer
- @components += pom.components
end
# Called by the definition.expand method to evaluate a user interface with a different context
# This should be made unavailable to the dsl
def expand_instance(freeze: true)