Module: Card::Format::Nest::View
- Included in:
- Card::Format::Nest
- Defined in:
- lib/card/format/nest/view.rb
Overview
Renders views for a nests
Instance Method Summary collapse
- #hide_view_in_edit_mode?(view) ⇒ Boolean
-
#modal_nest_view(view) ⇒ Object
private.
-
#view_in_closed_mode(view) ⇒ Object
Return the view that the card should use if nested in closed mode.
-
#view_in_edit_mode(homeview) ⇒ Object
Returns the view that the card should use if nested in edit mode.
- #with_nest_mode(mode) ⇒ Object
Instance Method Details
#hide_view_in_edit_mode?(view) ⇒ Boolean
40 41 42 43 44 |
# File 'lib/card/format/nest/view.rb', line 40 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) ⇒ Object
private
24 25 26 27 28 29 30 31 32 |
# File 'lib/card/format/nest/view.rb', line 24 def modal_nest_view view # Note: the subformat always has the same @mode as its parent format case @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 |
#view_in_closed_mode(view) ⇒ Object
Return the view that the card should use if nested in closed mode
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/card/format/nest/view.rb', line 48 def view_in_closed_mode view approved_view = Card::Format.closed[view] if approved_view == true view elsif Card::Format.error_code[view] view elsif approved_view approved_view elsif !card.known? :closed_missing else :closed_content end end |
#view_in_edit_mode(homeview) ⇒ Object
Returns the view that the card should use if nested in edit mode
36 37 38 |
# File 'lib/card/format/nest/view.rb', line 36 def view_in_edit_mode homeview hide_view_in_edit_mode?(homeview) ? :blank : :edit_in_form end |
#with_nest_mode(mode) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/card/format/nest/view.rb', line 12 def with_nest_mode mode old_mode = @mode if (switch_mode = NEST_MODES[mode]) @mode = switch_mode end result = yield @mode = old_mode result end |