Sha256: 2c9ce47b6f1b684d9fa2d5f45af99bded455245d3f0d1bb9c924e0eb11663f40

Contents?: true

Size: 1.5 KB

Versions: 4

Compression:

Stored size: 1.5 KB

Contents

::Card.error_codes[:conflict] = [:conflict, 409]


def content= value
  self.db_content = value
end

def content
  structured_content || standard_content
end
alias raw_content content #DEPRECATED!

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

def structured_content
  structure && template.db_content
end

format do
  def chunk_list # override to customize by set
    :default
  end
end

format :html do
  view :hidden_content_field, tags: :unknown_ok do
    hidden_field :content, class: "d0-card-content"
  end
end

def label
  name
end

def creator
  Card[creator_id]
end

def updater
  Card[updater_id]
end

def clean_html?
  true
end

def save_content_draft _content
  clear_drafts
end

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

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

event :set_content, :store, on: :save do
  self.db_content = standard_content || "" # necessary?
  self.db_content = Card::Content.clean!(db_content) if clean_html?
  @selected_action_id = @selected_content = nil
  clear_drafts
  reset_patterns_if_rule true
end

event :save_draft, :store,
      on: :update, when: proc { Env.params["draft"] == "true" } do
  save_content_draft content
  abort :success
end

event :set_default_content, :prepare_to_validate,
      on: :create, when: proc { |c| c.use_default_content? } do
  self.db_content = template.db_content
end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
card-1.93.3 mod/core/set/all/content.rb
card-1.93.2 mod/core/set/all/content.rb
card-1.93.1 mod/core/set/all/content.rb
card-1.93.0 mod/core/set/all/content.rb