checklists_controller.rb 964 B

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class ChecklistsController < ApplicationController
  3. prepend_before_action :authenticate_and_authorize!
  4. def show
  5. model_show_render(Checklist, existing_checklist_params)
  6. end
  7. def create
  8. ticket = Ticket.find params[:ticket_id]
  9. checklist = if params[:template_id].present?
  10. template = ChecklistTemplate.find(params[:template_id])
  11. Checklist.create_from_template!(ticket, template)
  12. else
  13. Checklist.create_fresh!(ticket)
  14. end
  15. render json: { id: checklist.id, assets: checklist.assets({}) }, status: :created
  16. end
  17. def update
  18. model_update_render(Checklist, existing_checklist_params)
  19. end
  20. def destroy
  21. model_destroy_render(Checklist, existing_checklist_params)
  22. end
  23. private
  24. def existing_checklist_params
  25. params.permit(:id, :name, sorted_item_ids: [])
  26. end
  27. end