Class: Lesli::Items::TasksController
Instance Attribute Summary
#engine_path, #query
Instance Method Summary
collapse
#log
#set_customizer
#respond_with_action, #respond_with_http, #respond_with_json, #respond_with_json_not_found, #respond_with_json_unauthorized, #respond_with_lesli, #respond_with_not_found, #respond_with_pagination, #respond_with_unauthorized, #stream_redirection
#set_locale, #set_requester
#initialize
Instance Method Details
#create ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/controllers/lesli/items/tasks_controller.rb', line 49
def create
task = task_class.new(task_params)
task.user = current_user
task.account = current_user.account
task.taskable = @taskable if @taskable
if task.save
respond_with_lesli(:turbo => [
stream_notification_success("Task created"),
turbo_stream.prepend("#{scope_key}-lesli-items-tasks-list") do
LesliView::Items::Task.new(task, scope_key).render_in(view_context)
end
])
else
respond_with_lesli(
:turbo => stream_notification_danger(task.errors.full_messages)
)
end
end
|
#index ⇒ Object
39
40
41
42
43
44
|
# File 'app/controllers/lesli/items/tasks_controller.rb', line 39
def index
@tasks = task_class
.where(account: current_user.account)
.order(created_at: :desc)
respond_with_lesli(json: @tasks)
end
|
#show ⇒ Object
46
47
|
# File 'app/controllers/lesli/items/tasks_controller.rb', line 46
def show
end
|
#update ⇒ Object
70
71
72
73
74
75
76
77
78
79
|
# File 'app/controllers/lesli/items/tasks_controller.rb', line 70
def update
@task.done = true
@task.save
respond_with_lesli(:turbo => [
stream_notification_success("Task updated #{@taskable}"),
turbo_stream.replace(helpers.dom_id(@task, scope_key)) do
LesliView::Items::Task.new(@task, scope_key).render_in(view_context)
end
])
end
|