can_prioritize.rb 466 B

123456789101112131415161718
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. module CanPrioritize
  3. extend ActiveSupport::Concern
  4. def prio
  5. klass.without_callback(:update, :before, :rearrangement) do
  6. params[:prios].each do |entry_prio|
  7. entry = klass.find(entry_prio[0])
  8. next if entry.prio == entry_prio[1]
  9. entry.prio = entry_prio[1]
  10. entry.save!
  11. end
  12. end
  13. render json: { success: true }, status: :ok
  14. end
  15. end