class Object

Public Instance Methods

alert_guide() click to toggle source
# File set/all/guide.rb, line 25
def alert_guide
  guide_text = guide
  return "" unless guide_text.present?

  alert(:secondary, true, false, class: "guide") { guide_text }
end
guide() click to toggle source
# File set/all/guide.rb, line 14
def guide
  guide_text = rule_based_guide
  return "" unless guide_text.present?

  if (rule_card = card.help_rule_card)
    edit_link = with_nest_mode(:normal) { nest(rule_card, view: :edit_link) }
    guide_text = "<span class='d-none'>#{edit_link}</span>#{guide_text}"
  end
  wrap_with :div, guide_text, class: classy("guide-text")
end
guide_card() click to toggle source
# File set/all/guide.rb, line 1
def guide_card
  guide_card = rule_card(:guide)
  return unless guide_card

  guide_card = guide_card.first_card if guide_card.type_id == Card::PointerID
  guide_card if guide_card.ok?(:read)
end
help_rule_card() click to toggle source
# File set/all/help.rb, line 1
def help_rule_card
  help_card = rule_card(:help)
  help_card if help_card&.ok?(:read)
end
help_text() click to toggle source
# File set/all/help.rb, line 32
def help_text
  voo.help || rule_based_help
end
quick_editor() click to toggle source
# File set/right/help.rb, line 8
def quick_editor
  # TODO: refactor when voo.input_type is ready.  (and use class_up)
  formgroup "Content", input: :content, help: false do
    text_field :content, value: card.content,
                         class: "d0-card-content _submit-after-typing"
  end
end
raw_guide_text() click to toggle source
# File set/all/guide.rb, line 32
def raw_guide_text
  false
end
raw_help_text() click to toggle source
# File set/all/help.rb, line 36
def raw_help_text
  card.try(:raw_help_text) || card.help_rule_card&.content
end
rule_based_guide() click to toggle source
# File set/all/guide.rb, line 36
def rule_based_guide
  if raw_guide_text
    with_nest_mode :normal do
      process_content raw_guide_text, chunk_list: :references
      # render guide text with current card's format
      # so current card's context is used in guide card nests
    end
  elsif card.guide_card
    with_nest_mode :normal do
      nest card.guide_card, view: :core
    end
  else
    ""
  end
end
rule_based_help() click to toggle source
# File set/all/help.rb, line 40
def rule_based_help
  return "" unless (help_text = raw_help_text)

  with_nest_mode :normal do
    process_content help_text, chunk_list: :references
    # render help card with current card's format
    # so current card's context is used in help card nests
  end
end
wrap_help_text(text) click to toggle source
# File set/all/help.rb, line 18
def wrap_help_text text
  help = text
  if (rule_card = card.help_rule_card)
    edit_link = with_nest_mode(:normal) { nest(rule_card, view: :edit_link) }
    help = "<span class='d-none'>#{edit_link}</span>#{text}"
  end
  help
end