Module: Admin::FeedbackHelper

Defined in:
app/helpers/admin/feedback_helper.rb

Instance Method Summary collapse

Instance Method Details

#button_to_conversation(item) ⇒ Object



37
38
39
40
41
# File 'app/helpers/admin/feedback_helper.rb', line 37

def button_to_conversation(item)
  link_to((:span, "", class: "glyphicon glyphicon-share-alt"),
          { controller: "admin/feedback", action: "article", id: item.article_id },
          { class: "btn btn-default btn-xs btn-action" })
end

#button_to_delete_comment(item) ⇒ Object



31
32
33
34
35
# File 'app/helpers/admin/feedback_helper.rb', line 31

def button_to_delete_comment(item)
  link_to((:span, "", class: "glyphicon glyphicon-trash"),
          { controller: "admin/feedback", action: "destroy", id: item.id },
          { class: "btn btn-danger btn-xs btn-action" })
end

#button_to_edit_comment(item) ⇒ Object



25
26
27
28
29
# File 'app/helpers/admin/feedback_helper.rb', line 25

def button_to_edit_comment(item)
  link_to((:span, "", class: "glyphicon glyphicon-pencil"),
          { controller: "admin/feedback", action: "edit", id: item.id },
          { class: "btn btn-primary btn-xs btn-action" })
end

#change_status(item, context = "listing") ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'app/helpers/admin/feedback_helper.rb', line 43

def change_status(item, context = "listing")
  spammy = item.state.to_s.downcase =~ /spam/
  direction = spammy ? "up" : "down"
  button_type = spammy ? "success" : "warning"

  link_to((:span, "", class: "glyphicon glyphicon-thumbs-#{direction}"),
          { controller: "admin/feedback", action: "change_state",
            id: item.id, context: context },
          { class: "btn btn-#{button_type} btn-xs btn-action", remote: true })
end

#comment_class(state) ⇒ Object



4
5
6
7
8
9
10
# File 'app/helpers/admin/feedback_helper.rb', line 4

def comment_class(state)
  return "label-info" if state.to_s.casecmp("presumed_ham").zero?
  return "label-warning" if state.to_s.casecmp("presumed_spam").zero?
  return "label-success" if state.to_s.casecmp("ham").zero?

  "label-danger"
end

#show_feedback_actions(item, context = "listing") ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/admin/feedback_helper.rb', line 12

def show_feedback_actions(item, context = "listing")
  return unless can? :manage, "admin/feedback"

  (:div, class: "action", style: "") do
    safe_join [
      (:small, change_status(item, context)),
      button_to_edit_comment(item),
      button_to_delete_comment(item),
      button_to_conversation(item),
    ], " "
  end
end