Module: Card::Set::All::Content

Extended by:
Card::Set
Defined in:
card/tmpsets/set/mod002-core/all/content.rb

Overview

Set: All cards (Content)

Defined Under Namespace

Modules: Format, HtmlFormat

Constant Summary

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Constants included from Event::Api

Event::Api::OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset_modules

Methods included from I18nScope

#mod_name, #scope

Methods included from Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set

Methods included from Helpers

#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscore

Methods included from Card::Set::AdvancedApi

#attachment, #define_set_from_error, #ensure_set, #setting_opts, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket, #unshift_basket

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/core/set/all/content.rb"; end

Instance Method Details

#blank_comment?Boolean

Returns:

  • (Boolean)


183
184
185
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 183

def blank_comment?
  comment.blank? || comment.strip.blank?
end

#blank_content?Boolean

Returns:

  • (Boolean)


179
180
181
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 179

def blank_content?
  content.blank? || content.strip.blank?
end

#clean_html?Boolean

Returns:

  • (Boolean)


167
168
169
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 167

def clean_html?
  true
end

#clear_draftsObject



124
125
126
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 124

def clear_drafts
  drafts.created_by(Card::Auth.current_id).each(&:delete)
end

#contentObject Also known as: raw_content



12
13
14
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 12

def content
  structured_content || standard_content
end

#content=(value) ⇒ Object



8
9
10
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 8

def content= value
  self.db_content = standardize_content(value)
end

#content?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 17

def content?
  content.present?
end

#creatorObject



112
113
114
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 112

def creator
  Card[creator_id]
end

#draft?Boolean

Returns:

  • (Boolean)


149
150
151
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 149

def draft?
  Env.params["draft"] == "true"
end

#event: save_draftObject



138
139
140
141
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 138

event :save_draft, :store, on: :update, when: :draft? do
  save_content_draft content
  abort :success
end

#event: set_contentObject



132
133
134
135
136
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 132

event :set_content, :store, on: :save do
  self.db_content = prepare_db_content
  @selected_action_id = @selected_content = nil
  clear_drafts
end

#event: set_default_contentObject



143
144
145
146
147
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 143

event :set_default_content,
      :prepare_to_validate,
      on: :create, when: :use_default_content? do
  self.db_content = template.db_content
end

#labelObject

seems like this should be moved to format so we can fall back on title rather than name. (In fact, name, title, AND label is a bit much. Trim to 2?)



108
109
110
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 108

def label
  name
end

#last_draft_contentObject



128
129
130
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 128

def last_draft_content
  drafts.last.card_changes.last.value
end

#prepare_db_contentObject



153
154
155
156
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 153

def prepare_db_content
  cont = standard_db_content || "" # necessary?
  clean_html? ? Card::Content.clean!(cont) : cont
end

#refresh_contentObject



33
34
35
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 33

def refresh_content
  self.content = Card.find(id)&.db_content
end

#save_content_draft(_content) ⇒ Object



120
121
122
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 120

def save_content_draft _content
  clear_drafts
end

#standard_contentObject



21
22
23
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 21

def standard_content
  db_content || (new_card? && template.db_content)
end

#standard_db_contentObject



158
159
160
161
162
163
164
165
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 158

def standard_db_content
  if structure
    # do not override db_content with content from structure
    db_content
  else
    standard_content
  end
end

#standardize_content(value) ⇒ Object



25
26
27
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 25

def standardize_content value
  value.is_a?(Array) ? value.join("\n") : value
end

#structured_contentObject



29
30
31
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 29

def structured_content
  structure && template.db_content
end

#unfilled?Boolean

Returns:

  • (Boolean)


175
176
177
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 175

def unfilled?
  blank_content? && blank_comment? && !subcards?
end

#updaterObject



116
117
118
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 116

def updater
  Card[updater_id]
end

#use_default_content?Boolean

Returns:

  • (Boolean)


171
172
173
# File 'card/tmpsets/set/mod002-core/all/content.rb', line 171

def use_default_content?
  !db_content_changed? && template && template.db_content.present?
end