Add command to tag cards

This commit is contained in:
Jorge Manrubia
2025-05-07 16:48:33 +02:00
parent 31d0271952
commit b7f086d361
6 changed files with 111 additions and 17 deletions
+8 -7
View File
@@ -19,14 +19,16 @@ class Command::Parser
command_name, *command_arguments = string.strip.split(" ")
case command_name
when /^#/
Command::FilterByTag.new(tag_title: tag_title_from(string), params: filter.as_params)
when /^@/
Command::GoToUser.new(user_id: assignee_from(command_name)&.id)
when "/assign", "/assignto"
Command::Assign.new(assignee_ids: assignees_from(command_arguments).collect(&:id), card_ids: cards.ids)
when "/close"
Command::Close.new(card_ids: cards.ids, reason: command_arguments.join(" "))
when /^#/
Command::FilterByTag.new(tag_id: tag_from(string).id, params: filter.as_params)
when /^@/
Command::GoToUser.new(user_id: assignee_from(command_name)&.id)
when "/tag"
Command::Tag.new(tag_title: tag_title_from(command_arguments.join(" ")), card_ids: cards.ids)
else
parse_free_string(string)
end
@@ -46,9 +48,8 @@ class Command::Parser
User.all.find { |user| user.mentionable_handles.include?(string_without_at) }
end
def tag_from(string)
title = string.gsub(/^#/, "")
Tag.find_or_create_by!(title: title)
def tag_title_from(string)
string.gsub(/^#/, "")
end
def parse_free_string(string)