Module: Card::Set::All::Comment::Format

Extended by:
Card::Set::AbstractFormat
Defined in:
card/tmpsets/set/mod022-card-mod-comment/all/comment.rb,
card/tmpsets/set/mod023-card-mod-comment/all/comment.rb

Instance Method Summary collapse

Instance Method Details

#comment_authorObject



44
45
46
47
48
49
50
# File 'card/tmpsets/set/mod022-card-mod-comment/all/comment.rb', line 44

def comment_author
  if Auth.signed_in?
    "[[#{Auth.current.name}]]"
  else
    "#{card.comment_author} (Not signed in)"
  end
end

#comment_author_labelObject



79
80
81
82
# File 'card/tmpsets/set/mod022-card-mod-comment/all/comment.rb', line 79

def comment_author_label
  return if Auth.signed_in?
  %(<label>My Name is:</label> #{text_field :comment_author})
end

#comment_boxObject



69
70
71
# File 'card/tmpsets/set/mod022-card-mod-comment/all/comment.rb', line 69

def comment_box
  text_area :comment, rows: 3
end

#comment_buttonsObject



73
74
75
76
77
# File 'card/tmpsets/set/mod022-card-mod-comment/all/comment.rb', line 73

def comment_buttons
  wrap_with :div, class: "comment-buttons" do
    [comment_author_label, comment_submit_button]
  end
end

#comment_signatureObject



38
39
40
41
42
# File 'card/tmpsets/set/mod022-card-mod-comment/all/comment.rb', line 38

def comment_signature
  wrap_with :div, class: "w-comment-author" do
    "#{comment_author}.....#{Time.zone.now}"
  end
end

#comment_submit_buttonObject



84
85
86
# File 'card/tmpsets/set/mod022-card-mod-comment/all/comment.rb', line 84

def comment_submit_button
  submit_button text: "Comment", type: :submit, disable_with: "Commenting"
end

#comment_with_signatureObject



34
35
36
# File 'card/tmpsets/set/mod022-card-mod-comment/all/comment.rb', line 34

def comment_with_signature
  card.clean_comment + "\n" + comment_signature
end

#hidden_comment_fieldsObject



61
62
63
64
65
66
67
# File 'card/tmpsets/set/mod022-card-mod-comment/all/comment.rb', line 61

def hidden_comment_fields
  return unless card.new_card?
  hidden_field_tag "card[name]", card.name
  # FIXME: wish we had more generalized solution for names.
  # without this, nonexistent cards will often take left's linkname.
  # (needs test)
end

#view: comment_boxObject



52
53
54
55
56
57
58
59
# File 'card/tmpsets/set/mod022-card-mod-comment/all/comment.rb', line 52

view :comment_box, denial: :blank, unknown: true, perms: :update do
  wrap_with :div, class: "comment-box nodblclick" do
    action = card.new_card? ? :create : :update
    card_form action do
      [hidden_comment_fields, comment_box, comment_buttons]
    end
  end
end