Add the ask command
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
class Command::Ask < Command
|
||||
store_accessor :data, :question, :card_ids
|
||||
|
||||
def title
|
||||
"Ask '#{question}'"
|
||||
end
|
||||
|
||||
def execute
|
||||
Current.user.resume_or_start_conversation(question)
|
||||
Command::Result::ShowModal.new(turbo_frame: "conversation", url: conversation_path)
|
||||
end
|
||||
end
|
||||
@@ -67,6 +67,8 @@ class Command::Parser
|
||||
Command::VisitUrl.new(url: command_arguments.first)
|
||||
when "/tag"
|
||||
Command::Tag.new(tag_title: tag_title_from(combined_arguments), card_ids: cards.ids)
|
||||
when "/ask"
|
||||
Command::Ask.new(question: combined_arguments, card_ids: cards.ids)
|
||||
when /^gid:\/\//
|
||||
parse_gid command_name
|
||||
else
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class Command::Result::ShowModal
|
||||
attr_reader :url, :turbo_frame
|
||||
|
||||
def initialize(url:, turbo_frame:)
|
||||
@url = url
|
||||
@turbo_frame = turbo_frame
|
||||
end
|
||||
|
||||
def as_json
|
||||
{ turbo_frame: turbo_frame, url: url }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user