Show also roles based groups in profile notification settings.
This commit is contained in:
parent
5aa0d5b184
commit
8d725040a9
4 changed files with 70 additions and 19 deletions
|
@ -73,10 +73,9 @@ class Index extends App.ControllerSubContent
|
||||||
user_group_config = false
|
user_group_config = false
|
||||||
|
|
||||||
groups = []
|
groups = []
|
||||||
group_ids = @Session.get('group_ids')
|
group_ids = App.User.find(@Session.get('id')).all_group_ids()
|
||||||
if group_ids
|
if group_ids
|
||||||
for group_id, access of group_ids
|
for group_id in group_ids
|
||||||
if _.contains(access, 'full')
|
|
||||||
group = App.Group.find(group_id)
|
group = App.Group.find(group_id)
|
||||||
groups.push group
|
groups.push group
|
||||||
if !user_group_config
|
if !user_group_config
|
||||||
|
@ -150,6 +149,8 @@ class Index extends App.ControllerSubContent
|
||||||
params.notification_sound = form_params.notification_sound
|
params.notification_sound = form_params.notification_sound
|
||||||
if !params.notification_sound.enabled
|
if !params.notification_sound.enabled
|
||||||
params.notification_sound.enabled = false
|
params.notification_sound.enabled = false
|
||||||
|
else
|
||||||
|
params.notification_sound.enabled = true
|
||||||
|
|
||||||
# get data
|
# get data
|
||||||
@ajax(
|
@ajax(
|
||||||
|
|
|
@ -248,15 +248,10 @@ class App.Ticket extends App.Model
|
||||||
editable: (permission = 'change') ->
|
editable: (permission = 'change') ->
|
||||||
user_id = App.Session.get('id')
|
user_id = App.Session.get('id')
|
||||||
return true if user_id is @customer_id
|
return true if user_id is @customer_id
|
||||||
group_ids = App.Session.get('group_ids')
|
return false if !App.User.exists(user_id)
|
||||||
if group_ids
|
group_ids = App.User.find(user_id).all_group_ids(permission)
|
||||||
return true if group_ids[@group_id] && (_.include(group_ids[@group_id], permission) || _.include(group_ids[@group_id], 'full'))
|
for local_group_id in group_ids
|
||||||
role_ids = App.Session.get('role_ids')
|
if local_group_id.toString() is @group_id.toString()
|
||||||
if role_ids
|
return true
|
||||||
for role_id in role_ids
|
|
||||||
if App.Role.exists(role_id)
|
|
||||||
role = App.Role.find(role_id)
|
|
||||||
if role.group_ids
|
|
||||||
return true if role.group_ids[@group_id] && (_.include(role.group_ids[@group_id], permission) || _.include(role.group_ids[@group_id], 'full'))
|
|
||||||
false
|
false
|
||||||
|
|
||||||
|
|
|
@ -258,6 +258,25 @@ class App.User extends App.Model
|
||||||
return access if access
|
return access if access
|
||||||
false
|
false
|
||||||
|
|
||||||
|
all_group_ids: (permission = 'full') ->
|
||||||
|
group_ids = []
|
||||||
|
user_group_ids = App.Session.get('group_ids')
|
||||||
|
if user_group_ids
|
||||||
|
for local_group_id, local_permission of user_group_ids
|
||||||
|
if _.include(local_permission, permission) || _.include(local_permission, 'full')
|
||||||
|
group_ids.push local_group_id
|
||||||
|
|
||||||
|
user_role_ids = App.Session.get('role_ids')
|
||||||
|
if user_role_ids
|
||||||
|
for role_id in user_role_ids
|
||||||
|
if App.Role.exists(role_id)
|
||||||
|
role = App.Role.find(role_id)
|
||||||
|
if role.group_ids
|
||||||
|
for local_group_id, local_permission of role.group_ids
|
||||||
|
if _.include(local_permission, permission) || _.include(local_permission, 'full')
|
||||||
|
group_ids.push local_group_id
|
||||||
|
_.uniq(group_ids)
|
||||||
|
|
||||||
@outOfOfficeTextPlaceholder: ->
|
@outOfOfficeTextPlaceholder: ->
|
||||||
today = new Date()
|
today = new Date()
|
||||||
outOfOfficeText = 'Christmas holiday'
|
outOfOfficeText = 'Christmas holiday'
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
class CleanupUserPreferencesNotificationSound < ActiveRecord::Migration[5.1]
|
||||||
|
def up
|
||||||
|
User.with_permissions('ticket.agent').each do |user|
|
||||||
|
local_to_h!(user.preferences)
|
||||||
|
user.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
User.with_permissions('ticket.agent').each do |user|
|
||||||
|
next if !user.preferences
|
||||||
|
next if !user.preferences[:notification_sound]
|
||||||
|
next if !user.preferences[:notification_sound][:enabled]
|
||||||
|
if user.preferences[:notification_sound][:enabled] == 'true'
|
||||||
|
user.preferences[:notification_sound][:enabled] = true
|
||||||
|
user.save!
|
||||||
|
next
|
||||||
|
end
|
||||||
|
next if user.preferences[:notification_sound][:enabled] != 'false'
|
||||||
|
user.preferences[:notification_sound][:enabled] = false
|
||||||
|
user.save!
|
||||||
|
next
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def local_to_h!(value)
|
||||||
|
if value.class == ActionController::Parameters
|
||||||
|
value = value.permit!.to_h
|
||||||
|
end
|
||||||
|
if value.class == Hash || value.class == ActiveSupport::HashWithIndifferentAccess
|
||||||
|
value.each_key do |local_key|
|
||||||
|
value[local_key] = local_to_h!(value[local_key])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
value
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in a new issue