Class: Dorsale::Flyboy::TasksController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- ApplicationController
- Dorsale::Flyboy::TasksController
- Includes:
- TasksSummaryConcern
- Defined in:
- app/controllers/dorsale/flyboy/tasks_controller.rb
Instance Method Summary collapse
- #complete ⇒ Object
- #copy ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #snooze ⇒ Object
- #summary ⇒ Object
- #update ⇒ Object
Methods included from TasksSummaryConcern
Methods inherited from ApplicationController
Instance Method Details
#complete ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'app/controllers/dorsale/flyboy/tasks_controller.rb', line 90 def complete @task, :complete? @task_comment ||= @task.comments.new( :progress => 100, :description => t("messages.tasks.complete_ok"), :date => Time.zone.now, :author => current_user, ) if @task_comment.save flash[:success] = t("messages.tasks.complete_ok") else flash[:danger] = t("messages.tasks.complete_error") end redirect_to back_url end |
#copy ⇒ Object
123 124 125 126 127 128 129 |
# File 'app/controllers/dorsale/flyboy/tasks_controller.rb', line 123 def copy @task, :copy? @original = @task @task = Dorsale::Flyboy::Task::Copy.(@original) render :new end |
#create ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/dorsale/flyboy/tasks_controller.rb', line 47 def create @task ||= scope.new(task_params) @task, :create? if @task.save flash[:success] = t("messages.tasks.create_ok") notify_owner(current_user, @task) redirect_to back_url else render :new end end |
#destroy ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/dorsale/flyboy/tasks_controller.rb', line 78 def destroy @task, :delete? if @task.destroy flash[:success] = t("messages.tasks.delete_ok") else flash[:danger] = t("messages.tasks.delete_error") end redirect_to url_for(action: :index, id: nil) end |
#edit ⇒ Object
61 62 63 |
# File 'app/controllers/dorsale/flyboy/tasks_controller.rb', line 61 def edit @task, :update? end |
#index ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/dorsale/flyboy/tasks_controller.rb', line 14 def index model, :list? @tasks ||= scope.all.preload(:taskable, :taggings) @filters ||= ::Dorsale::Flyboy::SmallData::FilterForTasks.new(filters_jar) @tasks = @filters.apply(@tasks) @tasks = @tasks.search(params[:q]) @tasks_without_pagination = @tasks @tasks = Dorsale::Flyboy::TasksSorter.(@tasks, params["sort"] ||= "term") if @tasks.is_a?(ActiveRecord::Relation) @tasks = @tasks.page(params[:page]) else @tasks = Kaminari.paginate_array(@tasks).page(params[:page]) end end |
#new ⇒ Object
39 40 41 42 43 44 45 |
# File 'app/controllers/dorsale/flyboy/tasks_controller.rb', line 39 def new @task ||= scope.new @task.owner ||= current_user @task.taskable_guid = params[:taskable_guid] @task, :create? end |
#show ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/controllers/dorsale/flyboy/tasks_controller.rb', line 31 def show @task, :read? @task_comments = @task.comments.preload(:author) @task_comments = Dorsale::Flyboy::TaskCommentsSorter.(@task_comments, params[:sort] ||= "-date") end |
#snooze ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'app/controllers/dorsale/flyboy/tasks_controller.rb', line 109 def snooze @task, :snooze? previous_term = @task.term if @task.snoozer.snooze @task.create_term_changed_comment!(previous: previous_term, author: current_user) flash[:success] = t("messages.tasks.snooze_ok") else flash[:danger] = t("messages.tasks.snooze_error") end redirect_to back_url end |
#summary ⇒ Object
131 132 133 134 135 |
# File 'app/controllers/dorsale/flyboy/tasks_controller.rb', line 131 def summary model, :list? setup_tasks_summary end |
#update ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/dorsale/flyboy/tasks_controller.rb', line 65 def update @task, :update? previous_term = @task.term if @task.update(task_params) @task.create_term_changed_comment!(previous: previous_term, author: current_user) flash[:success] = t("messages.tasks.update_ok") redirect_to back_url else render :edit end end |