Module: Card::Format::Nest::Mode
- Included in:
- Card::Format::Nest
- Defined in:
- lib/card/format/nest/mode.rb
Instance Method Summary collapse
-
#configured_view_in_closed_mode(view) ⇒ Symbol
the view configured in view definition for use when nested in closed mode.
- #hide_view_in_edit_mode?(view) ⇒ True/False
-
#modal_nest_view(view) ⇒ Symbol
view to be rendered in current mode.
-
#nest_mode ⇒ Symbol
current nest mode.
-
#view_in_closed_mode(view) ⇒ Symbol
the view that should be used when nested in closed mode.
-
#view_in_edit_mode(view) ⇒ Symbol
Returns the view that the card should use when nested in edit mode.
-
#with_nest_mode(new_mode) ⇒ Object
run block with new_mode as nest_mode, then return to prior mode.
Instance Method Details
#configured_view_in_closed_mode(view) ⇒ Symbol
the view configured in view definition for use when nested in closed mode
67 68 69 70 71 |
# File 'lib/card/format/nest/mode.rb', line 67 def configured_view_in_closed_mode view closed_config = Card::Format.closed[view] return view if closed_config == true || Card::Format.error_code[view] closed_config end |
#hide_view_in_edit_mode?(view) ⇒ True/False
51 52 53 54 55 |
# File 'lib/card/format/nest/mode.rb', line 51 def hide_view_in_edit_mode? view Card::Format.perms[view] == :none || # view never edited card.structure || # not yet nesting structures card.key.blank? # eg {{_self|type}} on new cards end |
#modal_nest_view(view) ⇒ Symbol
view to be rendered in current mode
32 33 34 35 36 37 38 39 40 |
# File 'lib/card/format/nest/mode.rb', line 32 def modal_nest_view view # Note: the subformat always has the same nest_mode as its parent format case nest_mode when :edit then view_in_edit_mode(view) when :template then :template_rule when :closed then view_in_closed_mode(view) else view end end |
#nest_mode ⇒ Symbol
current nest mode
14 15 16 |
# File 'lib/card/format/nest/mode.rb', line 14 def nest_mode @nest_mode ||= parent ? parent.nest_mode : :normal end |
#view_in_closed_mode(view) ⇒ Symbol
the view that should be used when nested in closed mode
60 61 62 |
# File 'lib/card/format/nest/mode.rb', line 60 def view_in_closed_mode view configured_view_in_closed_mode(view) || (card.known? ? :closed_content : :closed_missing) end |
#view_in_edit_mode(view) ⇒ Symbol
Returns the view that the card should use when nested in edit mode
45 46 47 |
# File 'lib/card/format/nest/mode.rb', line 45 def view_in_edit_mode view hide_view_in_edit_mode?(view) ? :blank : :edit_in_form end |
#with_nest_mode(new_mode) ⇒ Object
run block with new_mode as nest_mode, then return to prior mode
21 22 23 24 25 26 27 |
# File 'lib/card/format/nest/mode.rb', line 21 def with_nest_mode new_mode old_mode = nest_mode @nest_mode = new_mode result = yield @nest_mode = old_mode result end |