ticket_shared_draft_zoom_controller.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class TicketSharedDraftZoomController < ApplicationController
  3. prepend_before_action :authorize!
  4. prepend_before_action :authentication_check
  5. def show
  6. object = ticket.shared_draft
  7. render json: {
  8. shared_draft_id: object&.id,
  9. assets: object&.assets,
  10. }
  11. end
  12. def update
  13. if ticket.shared_draft.present?
  14. object = ticket.shared_draft
  15. object.update! draft_params
  16. else
  17. object = ticket.create_shared_draft! draft_params
  18. end
  19. object.attach_upload_cache params[:form_id]
  20. render json: {
  21. shared_draft_id: object.id,
  22. assets: object.assets,
  23. }
  24. end
  25. def destroy
  26. object = ticket.shared_draft
  27. object.destroy!
  28. render json: {
  29. shared_draft_id: object.id
  30. }
  31. end
  32. def import_attachments
  33. new_attachments = ticket.shared_draft.clone_attachments 'UploadCache', params[:form_id]
  34. render json: {
  35. attachments: new_attachments
  36. }
  37. end
  38. private
  39. def ticket
  40. Ticket.find params[:ticket_id]
  41. end
  42. def draft_params
  43. params.permit ticket_attributes: {}, new_article: {}
  44. end
  45. end