Module: Card::Set::Type::Cardtype::HtmlFormat

Extended by:
AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod004-format/type/cardtype.rb,
platypus/tmp/set/gem-defaults/mod009-search/type/cardtype.rb,
platypus/tmp/set/gem-defaults/mod028-follow/type/cardtype.rb

Instance Method Summary collapse

Instance Method Details

#add_autocomplete_item_pathObject



20
21
22
# File 'platypus/tmp/set/gem-defaults/mod009-search/type/cardtype.rb', line 20

def add_autocomplete_item_path
  path action: :new
end


29
30
31
32
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/cardtype.rb', line 29

def add_link opts={}
  voo.title ||= t(:format_add_card, cardname: safe_name)
  link_to render_title, add_link_opts(opts)
end


34
35
36
37
38
39
40
41
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/cardtype.rb', line 34

def add_link_opts opts
  modal = opts.delete :modal
  if modal.nil? || modal
    modal_link_opts opts.merge(path: add_path(:new_in_modal))
  else
    opts.merge path: add_path(:new)
  end
end

#add_path(view) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/cardtype.rb', line 47

def add_path view
  path_args = { mark: card.name }
  process_voo_params(path_args) if voo.params
  if view == :new
    path_args[:action] = :new
  else
    path_args[:action] = :type
    path_args[:view] = view
  end
  path path_args
end

#can_configure?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/cardtype.rb', line 64

def can_configure?
  Card.fetch(card, :type, :structure, new: {}).ok? :update
end


72
73
74
75
76
77
78
79
80
81
82
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/cardtype.rb', line 72

def configure_link css_class=nil
  return "" unless Card.fetch(card, :type, :structure, new: {}).ok? :update

  voo.title ||= t(:format_configure_card, cardname: safe_name.pluralize)
  title = _render_title
  link_to_card card, title,
               path: { view: :board,
                       board: { tab: :rules_tab },
                       set: Card::Name[safe_name, :type] },
               class: css_classes("configure-type-link ms-3", css_class)
end


25
26
27
# File 'platypus/tmp/set/gem-defaults/mod028-follow/type/cardtype.rb', line 25

def related_by_type_items
  super.unshift ["#{card.name} cards", [card, :type, :by_name], { mark: :absolute }]
end

#type_formgroup(args = {}) ⇒ Object



13
14
15
16
17
18
19
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/cardtype.rb', line 13

def type_formgroup args={}
  if card.cards_of_type_exist?
    wrap_with :div, t(:core_cards_exist, scope: "core", cardname: safe_name)
  else
    super
  end
end

#view: add_buttonObject



25
26
27
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/cardtype.rb', line 25

view :add_button do
  add_link class: "btn btn-secondary"
end


21
22
23
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/cardtype.rb', line 21

view :add_link do
  add_link
end

#view: add_urlObject



43
44
45
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/cardtype.rb', line 43

view :add_url do
  card_url _render_add_path
end

#view: configure_buttonObject



68
69
70
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/cardtype.rb', line 68

view :configure_button, cache: :never, denial: :blank, perms: :can_configure? do
  configure_link "btn btn-secondary"
end

don’t cache because it depends on update permission for another card



60
61
62
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/cardtype.rb', line 60

view :configure_link, cache: :never, perms: :can_configure? do
  configure_link
end

#view: typeObject



9
10
11
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/cardtype.rb', line 9

view :type, unknown: true do
  link_to_card card.type_card, nil, class: "cardtype"
end