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

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb

Instance Method Summary collapse

Instance Method Details

#comment_authorObject



45
46
47
48
49
50
51
# File 'platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb', line 45

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

#comment_author_labelObject



81
82
83
84
85
# File 'platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb', line 81

def comment_author_label
  return if Auth.signed_in?

  %(<label>My Name is:</label> #{text_field :comment_author})
end

#comment_boxObject



71
72
73
# File 'platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb', line 71

def comment_box
  text_area :comment, rows: 3
end

#comment_buttonsObject



75
76
77
78
79
# File 'platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb', line 75

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

#comment_signatureObject



39
40
41
42
43
# File 'platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb', line 39

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

#comment_submit_buttonObject



87
88
89
90
# File 'platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb', line 87

def comment_submit_button
  submit_button text: "Comment", type: :submit, disable_with: "Commenting",
                situation: "outline-primary"
end

#comment_with_signatureObject



35
36
37
# File 'platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb', line 35

def comment_with_signature
  "#{card.clean_comment}\n#{comment_signature}"
end

#hidden_comment_fieldsObject



62
63
64
65
66
67
68
69
# File 'platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb', line 62

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



53
54
55
56
57
58
59
60
# File 'platypus/tmp/set/gem-defaults/mod025-comment/all/comment.rb', line 53

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