2014-02-03 19:23:00 +00:00
|
|
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2012-09-20 12:08:02 +00:00
|
|
|
class Overview < ApplicationModel
|
2012-04-10 14:06:46 +00:00
|
|
|
store :condition
|
|
|
|
store :order
|
|
|
|
store :view
|
2015-04-27 13:42:53 +00:00
|
|
|
validates :name, presence: true
|
2015-09-17 18:39:51 +00:00
|
|
|
|
2016-03-12 16:23:51 +00:00
|
|
|
before_create :fill_link_on_create, :fill_prio
|
|
|
|
before_update :fill_link_on_update
|
2015-09-17 18:39:51 +00:00
|
|
|
|
2016-03-12 00:49:51 +00:00
|
|
|
notify_clients_support
|
2016-03-03 01:51:24 +00:00
|
|
|
latest_change_support
|
|
|
|
|
2015-09-17 18:39:51 +00:00
|
|
|
private
|
|
|
|
|
2016-03-12 16:23:51 +00:00
|
|
|
def fill_prio
|
2016-03-14 05:52:57 +00:00
|
|
|
return true if prio
|
2016-03-13 23:25:05 +00:00
|
|
|
self.prio = 9999
|
2016-03-12 16:23:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def fill_link_on_create
|
|
|
|
return true if !link.empty?
|
|
|
|
self.link = link_name(name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def fill_link_on_update
|
2016-03-12 00:49:51 +00:00
|
|
|
return true if link.empty?
|
|
|
|
return true if !changes['name']
|
2016-03-12 16:23:51 +00:00
|
|
|
self.link = link_name(name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def link_name(name)
|
|
|
|
link = name.downcase
|
2015-09-17 18:39:51 +00:00
|
|
|
link.gsub!(/\s/, '_')
|
|
|
|
link.gsub!(/[^0-9a-z]/i, '_')
|
|
|
|
link.gsub!(/_+/, '_')
|
2016-03-12 16:23:51 +00:00
|
|
|
link
|
2015-09-17 18:39:51 +00:00
|
|
|
end
|
|
|
|
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|