has_taskbars.rb 677 B

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module HasTaskbars
  3. extend ActiveSupport::Concern
  4. included do
  5. before_destroy :destroy_taskbars
  6. end
  7. class_methods do
  8. # Defines the entities which are available for the taskbar.
  9. def taskbar_entities(*entities)
  10. @taskbar_entities ||= entities
  11. end
  12. def taskbar_ignore_state_updates_entities(*entities)
  13. @taskbar_ignore_state_updates_entities ||= entities
  14. end
  15. end
  16. =begin
  17. destroy all taskbars for the class object id
  18. model = Model.find(123)
  19. model.destroy
  20. =end
  21. def destroy_taskbars
  22. Taskbar.where(key: "#{self.class}-#{id}").destroy_all
  23. end
  24. end