Fixes #2293 - Any user can be set as a replacement for out of office.
This commit is contained in:
parent
05a471f90d
commit
d0689778dc
4 changed files with 73 additions and 32 deletions
|
@ -75,6 +75,13 @@ class ProfileOutOfOffice extends App.ControllerSubContent
|
||||||
translate: false
|
translate: false
|
||||||
disableCreateObject: true
|
disableCreateObject: true
|
||||||
value: @localData
|
value: @localData
|
||||||
|
source: "#{@apiPath}/users/search?full=true"
|
||||||
|
sourceType: 'POST'
|
||||||
|
queryCallback: (query) ->
|
||||||
|
return JSON.stringify(
|
||||||
|
query: query
|
||||||
|
permissions: ['ticket.agent']
|
||||||
|
)
|
||||||
]
|
]
|
||||||
noFieldset: true
|
noFieldset: true
|
||||||
params: @localData
|
params: @localData
|
||||||
|
|
|
@ -39,6 +39,8 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
|
||||||
|
|
||||||
@key = Math.floor( Math.random() * 999999 ).toString()
|
@key = Math.floor( Math.random() * 999999 ).toString()
|
||||||
|
|
||||||
|
if !@attribute.sourceType
|
||||||
|
@attribute.sourceType = 'GET'
|
||||||
if !@attribute.source
|
if !@attribute.source
|
||||||
@attribute.source = "#{@apiPath}/search/user-organization"
|
@attribute.source = "#{@apiPath}/search/user-organization"
|
||||||
@build()
|
@build()
|
||||||
|
@ -345,12 +347,16 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
|
||||||
@lazySearch(query)
|
@lazySearch(query)
|
||||||
|
|
||||||
searchObject: (query) =>
|
searchObject: (query) =>
|
||||||
|
data =
|
||||||
|
query: query
|
||||||
|
if @attribute.queryCallback
|
||||||
|
data = @attribute.queryCallback(query)
|
||||||
|
|
||||||
@ajax(
|
@ajax(
|
||||||
id: "searchObject#{@key}"
|
id: "searchObject#{@key}"
|
||||||
type: 'GET'
|
type: @attribute.sourceType
|
||||||
url: @attribute.source
|
url: @attribute.source
|
||||||
data:
|
data: data
|
||||||
query: query
|
|
||||||
processData: true
|
processData: true
|
||||||
success: (data, status, xhr) =>
|
success: (data, status, xhr) =>
|
||||||
@emptyResultList()
|
@emptyResultList()
|
||||||
|
@ -358,7 +364,14 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
|
||||||
# load assets
|
# load assets
|
||||||
App.Collection.loadAssets(data.assets)
|
App.Collection.loadAssets(data.assets)
|
||||||
|
|
||||||
# build markup
|
# user search endpoint
|
||||||
|
if data.user_ids
|
||||||
|
for id in data.user_ids
|
||||||
|
object = App[@objectSingle].fullLocal(id)
|
||||||
|
@recipientList.append(@buildObjectItem(object))
|
||||||
|
|
||||||
|
# global search endpoint
|
||||||
|
else
|
||||||
for item in data.result
|
for item in data.result
|
||||||
|
|
||||||
# organization
|
# organization
|
||||||
|
@ -371,7 +384,7 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
|
||||||
@$('.dropdown-menu').append(@buildOrganizationMembers(organization))
|
@$('.dropdown-menu').append(@buildOrganizationMembers(organization))
|
||||||
|
|
||||||
# objectss
|
# objectss
|
||||||
if item.type is @objectSingle
|
else if item.type is @objectSingle
|
||||||
object = App[@objectSingle].fullLocal(item.id)
|
object = App[@objectSingle].fullLocal(item.id)
|
||||||
@recipientList.append(@buildObjectItem(object))
|
@recipientList.append(@buildObjectItem(object))
|
||||||
|
|
||||||
|
|
|
@ -211,8 +211,9 @@ class UsersController < ApplicationController
|
||||||
# @parameter query [String] The search query.
|
# @parameter query [String] The search query.
|
||||||
# @parameter limit [Integer] The limit of search results.
|
# @parameter limit [Integer] The limit of search results.
|
||||||
# @parameter ids(multi) [Array<Integer>] A list of User IDs which should be returned
|
# @parameter ids(multi) [Array<Integer>] A list of User IDs which should be returned
|
||||||
# @parameter role_ids(multi) [Array<String>] A list of Role identifiers to which the Users have to be allocated to.
|
# @parameter role_ids(multi) [Array<Integer>] A list of Role identifiers to which the Users have to be allocated to.
|
||||||
# @parameter group_ids(multi) [Hash<String=>String,Array<String>>] A list of Group identifiers to which the Users have to be allocated to.
|
# @parameter group_ids(multi) [Hash<String=>Integer,Array<Integer>>] A list of Group identifiers to which the Users have to be allocated to.
|
||||||
|
# @parameter permissions(multi) [Array<String>] A list of Permission identifiers to which the Users have to be allocated to.
|
||||||
# @parameter full [Boolean] Defines if the result should be
|
# @parameter full [Boolean] Defines if the result should be
|
||||||
# true: { user_ids => [1,2,...], assets => {...} }
|
# true: { user_ids => [1,2,...], assets => {...} }
|
||||||
# or false: [{:id => user.id, :label => "firstname lastname <email>", :value => "firstname lastname <email>"},...].
|
# or false: [{:id => user.id, :label => "firstname lastname <email>", :value => "firstname lastname <email>"},...].
|
||||||
|
|
20
spec/system/profile/out_of_office_spec.rb
Normal file
20
spec/system/profile/out_of_office_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'Profile > Out of Office', type: :system do
|
||||||
|
before do
|
||||||
|
visit 'profile/out_of_office'
|
||||||
|
sleep 3 # wait for popover killer to pass
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does find agents' do
|
||||||
|
find(:css, '.js-objectSelect').send_keys('Agent')
|
||||||
|
expect(page).to have_text('Agent 1 Test', wait: 20)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not find customers' do
|
||||||
|
find(:css, '.js-objectSelect').send_keys('Nicole')
|
||||||
|
expect(page).to have_no_text('Nicole Braun', wait: 20)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue