Fixed not recognised overview sort by prio. Ignore auto generated link on create if already present.
This commit is contained in:
parent
00abecbd98
commit
6b778c27ee
3 changed files with 30 additions and 16 deletions
|
@ -7,22 +7,36 @@ class Overview < ApplicationModel
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
validates :prio, presence: true
|
validates :prio, presence: true
|
||||||
|
|
||||||
before_create :fill_link
|
before_create :fill_link_on_create, :fill_prio
|
||||||
before_update :fill_link
|
before_update :fill_link_on_update
|
||||||
|
|
||||||
notify_clients_support
|
notify_clients_support
|
||||||
latest_change_support
|
latest_change_support
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# fill link
|
def fill_prio
|
||||||
def fill_link
|
return true if prio
|
||||||
|
prio = 9999
|
||||||
|
end
|
||||||
|
|
||||||
|
def fill_link_on_create
|
||||||
|
return true if !link.empty?
|
||||||
|
self.link = link_name(name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def fill_link_on_update
|
||||||
return true if link.empty?
|
return true if link.empty?
|
||||||
return true if !changes['name']
|
return true if !changes['name']
|
||||||
self.link = name.downcase
|
self.link = link_name(name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def link_name(name)
|
||||||
|
link = name.downcase
|
||||||
link.gsub!(/\s/, '_')
|
link.gsub!(/\s/, '_')
|
||||||
link.gsub!(/[^0-9a-z]/i, '_')
|
link.gsub!(/[^0-9a-z]/i, '_')
|
||||||
link.gsub!(/_+/, '_')
|
link.gsub!(/_+/, '_')
|
||||||
|
link
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,9 +21,9 @@ returns
|
||||||
if data[:current_user].role?('Customer')
|
if data[:current_user].role?('Customer')
|
||||||
role = Role.find_by(name: 'Customer')
|
role = Role.find_by(name: 'Customer')
|
||||||
overviews = if data[:current_user].organization_id && data[:current_user].organization.shared
|
overviews = if data[:current_user].organization_id && data[:current_user].organization.shared
|
||||||
Overview.where(role_id: role.id, active: true)
|
Overview.where(role_id: role.id, active: true).order(:prio)
|
||||||
else
|
else
|
||||||
Overview.where(role_id: role.id, organization_shared: false, active: true)
|
Overview.where(role_id: role.id, organization_shared: false, active: true).order(:prio)
|
||||||
end
|
end
|
||||||
return overviews
|
return overviews
|
||||||
end
|
end
|
||||||
|
@ -31,7 +31,7 @@ returns
|
||||||
# get agent overviews
|
# get agent overviews
|
||||||
return if !data[:current_user].role?('Agent')
|
return if !data[:current_user].role?('Agent')
|
||||||
role = Role.find_by(name: 'Agent')
|
role = Role.find_by(name: 'Agent')
|
||||||
Overview.where(role_id: role.id, active: true)
|
Overview.where(role_id: role.id, active: true).order(:prio)
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
Loading…
Reference in a new issue