Fixes #2293 - Any user can be set as a replacement for out of office.

This commit is contained in:
Rolf Schmidt 2021-08-25 15:08:05 +02:00 committed by Thorsten Eckel
parent 05a471f90d
commit d0689778dc
4 changed files with 73 additions and 32 deletions

View file

@ -75,6 +75,13 @@ class ProfileOutOfOffice extends App.ControllerSubContent
translate: false
disableCreateObject: true
value: @localData
source: "#{@apiPath}/users/search?full=true"
sourceType: 'POST'
queryCallback: (query) ->
return JSON.stringify(
query: query
permissions: ['ticket.agent']
)
]
noFieldset: true
params: @localData

View file

@ -39,6 +39,8 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
@key = Math.floor( Math.random() * 999999 ).toString()
if !@attribute.sourceType
@attribute.sourceType = 'GET'
if !@attribute.source
@attribute.source = "#{@apiPath}/search/user-organization"
@build()
@ -345,12 +347,16 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
@lazySearch(query)
searchObject: (query) =>
data =
query: query
if @attribute.queryCallback
data = @attribute.queryCallback(query)
@ajax(
id: "searchObject#{@key}"
type: 'GET'
type: @attribute.sourceType
url: @attribute.source
data:
query: query
data: data
processData: true
success: (data, status, xhr) =>
@emptyResultList()
@ -358,7 +364,14 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
# load 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
# organization
@ -371,7 +384,7 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
@$('.dropdown-menu').append(@buildOrganizationMembers(organization))
# objectss
if item.type is @objectSingle
else if item.type is @objectSingle
object = App[@objectSingle].fullLocal(item.id)
@recipientList.append(@buildObjectItem(object))

View file

@ -211,8 +211,9 @@ class UsersController < ApplicationController
# @parameter query [String] The search query.
# @parameter limit [Integer] The limit of search results.
# @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 group_ids(multi) [Hash<String=>String,Array<String>>] A list of Group 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=>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
# true: { user_ids => [1,2,...], assets => {...} }
# or false: [{:id => user.id, :label => "firstname lastname <email>", :value => "firstname lastname <email>"},...].

View 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