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

Extended by:
AbstractFormat
Defined in:
card/tmpsets/set/mod004-standard/type/cardtype.rb,
card/tmpsets/set/mod025-card-mod-follow/type/cardtype.rb,
card/tmpsets/set/mod007-card-mod-format/type/cardtype.rb,
card/tmpsets/set/mod026-card-mod-follow/type/cardtype.rb

Instance Method Summary collapse

Instance Method Details



35
36
37
38
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 35

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


40
41
42
43
44
45
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 40

def add_link_opts opts
  modal = opts.delete :modal
  modal = true if modal.nil?
  opts[:path] = add_path(modal ? :new_in_modal : :new)
  modal ? modal_link_opts(opts) : opts
end

#add_path(view) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 51

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)


68
69
70
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 68

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


77
78
79
80
81
82
83
84
85
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 77

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

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


25
26
27
# File 'card/tmpsets/set/mod025-card-mod-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



19
20
21
22
23
24
25
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 19

def type_formgroup args={}
  if card.cards_of_type_exist?
    wrap_with :div, tr(:cards_exist, cardname: safe_name)
  else
    super
  end
end

#view: add_buttonObject



31
32
33
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 31

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


27
28
29
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 27

view :add_link do
  add_link
end

#view: add_urlObject



47
48
49
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 47

view :add_url do
  card_url _render_add_path
end

#view: configure_buttonObject



72
73
74
75
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 72

view :configure_button, cache: :never, denial: :blank,
                        perms:  ->(fmt) { fmt.can_configure? } do
  configure_link "btn btn-secondary"
end

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



64
65
66
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 64

view :configure_link, cache: :never, perms: ->(fmt) { fmt.can_configure? } do
  configure_link
end

#view: typeObject



15
16
17
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 15

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