Module: Card::Set::All::Html::Views::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb

Instance Method Summary collapse

Instance Method Details

#countObject



132
133
134
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 132

def count
  @count ||= card.count
end

#current_set_cardObject



91
92
93
94
95
96
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 91

def current_set_card
  set_name = params[:current_set]
  set_name ||= "#{card.name}+*type" if card.known? && card.type_id == Card::CardtypeID
  set_name ||= "#{card.name}+*self"
  Card.fetch(set_name)
end

#labeled(label, content) ⇒ Object



81
82
83
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 81

def labeled label, content
  haml :labeled, label: label, content: content
end

#labeled_field(field, item_view = :name, opts = {}) ⇒ Object



85
86
87
88
89
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 85

def labeled_field field, item_view=:name, opts={}
  opts[:title] ||= field.cardname
  field_nest field, opts.merge(view: :labeled,
                               items: (opts[:items] || {}).merge(view: item_view))
end

#prepare_content_slotObject



11
12
13
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 11

def prepare_content_slot
  class_up "card-slot", "d0-card-content"
end

#short_contentObject

LOCALIZE



99
100
101
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 99

def short_content
  short_content_items || short_content_fields || short_content_from_core
end

#short_content_fieldsObject



109
110
111
112
113
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 109

def short_content_fields
  with_short_content_fields do |num_fields|
    "#{num_fields} #{'field'.pluralize num_fields}" if num_fields.positive?
  end
end

#short_content_from_coreObject



119
120
121
122
123
124
125
126
127
128
129
130
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 119

def short_content_from_core
  content = render_core
  if content.blank?
    "empty"
  elsif content.size <= 5
    content
  elsif content.count("\n") < 2
    "#{content.size} characters"
  else
    "#{content.count("\n") + 1} lines"
  end
end

#short_content_itemsObject



103
104
105
106
107
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 103

def short_content_items
  return unless card.respond_to? :count

  "#{count} #{'item'.pluralize count}"
end

#view: contentObject



17
18
19
20
21
22
23
24
25
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 17

view :content, cache: :yes do
  wrap do
    [
      render_menu(optional: :hide),
      render_core,
      render_edit_button(optional: :hide, edit: :inline)
    ]
  end
end

#view: content_panelObject



54
55
56
57
58
59
60
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 54

view :content_panel do
  wrap do
    wrap_with :div, class: "card-body" do
      [render_menu, render_core]
    end
  end
end

#view: content_with_titleObject



43
44
45
46
47
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 43

view :content_with_title do
  wrap true, title: card.format(:text).render_core do
    [render_menu, render_core]
  end
end

#view: labeledObject

unlike unknown: true, unknown: (same view) can be overridden



74
75
76
77
78
79
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 74

view :labeled, unknown: :labeled, cache: :yes do
  @content_body = true
  wrap(true, class: "row") do
    [labeled(render_title, wrap_body { render_labeled_content }), render_menu]
  end
end

#view: one_line_contentObject



36
37
38
39
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 36

view :one_line_content, unknown: :mini_unknown,
                        wrap: { div: { class: "text-muted" } } do
  one_line_content
end

#view: raw_one_line_contentObject



31
32
33
34
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 31

view :raw_one_line_content, unknown: :mini_unknown,
                            wrap: { div: { class: "text-muted" } } do
  raw_one_line_content
end

#view: short_contentObject



27
28
29
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 27

view :short_content, wrap: { div: { class: "text-muted" } } do
  short_content
end

#view: titledObject



62
63
64
65
66
67
68
69
70
71
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 62

view :titled, cache: :yes do
  @content_body = true
  wrap do
    [
      naming { render_header },
      render_flash,
      wrap_body { render_titled_content }
    ]
  end
end

#with_short_content_fields {|nested_field_names.size| ... } ⇒ Object

Yields:

  • (nested_field_names.size)


115
116
117
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 115

def with_short_content_fields
  yield nested_field_names.size if voo.structure || card.structure
end