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



161
162
163
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 161

def count
  @count ||= card.count
end

#current_set_cardObject



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

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



89
90
91
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 89

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

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



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

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

#prepare_content_slotObject



11
12
13
14
# 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"
  voo.hide :menu
end

#short_contentObject

LOCALIZE



128
129
130
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 128

def short_content
  short_content_items || short_content_fields || short_content_from_core
end

#short_content_fieldsObject



138
139
140
141
142
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 138

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



148
149
150
151
152
153
154
155
156
157
158
159
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 148

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



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

def short_content_items
  return unless card.respond_to? :count

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

#toggle_logicObject



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

def toggle_logic
  show_view?(:title_link, :hide) ? voo.show(:icon_toggle) : voo.show(:title_toggle)
end

#view: closedObject



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

view :closed do
  with_nest_mode :compact do
    toggle_logic
    class_up "d0-card-body", "closed-content"
    @content_body = false
    @toggle_mode = :close
    frame
  end
end

#view: contentObject



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

view :content do
  voo.hide :edit_button
  wrap do
    [render_menu, render_core, render_edit_button(edit: :inline)]
  end
end

#view: content_panelObject



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

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

#view: content_with_edit_buttonObject



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

view :content_with_edit_button, unknown: true do
  wrap do
    [render_menu, render_core, render_edit_button(edit: :inline)]
  end
end

#view: content_with_titleObject



51
52
53
54
55
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 51

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



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

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

#view: one_line_contentObject



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

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

#view: openObject



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

view :open do
  toggle_logic
  @toggle_mode = :open
  @content_body = true
  frame { _render_open_content }
end

#view: raw_one_line_contentObject



39
40
41
42
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 39

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

#view: short_contentObject



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

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

#view: titledObject



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

view :titled 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)


144
145
146
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/views.rb', line 144

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