Module: Card::Set::Self::Trash::HtmlFormat

Extended by:
AbstractFormat
Defined in:
tmpsets/set/mod002-admin/self/trash.rb

Instance Method Summary collapse

Instance Method Details



39
40
41
42
43
44
45
46
47
48
49
# File 'tmpsets/set/mod002-admin/self/trash.rb', line 39

def empty_trash_link
  wrap_with(
    :p,
    button_link("empty trash",
                btn_type: :default,
                path: { mark: :admin, action: :update, task: :empty_trash,
                        success: { id: "~#{card.id}" } },
                "data-confirm" => "Are you sure you want to delete "\
                                  "all cards in the trash?")
  )
end


51
52
53
54
# File 'tmpsets/set/mod002-admin/self/trash.rb', line 51

def history_link trashed_card
  link_to_card trashed_card, "history",
               path: { view: :history, look_in_trash: true }
end


56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'tmpsets/set/mod002-admin/self/trash.rb', line 56

def restore_link trashed_card
  before_delete = trashed_card.actions[-2]
  link_to "restore", method: :post,
                     rel: "nofollow",
                     remote: true,
                     class: "slotter",
                     path: { id: trashed_card.id,
                             view: :open,
                             look_in_trash: true,
                             action: :update,
                             restore: trashed_card.id,
                             action_ids: [before_delete],
                             success: { id: "~#{card.id}" } }
end

#restoredObject



31
32
33
34
35
36
37
# File 'tmpsets/set/mod002-admin/self/trash.rb', line 31

def restored
  return unless (res_id = Env.params[:restore]) &&
                (res_card = Card[res_id.to_i])
  alert :success, true do
    wrap_with(:h5, "restored") + subformat(res_card).render_closed
  end
end

#trash_table_row(card) ⇒ Object



22
23
24
25
26
27
28
29
# File 'tmpsets/set/mod002-admin/self/trash.rb', line 22

def trash_table_row card
  [
    card.name,
    "#{time_ago_in_words(card.updated_at)} ago",
    Card[card.updater_id].name,
    "#{history_link(card)} | #{restore_link(card)}"
  ]
end

#trashed_cardsObject



18
19
20
# File 'tmpsets/set/mod002-admin/self/trash.rb', line 18

def trashed_cards
  Card.where(trash: true).order(updated_at: :desc)
end