Add "Do" command

This commit is contained in:
Jorge Manrubia
2025-06-25 14:55:56 +02:00
parent 813f39b227
commit 1303dfb14e
2 changed files with 36 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
class Command::Do < Command
include Command::Cards
store_accessor :data, :statues_by_card_id
def title
"Move #{cards_description} to Doing"
end
def execute
statues_by_card_id = {}
transaction do
cards.find_each do |card|
statues_by_card_id[card.id] = { closed: card.closed?, doing: card.doing?, considering: card.considering? }
card.engage
end
update! statues_by_card_id: statues_by_card_id
end
end
def undo
transaction do
statues_by_card_id.each do |card_id, data|
if card = user.accessible_cards.find_by_id(card_id)
card.close if data["closed"]
card.engage if data["doing"]
card.reconsider if data["considering"]
end
end
end
end
end
+2
View File
@@ -31,6 +31,8 @@ class Command::Parser
Command::ClearFilters.new(params: filter.as_params)
when "/close"
Command::Close.new(card_ids: cards.ids, reason: combined_arguments)
when "/do"
Command::Do.new(card_ids: cards.ids)
when "/insight"
Command::GetInsight.new(query: combined_arguments, card_ids: cards.ids)
when "/search"