clair_app/app/controllers/admin/i_tasks_controller.rb
Nicolas Bally c2f8ec2efb initial
2020-10-10 00:28:38 +02:00

99 lines
1.2 KiB
Ruby

# -*- encoding : utf-8 -*-
class Admin::ITasksController < ApplicationController
layout "admin"
before_action :auth_admin
before_action :admin_space
def admin_space
@admin_space = "todos"
end
def index
@i_tasks = ITask.order("p_customer_id ASC").all
end
def show
@i_task = ITask.find(params[:id])
end
def new
@i_task = ITask.new
end
def edit
@i_task = ITask.find(params[:id])
end
def create
@i_task = ITask.new(params.require(:i_task).permit!)
if @i_task.name? and (tasks = @i_task.name.split(";")).size > 1
@all_tasks = []
tasks.each do |task|
t = @i_task.dup
t.name = task.lstrip
t.save
@all_tasks << t
end
else
if @i_task.save
else
render action: "new"
end
end
end
def update
@i_task = ITask.find(params[:id])
if @i_task.update_attributes(params.require(:i_task).permit!)
else
render action: "edit"
end
end
def destroy
@i_task = ITask.find(params[:id])
@i_task.destroy
end
end