2014-12-25 23:41:00 +00:00
// form
2021-10-14 14:35:12 +00:00
QUnit . test ( 'form checks' , assert => {
2014-12-25 23:41:00 +00:00
2018-04-05 03:15:51 +00:00
// use unsorted order to check if the frontend is sorting correctly
2015-10-14 14:33:26 +00:00
App . TicketPriority . refresh ( [
2014-12-25 23:41:00 +00:00
{
id : 2 ,
name : '2 normal' ,
note : 'some note 2' ,
active : false ,
created _at : '2014-06-10T10:17:34.000Z' ,
} ,
{
id : 3 ,
name : '3 high' ,
note : 'some note 3' ,
active : true ,
created _at : '2014-06-10T10:17:44.000Z' ,
} ,
{
id : 4 ,
name : '4 very high' ,
note : 'some note 4' ,
active : true ,
created _at : '2014-06-10T10:17:54.000Z' ,
} ,
2016-05-23 19:20:18 +00:00
{
id : 5 ,
name : '5 xxx very high' ,
note : 'some note 5' ,
active : false ,
created _at : '2014-06-10T10:17:56.000Z' ,
} ,
2018-04-05 03:15:51 +00:00
{
id : 1 ,
name : '1 low' ,
note : 'some note 1' ,
active : true ,
created _at : '2014-06-10T11:17:34.000Z' ,
} ,
2015-10-14 14:33:26 +00:00
] )
2016-03-14 07:11:47 +00:00
App . TicketState . refresh ( [
{
id : 1 ,
name : 'new' ,
note : 'some note 1' ,
active : true ,
created _at : '2014-06-10T11:17:34.000Z' ,
} ,
{
id : 2 ,
name : 'open' ,
note : 'some note 2' ,
active : true ,
created _at : '2014-06-10T10:17:34.000Z' ,
} ,
{
id : 3 ,
name : 'should not be shown' ,
note : 'some note 3' ,
active : false ,
created _at : '2014-06-10T10:17:34.000Z' ,
} ,
] )
2015-10-14 14:33:26 +00:00
App . User . refresh ( [
{
id : 47 ,
login : 'bod@example.com' ,
email : 'bod@example.com' ,
firstname : 'Bob' ,
lastname : 'Smith' ,
active : true ,
created _at : '2014-06-10T11:17:34.000Z' ,
} ,
] )
App . Organization . refresh ( [
{
id : 12 ,
name : 'Org 1' ,
active : true ,
created _at : '2014-06-10T11:19:34.000Z' ,
} ,
] )
2014-12-25 23:41:00 +00:00
2022-04-08 10:18:19 +00:00
App . ObjectManagerAttribute . refresh ( [ { "name" : "number" , "object" : "Ticket" , "display" : "#" , "active" : true , "editable" : false , "data_type" : "input" , "data_option" : { "type" : "text" , "readonly" : 1 , "null" : true , "maxlength" : 60 , "width" : "68px" } , "screens" : { "create_top" : { } , "edit" : { } } , "position" : 5 , "id" : 1 } , { "name" : "title" , "object" : "Ticket" , "display" : "Title" , "active" : true , "editable" : false , "data_type" : "input" , "data_option" : { "type" : "text" , "maxlength" : 200 , "null" : false , "translate" : false } , "screens" : { "create_top" : { "-all-" : { "null" : false } } , "edit" : { } } , "position" : 8 , "id" : 2 } , { "name" : "customer_id" , "object" : "Ticket" , "display" : "Customer" , "active" : true , "editable" : false , "data_type" : "user_autocompletion" , "data_option" : { "relation" : "User" , "autocapitalize" : false , "multiple" : false , "guess" : true , "null" : false , "limit" : 200 , "placeholder" : "Enter Person or Organization/Company" , "minLengt" : 2 , "translate" : false , "permission" : [ "ticket.agent" ] } , "screens" : { "create_top" : { "-all-" : { "null" : false } } , "edit" : { } } , "position" : 10 , "id" : 3 } , { "name" : "organization_id" , "object" : "Ticket" , "display" : "Organization" , "active" : true , "editable" : false , "data_type" : "autocompletion_ajax" , "data_option" : { "relation" : "Organization" , "autocapitalize" : false , "multiple" : false , "null" : true , "translate" : false , "permission" : [ "ticket.agent" ] , "readonly" : 1 } , "screens" : { "create_top" : { "-all-" : { "null" : false } } , "edit" : { } } , "position" : 12 , "id" : 4 } , { "name" : "type" , "object" : "Ticket" , "display" : "Type" , "active" : false , "editable" : true , "data_type" : "select" , "data_option" : { "default" : "" , "options" : { "Incident" : "Incident" , "Problem" : "Problem" , "Request for Change" : "Request for Change" } , "nulloption" : true , "multiple" : false , "null" : true , "translate" : true , "maxlength" : 255 } , "screens" : { "create_middle" : { "-all-" : { "null" : false , "item_class" : "column" } } , "edit" : { "ticket.agent" : { "null" : false } } } , "position" : 20 , "id" : 5 } , { "name" : "group_id" , "object" : "Ticket" , "display" : "Group" , "active" : true , "editable" : false , "data_type" : "select" , "data_option" : { "default" : "" , "relation" : "Group" , "relation_condition" : { "access" : "full" } , "nulloption" : true , "multiple" : false , "null" : false , "translate" : false , "only_shown_if_selectable" : true , "permission" : [ "ticket.agent" , "ticket.customer" ] , "maxlength" : 255 } , "screens" : { "create_middle" : { "-all-" : { "null" : false , "item_class" : "column" } } , "edit" : { "ticket.agent" : { "null" : false } } } , "position" : 25 , "id" : 6 } , { "name" : "owner_id" , "object" : "Ticket" , "display" : "Owner" , "active" : true , "editable" : false , "data_type" : "select" , "data_option" : { "default" : "" , "relation" : "User" , "relation_condition" : { "roles" : "Agent" } , "nulloption" : true , "multiple" : false , "null" : true , "translate" : false , "permission" : [ "ticket.agent" ] , "maxlength" : 255 } , "screens" : { "create_middle" : { "-all-" : { "null" : true , "item_class" : "column" } } , "edit" : { "-all-" : { "null" : true } } } , "position" : 30 , "id" : 7 } , { "name" : "state_id" , "object" : "Ticket" , "display" : "State" , "active" : true , "editable" : false , "data_type" : "select" , "data_option" : { "relation" : "TicketState" , "nulloption" : true , "multiple" : false , "null" : false , "default" : 2 , "translate" : true , "filter" : [ 2 , 1 , 3 , 4 , 6 , 7 ] , "maxlength" : 255 } , "screens" : { "create_middle" : { "ticket.agent" : { "null" : false , "item_class" : "column" , "filter" : [ 2 , 1 , 3 , 4 , 7 ] } , "ticket.customer" : { "item_class" : "column" , "nulloption" : false , "null" : true , "filter" : [ 1 , 4 ] , "default" : 1 } } , "edit" : { "ticket.agent" : { "nulloption" : false , "null" : false , "filter" : [ 2 , 3 , 4 , 7 ] } , "ticket.customer" : { "nulloption" : false , "null" : true , "filter" : [ 2 , 4 ] , "default" : 2 } } } , "position" : 40 , "id" : 8 } , { "name" : "pending_time" , "object" : "Ticket" , "display" : "Pending till" , "active" : true , "editable" : false , "data_type" : "datetime" , "data_option" : { "future" : true , "past" : false , "diff" : 24 , "null" : true , "translate" : true , "permission" : [ "ticket.agent" ] } , "screens" : { "create_middle" : { "-all-" : { "null" : false , "item_class" : "column" } } , "edit" : { "-all-" : { "null" : false } } } , "position" : 41 , "id" : 9 } , { "name" : "priority_id" , "object" : "Ticket" , "display" : "Priority" , "active" : true , "editable" : false , "data_type" : "select" , "data_option" : { "relation" : "TicketPriority" , "nulloption" : false , "multiple" : false , "null" : false , "default" : 2 , "translate" : true , "maxlength" : 255 } , "screens" : { "create_middle" : { "ticket.agent" : { "null" : false , "item_class" : "column" } } , "edit" : { "ticket.agent" : { "null" : false } } } , " pos
2016-03-13 23:25:05 +00:00
/* working hours and escalation_times */
$ ( '#forms' ) . append ( '<hr><h1>form condition check</h1><form id="form1"></form>' )
2014-12-25 23:41:00 +00:00
var el = $ ( '#form1' )
var defaults = {
2016-05-23 19:20:18 +00:00
priority1 _id : '1' ,
priority2 _id : [ '1' , '2' ] ,
priority3 _id : '2' ,
2018-08-23 19:19:48 +00:00
priority4 _id : '2' ,
priority5 _id : '1' ,
2015-09-20 22:19:45 +00:00
working _hours : {
mon : {
active : true ,
timeframes : [
[ '09:00' , '17:00' ]
]
} ,
tue : {
active : true ,
timeframes : [
[ '00:00' , '22:00' ]
]
} ,
wed : {
active : true ,
timeframes : [
[ '09:00' , '17:00' ]
]
} ,
thu : {
active : true ,
timeframes : [
[ '09:00' , '12:00' ] ,
[ '13:00' , '17:00' ]
]
} ,
fri : {
active : true ,
timeframes : [
[ '09:00' , '17:00' ]
]
} ,
sat : {
active : false ,
timeframes : [
[ '10:00' , '14:00' ]
]
} ,
sun : {
active : false ,
timeframes : [
[ '10:00' , '14:00' ]
]
} ,
2014-12-25 23:41:00 +00:00
} ,
2015-09-20 22:19:45 +00:00
first _response _time : 150 ,
solution _time : '' ,
update _time : 45 ,
2014-12-25 23:41:00 +00:00
}
new App . ControllerForm ( {
el : el ,
model : {
configure _attributes : [
2018-08-23 19:19:48 +00:00
{ name : 'priority1_id' , display : 'Priroity1 (with active selection)' , tag : 'select' , relation : 'TicketPriority' , null : true , options : { } } ,
{ name : 'priority2_id' , display : 'Priroity2 (with active and inactive selection)' , tag : 'select' , multiple : true , relation : 'TicketPriority' , null : true , options : { } } ,
{ name : 'priority3_id' , display : 'Priroity3 (with inactive selection)' , tag : 'select' , relation : 'TicketPriority' , null : true , options : { } } ,
{ name : 'priority4_id' , display : 'Priroity4 (with inactive selection)' , tag : 'select' , multiple : true , relation : 'TicketPriority' , null : true , options : { } } ,
{ name : 'priority5_id' , display : 'Priroity5 (with active selection)' , tag : 'select' , multiple : true , relation : 'TicketPriority' , null : true , options : { } } ,
2015-09-20 22:19:45 +00:00
{ name : 'escalation_times' , display : 'Times' , tag : 'sla_times' , null : true } ,
{ name : 'working_hours' , display : 'Hours' , tag : 'business_hours' , null : true } ,
2014-12-25 23:41:00 +00:00
]
} ,
2015-09-20 22:19:45 +00:00
params : defaults ,
2014-12-25 23:41:00 +00:00
autofocus : true
2016-03-13 23:25:05 +00:00
} )
var params = App . ControllerForm . params ( el )
2014-12-25 23:41:00 +00:00
var test _params = {
2016-05-23 19:20:18 +00:00
priority1 _id : '1' ,
priority2 _id : [ '1' , '2' ] ,
priority3 _id : '2' ,
2018-08-23 19:19:48 +00:00
priority4 _id : '2' ,
priority5 _id : '1' ,
2015-09-20 22:19:45 +00:00
first _response _time : '150' ,
2020-05-25 10:01:49 +00:00
first _response _time _enabled : 'on' ,
2015-09-20 22:19:45 +00:00
first _response _time _in _text : '02:30' ,
2021-10-27 09:38:45 +00:00
response _time : '' ,
response _time _in _text : '' ,
2015-09-20 22:19:45 +00:00
solution _time : '' ,
2020-05-25 10:01:49 +00:00
solution _time _enabled : undefined ,
2015-09-20 22:19:45 +00:00
solution _time _in _text : '' ,
update _time : '45' ,
2020-05-25 10:01:49 +00:00
update _time _enabled : 'on' ,
2015-09-20 22:19:45 +00:00
update _time _in _text : '00:45' ,
2021-10-27 09:38:45 +00:00
update _type : 'update' ,
2015-09-20 22:19:45 +00:00
working _hours : {
mon : {
active : true ,
timeframes : [
[ '09:00' , '17:00' ]
]
} ,
tue : {
active : true ,
timeframes : [
[ '00:00' , '22:00' ]
]
} ,
wed : {
active : true ,
timeframes : [
[ '09:00' , '17:00' ]
]
} ,
thu : {
active : true ,
timeframes : [
[ '09:00' , '12:00' ] ,
[ '13:00' , '17:00' ]
]
} ,
fri : {
active : true ,
timeframes : [
[ '09:00' , '17:00' ]
]
} ,
sat : {
active : false ,
timeframes : [
[ '10:00' , '14:00' ]
]
} ,
sun : {
active : false ,
timeframes : [
[ '10:00' , '14:00' ]
]
} ,
} ,
}
2021-10-14 14:35:12 +00:00
assert . deepEqual ( params , test _params , 'form param check' )
2015-09-20 22:19:45 +00:00
2016-05-23 19:20:18 +00:00
// check possible options
2021-10-14 14:35:12 +00:00
assert . equal ( el . find ( '[name="priority1_id"] option' ) . length , 3 )
assert . equal ( el . find ( '[name="priority2_id"] option' ) . length , 4 )
assert . equal ( el . find ( '[name="priority3_id"] option' ) . length , 4 )
assert . equal ( el . find ( '[name="priority4_id"] option' ) . length , 4 )
assert . equal ( el . find ( '[name="priority5_id"] option' ) . length , 3 )
2018-08-23 19:19:48 +00:00
// check priority1_id selection order
2021-10-14 14:35:12 +00:00
assert . equal ( el . find ( '[name="priority1_id"] option:nth-child(1)' ) . text ( ) , '1 low' )
assert . equal ( el . find ( '[name="priority1_id"] option:nth-child(2)' ) . text ( ) , '3 high' )
assert . equal ( el . find ( '[name="priority1_id"] option:nth-child(3)' ) . text ( ) , '4 very high' )
2018-08-23 19:19:48 +00:00
// check priority2_id selection order
2021-10-14 14:35:12 +00:00
assert . equal ( el . find ( '[name="priority2_id"] option:nth-child(1)' ) . text ( ) , '1 low' )
assert . equal ( el . find ( '[name="priority2_id"] option:nth-child(2)' ) . text ( ) , '2 normal' )
assert . equal ( el . find ( '[name="priority2_id"] option:nth-child(3)' ) . text ( ) , '3 high' )
assert . equal ( el . find ( '[name="priority2_id"] option:nth-child(4)' ) . text ( ) , '4 very high' )
2018-08-23 19:19:48 +00:00
// check priority3_id selection order
2021-10-14 14:35:12 +00:00
assert . equal ( el . find ( '[name="priority3_id"] option:nth-child(1)' ) . text ( ) , '1 low' )
assert . equal ( el . find ( '[name="priority3_id"] option:nth-child(2)' ) . text ( ) , '2 normal' )
assert . equal ( el . find ( '[name="priority3_id"] option:nth-child(3)' ) . text ( ) , '3 high' )
assert . equal ( el . find ( '[name="priority3_id"] option:nth-child(4)' ) . text ( ) , '4 very high' )
2018-08-23 19:19:48 +00:00
// check priority4_id selection order
2021-10-14 14:35:12 +00:00
assert . equal ( el . find ( '[name="priority4_id"] option:nth-child(1)' ) . text ( ) , '1 low' )
assert . equal ( el . find ( '[name="priority4_id"] option:nth-child(2)' ) . text ( ) , '2 normal' )
assert . equal ( el . find ( '[name="priority4_id"] option:nth-child(3)' ) . text ( ) , '3 high' )
assert . equal ( el . find ( '[name="priority4_id"] option:nth-child(4)' ) . text ( ) , '4 very high' )
2018-08-23 19:19:48 +00:00
// check priority5_id selection order
2021-10-14 14:35:12 +00:00
assert . equal ( el . find ( '[name="priority5_id"] option:nth-child(1)' ) . text ( ) , '1 low' )
assert . equal ( el . find ( '[name="priority5_id"] option:nth-child(2)' ) . text ( ) , '3 high' )
assert . equal ( el . find ( '[name="priority5_id"] option:nth-child(3)' ) . text ( ) , '4 very high' )
2016-05-23 19:20:18 +00:00
2015-09-20 22:19:45 +00:00
// change sla times
el . find ( '[name="first_response_time_in_text"]' ) . val ( '0:30' ) . trigger ( 'blur' )
2022-02-02 09:51:08 +00:00
el . find ( '#update_time' ) . trigger ( 'click' )
2015-09-20 22:19:45 +00:00
2016-03-13 23:25:05 +00:00
var params = App . ControllerForm . params ( el )
2015-09-20 22:19:45 +00:00
var test _params = {
2016-05-23 19:20:18 +00:00
priority1 _id : '1' ,
priority2 _id : [ '1' , '2' ] ,
priority3 _id : '2' ,
2018-08-23 19:19:48 +00:00
priority4 _id : '2' ,
priority5 _id : '1' ,
2015-09-20 22:19:45 +00:00
working _hours : {
mon : {
active : true ,
timeframes : [
[ '09:00' , '17:00' ]
]
} ,
tue : {
active : true ,
timeframes : [
[ '00:00' , '22:00' ]
]
} ,
wed : {
active : true ,
timeframes : [
[ '09:00' , '17:00' ]
]
} ,
thu : {
active : true ,
timeframes : [
[ '09:00' , '12:00' ] ,
[ '13:00' , '17:00' ]
]
} ,
fri : {
active : true ,
timeframes : [
[ '09:00' , '17:00' ]
]
} ,
sat : {
active : false ,
timeframes : [
[ '10:00' , '14:00' ]
]
} ,
sun : {
active : false ,
timeframes : [
[ '10:00' , '14:00' ]
]
} ,
2014-12-25 23:41:00 +00:00
} ,
2015-09-20 22:19:45 +00:00
first _response _time : '30' ,
2020-05-25 10:01:49 +00:00
first _response _time _enabled : 'on' ,
2015-09-20 22:19:45 +00:00
first _response _time _in _text : '00:30' ,
2021-10-27 09:38:45 +00:00
response _time : '' ,
response _time _in _text : '' ,
2015-09-20 22:19:45 +00:00
solution _time : '' ,
2020-05-25 10:01:49 +00:00
solution _time _enabled : undefined ,
2015-09-20 22:19:45 +00:00
solution _time _in _text : '' ,
update _time : '' ,
2020-05-25 10:01:49 +00:00
update _time _enabled : undefined ,
2015-09-20 22:19:45 +00:00
update _time _in _text : '' ,
2021-10-27 09:38:45 +00:00
update _type : undefined ,
2016-03-13 23:25:05 +00:00
}
2021-10-14 14:35:12 +00:00
assert . deepEqual ( params , test _params , 'form param check' )
2016-03-13 23:25:05 +00:00
2021-10-27 09:38:45 +00:00
// change sla times
el . find ( '#update_time' ) . attr ( 'checked' , false )
2022-02-02 09:51:08 +00:00
el . find ( '[value=response]' ) . trigger ( 'click' )
2021-10-27 09:38:45 +00:00
el . find ( '[name="response_time_in_text"]' ) . val ( '4:30' ) . trigger ( 'blur' )
var params = App . ControllerForm . params ( el )
var test _params = {
priority1 _id : '1' ,
priority2 _id : [ '1' , '2' ] ,
priority3 _id : '2' ,
priority4 _id : '2' ,
priority5 _id : '1' ,
working _hours : {
mon : {
active : true ,
timeframes : [
[ '09:00' , '17:00' ]
]
} ,
tue : {
active : true ,
timeframes : [
[ '00:00' , '22:00' ]
]
} ,
wed : {
active : true ,
timeframes : [
[ '09:00' , '17:00' ]
]
} ,
thu : {
active : true ,
timeframes : [
[ '09:00' , '12:00' ] ,
[ '13:00' , '17:00' ]
]
} ,
fri : {
active : true ,
timeframes : [
[ '09:00' , '17:00' ]
]
} ,
sat : {
active : false ,
timeframes : [
[ '10:00' , '14:00' ]
]
} ,
sun : {
active : false ,
timeframes : [
[ '10:00' , '14:00' ]
]
} ,
} ,
first _response _time : '30' ,
first _response _time _enabled : 'on' ,
first _response _time _in _text : '00:30' ,
response _time : '270' ,
response _time _in _text : '04:30' ,
solution _time : '' ,
solution _time _enabled : undefined ,
solution _time _in _text : '' ,
update _time : '' ,
update _time _enabled : 'on' ,
update _time _in _text : '' ,
update _type : 'response'
}
assert . deepEqual ( params , test _params , 'form param check post response' )
2016-03-13 23:25:05 +00:00
/* empty params or defaults */
$ ( '#forms' ) . append ( '<hr><h1>form condition check</h1><form id="form2"></form>' )
var el = $ ( '#form2' )
new App . ControllerForm ( {
el : el ,
model : {
configure _attributes : [
{ name : 'condition' , display : 'Conditions' , tag : 'ticket_selector' , null : true } ,
2016-05-03 00:36:44 +00:00
{ name : 'executions' , display : 'Executions' , tag : 'ticket_perform_action' , null : true , notification : true } ,
2016-03-13 23:25:05 +00:00
]
} ,
autofocus : true
} )
var params = App . ControllerForm . params ( el )
var test _params = {
condition : {
'ticket.state_id' : {
operator : 'is' ,
value : '2' ,
} ,
} ,
executions : {
'ticket.state_id' : {
value : '2' ,
} ,
} ,
}
2021-10-14 14:35:12 +00:00
assert . deepEqual ( params , test _params , 'form param check' ) ;
2016-03-13 23:25:05 +00:00
/* with params or defaults */
2016-05-03 00:36:44 +00:00
$ ( '#forms' ) . append ( '<hr><h1>form 3</h1><form id="form3"></form>' )
2016-03-13 23:25:05 +00:00
var el = $ ( '#form3' )
var defaults = {
condition : {
2015-09-20 22:19:45 +00:00
'ticket.title' : {
operator : 'contains' ,
value : 'some title' ,
} ,
2016-03-13 23:25:05 +00:00
'ticket.priority_id' : {
operator : 'is' ,
value : [ 1 , 2 , 3 ] ,
} ,
2015-09-20 22:19:45 +00:00
'ticket.created_at' : {
operator : 'before (absolute)' ,
value : '2015-09-20T03:41:00.000Z' ,
} ,
2016-03-13 23:25:05 +00:00
'ticket.updated_at' : {
operator : 'within last (relative)' ,
range : 'year' ,
value : 2 ,
} ,
'ticket.organization_id' : {
operator : 'is not' ,
pre _condition : 'specific' ,
value : 12 ,
} ,
'ticket.owner_id' : {
operator : 'is' ,
pre _condition : 'specific' ,
value : 47 ,
} ,
'ticket.created_by_id' : {
operator : 'is' ,
pre _condition : 'current_user.id' ,
value : '' ,
} ,
} ,
executions : {
'ticket.title' : {
value : 'some title new' ,
} ,
'ticket.priority_id' : {
value : 3 ,
} ,
'ticket.owner_id' : {
pre _condition : 'specific' ,
value : 47 ,
} ,
'ticket.tags' : {
operator : 'remove' ,
value : 'tag1, tag2' ,
} ,
2016-05-03 00:36:44 +00:00
'notification.email' : {
recipient : 'ticket_customer' ,
subject : 'some subject' ,
body : "some<br>\nbody" ,
2021-08-16 11:34:05 +00:00
internal : 'false' ,
include _attachments : 'false' ,
2016-05-03 00:36:44 +00:00
} ,
2016-03-13 23:25:05 +00:00
} ,
}
new App . ControllerForm ( {
el : el ,
model : {
configure _attributes : [
{ name : 'condition' , display : 'Conditions' , tag : 'ticket_selector' , null : true } ,
2016-05-03 00:36:44 +00:00
{ name : 'executions' , display : 'Executions' , tag : 'ticket_perform_action' , null : true , notification : true } ,
2016-03-13 23:25:05 +00:00
]
} ,
params : defaults ,
autofocus : true
} )
var params = App . ControllerForm . params ( el )
var test _params = {
condition : {
'ticket.title' : {
operator : 'contains' ,
value : 'some title' ,
} ,
'ticket.priority_id' : {
operator : 'is' ,
2016-05-23 19:20:18 +00:00
value : [ '1' , '2' , '3' ] , // show also invalid proirity, because it's selected
2016-03-13 23:25:05 +00:00
} ,
'ticket.created_at' : {
operator : 'before (absolute)' ,
value : '2015-09-20T03:41:00.000Z' ,
} ,
'ticket.updated_at' : {
operator : 'within last (relative)' ,
range : 'year' ,
value : '2' ,
} ,
'ticket.organization_id' : {
operator : 'is not' ,
pre _condition : 'specific' ,
value : '12' ,
2022-01-12 13:24:11 +00:00
value _completion : '' ,
2016-03-13 23:25:05 +00:00
} ,
'ticket.owner_id' : {
operator : 'is' ,
pre _condition : 'specific' ,
value : '47' ,
2022-01-12 13:24:11 +00:00
value _completion : '' ,
2016-03-13 23:25:05 +00:00
} ,
'ticket.created_by_id' : {
operator : 'is' ,
pre _condition : 'current_user.id' ,
2022-01-12 13:24:11 +00:00
value : null ,
2016-03-13 23:25:05 +00:00
value _completion : ''
} ,
} ,
executions : {
'ticket.title' : {
value : 'some title new' ,
} ,
'ticket.owner_id' : {
pre _condition : 'specific' ,
value : '47' ,
2022-01-12 13:24:11 +00:00
value _completion : ''
2016-03-13 23:25:05 +00:00
} ,
'ticket.priority_id' : {
value : '3' ,
} ,
'ticket.tags' : {
operator : 'remove' ,
value : 'tag1, tag2' ,
} ,
2016-05-03 00:36:44 +00:00
'notification.email' : {
recipient : 'ticket_customer' ,
subject : 'some subject' ,
body : "some<br>\nbody" ,
2021-08-16 11:34:05 +00:00
internal : 'false' ,
include _attachments : 'false' ,
2016-05-03 00:36:44 +00:00
} ,
2016-03-13 23:25:05 +00:00
} ,
}
2021-10-14 14:35:12 +00:00
assert . deepEqual ( params , test _params , 'form param check' )
2016-03-13 23:25:05 +00:00
// change selector
2022-02-02 09:51:08 +00:00
el . find ( '[name="condition::ticket.priority_id::value"]' ) . closest ( '.js-filterElement' ) . find ( '.js-remove' ) . trigger ( 'click' )
el . find ( '[name="executions::ticket.title::value"]' ) . closest ( '.js-filterElement' ) . find ( '.js-remove' ) . trigger ( 'click' )
2016-03-13 23:25:05 +00:00
var params = App . ControllerForm . params ( el )
var test _params = {
condition : {
'ticket.title' : {
operator : 'contains' ,
value : 'some title' ,
} ,
'ticket.created_at' : {
operator : 'before (absolute)' ,
value : '2015-09-20T03:41:00.000Z' ,
} ,
'ticket.updated_at' : {
operator : 'within last (relative)' ,
range : 'year' ,
value : '2' ,
} ,
2015-10-14 14:33:26 +00:00
'ticket.organization_id' : {
operator : 'is not' ,
pre _condition : 'specific' ,
value : '12' ,
2022-01-12 13:24:11 +00:00
value _completion : '' ,
2015-10-14 14:33:26 +00:00
} ,
'ticket.owner_id' : {
operator : 'is' ,
pre _condition : 'specific' ,
value : '47' ,
2022-01-12 13:24:11 +00:00
value _completion : '' ,
2015-10-14 14:33:26 +00:00
} ,
2016-03-13 23:25:05 +00:00
'ticket.created_by_id' : {
operator : 'is' ,
pre _condition : 'current_user.id' ,
2022-01-12 13:24:11 +00:00
value : null ,
2016-03-13 23:25:05 +00:00
value _completion : ''
} ,
2014-12-25 23:41:00 +00:00
} ,
executions : {
2015-09-20 22:19:45 +00:00
'ticket.priority_id' : {
value : '3' ,
} ,
2016-03-13 23:25:05 +00:00
'ticket.owner_id' : {
pre _condition : 'specific' ,
value : '47' ,
2022-01-12 13:24:11 +00:00
value _completion : ''
2016-03-13 23:25:05 +00:00
} ,
2015-10-15 13:23:41 +00:00
'ticket.tags' : {
operator : 'remove' ,
value : 'tag1, tag2' ,
} ,
2016-05-03 00:36:44 +00:00
'notification.email' : {
recipient : 'ticket_customer' ,
subject : 'some subject' ,
body : "some<br>\nbody" ,
2020-02-18 10:28:44 +00:00
internal : 'false' ,
2021-08-16 11:34:05 +00:00
include _attachments : 'false' ,
2016-05-03 00:36:44 +00:00
} ,
} ,
}
2021-10-14 14:35:12 +00:00
assert . deepEqual ( params , test _params , 'form param check' )
2016-05-03 00:36:44 +00:00
// change selector
2022-02-02 09:51:08 +00:00
el . find ( '[name="executions::notification.email::subject"]' ) . closest ( '.js-filterElement' ) . find ( '.js-remove' ) . trigger ( 'click' )
2016-05-03 00:36:44 +00:00
var params = App . ControllerForm . params ( el )
var test _params = {
condition : {
'ticket.title' : {
operator : 'contains' ,
value : 'some title' ,
} ,
'ticket.created_at' : {
operator : 'before (absolute)' ,
value : '2015-09-20T03:41:00.000Z' ,
} ,
'ticket.updated_at' : {
operator : 'within last (relative)' ,
range : 'year' ,
value : '2' ,
} ,
'ticket.organization_id' : {
operator : 'is not' ,
pre _condition : 'specific' ,
value : '12' ,
2022-01-12 13:24:11 +00:00
value _completion : '' ,
2016-05-03 00:36:44 +00:00
} ,
'ticket.owner_id' : {
operator : 'is' ,
pre _condition : 'specific' ,
value : '47' ,
2022-01-12 13:24:11 +00:00
value _completion : '' ,
2016-05-03 00:36:44 +00:00
} ,
'ticket.created_by_id' : {
operator : 'is' ,
pre _condition : 'current_user.id' ,
2022-01-12 13:24:11 +00:00
value : null ,
2016-05-03 00:36:44 +00:00
value _completion : ''
} ,
} ,
executions : {
'ticket.priority_id' : {
value : '3' ,
} ,
'ticket.owner_id' : {
pre _condition : 'specific' ,
value : '47' ,
2022-01-12 13:24:11 +00:00
value _completion : ''
2016-05-03 00:36:44 +00:00
} ,
'ticket.tags' : {
operator : 'remove' ,
value : 'tag1, tag2' ,
} ,
} ,
}
2021-10-14 14:35:12 +00:00
assert . deepEqual ( params , test _params , 'form param check' )
2016-05-03 00:36:44 +00:00
// change selector
el . find ( '.js-attributeSelector' ) . last ( ) . find ( 'select' ) . val ( 'notification.email' ) . trigger ( 'change' )
el . find ( '[name="executions::notification.email::subject"]' ) . val ( 'some subject' )
el . find ( '[data-name="executions::notification.email::body"]' ) . html ( 'lala' )
2022-02-02 09:51:08 +00:00
el . find ( '[data-name="executions::notification.email::recipient"] .js-select.js-option[data-value="ticket_owner"]' ) . trigger ( 'click' )
2016-05-03 00:36:44 +00:00
var params = App . ControllerForm . params ( el )
var test _params = {
condition : {
'ticket.title' : {
operator : 'contains' ,
value : 'some title' ,
} ,
'ticket.created_at' : {
operator : 'before (absolute)' ,
value : '2015-09-20T03:41:00.000Z' ,
} ,
'ticket.updated_at' : {
operator : 'within last (relative)' ,
range : 'year' ,
value : '2' ,
} ,
'ticket.organization_id' : {
operator : 'is not' ,
pre _condition : 'specific' ,
value : '12' ,
2022-01-12 13:24:11 +00:00
value _completion : '' ,
2016-05-03 00:36:44 +00:00
} ,
'ticket.owner_id' : {
operator : 'is' ,
pre _condition : 'specific' ,
value : '47' ,
2022-01-12 13:24:11 +00:00
value _completion : '' ,
2016-05-03 00:36:44 +00:00
} ,
'ticket.created_by_id' : {
operator : 'is' ,
pre _condition : 'current_user.id' ,
2022-01-12 13:24:11 +00:00
value : null ,
2016-05-03 00:36:44 +00:00
value _completion : ''
} ,
} ,
executions : {
'ticket.priority_id' : {
value : '3' ,
} ,
'ticket.owner_id' : {
pre _condition : 'specific' ,
value : '47' ,
2022-01-12 13:24:11 +00:00
value _completion : ''
2016-05-03 00:36:44 +00:00
} ,
'notification.email' : {
recipient : 'ticket_owner' ,
subject : 'some subject' ,
body : 'lala' ,
2021-08-16 11:34:05 +00:00
internal : 'false' ,
include _attachments : 'false' ,
2016-05-03 00:36:44 +00:00
} ,
2014-12-25 23:41:00 +00:00
} ,
}
2021-10-14 14:35:12 +00:00
assert . deepEqual ( params , test _params , 'form param check' )
2014-12-25 23:41:00 +00:00
2016-05-03 00:36:44 +00:00
/* with params or defaults */
$ ( '#forms' ) . append ( '<hr><h1>form 4</h1><form id="form4"></form>' )
var el = $ ( '#form4' )
var defaults = {
condition : {
'ticket.title' : {
operator : 'contains' ,
value : 'some title' ,
} ,
} ,
executions : {
'notification.email' : {
recipient : 'ticket_customer' ,
subject : 'some subject' ,
body : "some<br>\nbody" ,
2021-08-16 11:34:05 +00:00
internal : 'false' ,
include _attachments : 'false' ,
2016-05-03 00:36:44 +00:00
} ,
} ,
}
new App . ControllerForm ( {
el : el ,
model : {
configure _attributes : [
{ name : 'condition' , display : 'Conditions' , tag : 'ticket_selector' , null : true } ,
{ name : 'executions' , display : 'Executions' , tag : 'ticket_perform_action' , null : true , notification : true } ,
]
} ,
params : defaults ,
autofocus : true
} )
var params = App . ControllerForm . params ( el )
var test _params = {
condition : {
'ticket.title' : {
operator : 'contains' ,
value : 'some title' ,
} ,
} ,
executions : {
'notification.email' : {
recipient : 'ticket_customer' ,
subject : 'some subject' ,
body : "some<br>\nbody" ,
2020-02-18 10:28:44 +00:00
internal : 'false' ,
2021-08-16 11:34:05 +00:00
include _attachments : 'false' ,
2016-05-03 00:36:44 +00:00
} ,
} ,
}
2021-10-14 14:35:12 +00:00
assert . deepEqual ( params , test _params , 'form param check' )
2014-12-25 23:41:00 +00:00
2018-05-14 16:01:15 +00:00
$ ( '#forms' ) . append ( '<hr><h1>form 5</h1><form id="form5"></form>' )
var el = $ ( '#form5' )
var defaults = {
condition : {
'article.body' : {
operator : 'contains' ,
value : 'some body' ,
} ,
} ,
executions : {
'notification.email' : {
recipient : 'ticket_customer' ,
subject : 'some subject' ,
body : "some<br>\nbody" ,
2021-08-16 11:34:05 +00:00
internal : 'false' ,
include _attachments : 'true' ,
2018-05-14 16:01:15 +00:00
} ,
} ,
2020-03-17 07:52:57 +00:00
}
2018-05-14 16:01:15 +00:00
new App . ControllerForm ( {
el : el ,
model : {
configure _attributes : [
{ name : 'condition' , display : 'Conditions' , tag : 'ticket_selector' , null : true } ,
{ name : 'executions' , display : 'Executions' , tag : 'ticket_perform_action' , null : true , notification : true } ,
]
} ,
params : defaults ,
autofocus : true
} )
var params = App . ControllerForm . params ( el )
var test _params = {
condition : {
'article.body' : {
operator : 'contains' ,
value : 'some body' ,
} ,
} ,
executions : {
'notification.email' : {
recipient : 'ticket_customer' ,
subject : 'some subject' ,
body : "some<br>\nbody" ,
2021-08-16 11:34:05 +00:00
internal : 'false' ,
include _attachments : 'true' ,
2018-05-14 16:01:15 +00:00
} ,
} ,
}
2021-10-14 14:35:12 +00:00
assert . deepEqual ( params , test _params , 'form article body param check' )
2022-01-12 13:24:11 +00:00
App . User . refresh ( [
{
id : 44 ,
login : 'bod@example.com' ,
email : 'bod@example.com' ,
firstname : 'Bob' ,
lastname : 'Smith' ,
active : true ,
created _at : '2014-06-10T11:17:34.000Z' ,
} ,
{
id : 45 ,
login : 'john@example.com' ,
email : 'john@example.com' ,
firstname : 'John' ,
lastname : 'Doe' ,
active : true ,
created _at : '2014-07-10T11:17:34.000Z' ,
} ,
{
id : 46 ,
login : 'sam@example.com' ,
email : 'sam@example.com' ,
firstname : 'Sam' ,
lastname : 'Bond' ,
active : true ,
created _at : '2014-08-10T11:17:34.000Z' ,
} ,
{
id : 30 ,
login : 'clark@example.com' ,
email : 'clark@example.com' ,
firstname : 'Clark' ,
lastname : 'Olsen' ,
active : true ,
created _at : '2016-02-10T11:17:34.000Z' ,
} ,
{
id : 31 ,
login : 'james@example.com' ,
email : 'james@example.com' ,
firstname : 'James' ,
lastname : 'Puth' ,
active : true ,
created _at : '2016-03-10T11:17:34.000Z' ,
} ,
{
id : 32 ,
login : 'charles@example.com' ,
email : 'charles@example.com' ,
firstname : 'Charles' ,
lastname : 'Kent' ,
active : true ,
created _at : '2016-04-10T11:17:34.000Z' ,
} ,
] )
App . Organization . refresh ( [
{
id : 9 ,
name : 'Org 1' ,
active : true ,
created _at : '2018-06-10T11:19:34.000Z' ,
} ,
{
id : 10 ,
name : 'Org 2' ,
active : true ,
created _at : '2018-06-10T11:19:34.000Z' ,
} ,
{
id : 11 ,
name : 'Org 3' ,
active : true ,
created _at : '2018-06-10T11:19:34.000Z' ,
} ,
] )
/* with params or defaults */
$ ( '#forms' ) . append ( '<hr><h1>form condition check for multiple user and organisation selection</h1><form id="form6"></form>' )
var el = $ ( '#form6' )
var defaults = {
condition : {
'ticket.title' : {
operator : 'contains' ,
value : 'some title' ,
} ,
'ticket.organization_id' : {
operator : 'is' ,
pre _condition : 'specific' ,
value : [ 9 , 10 , 11 ] ,
} ,
'ticket.owner_id' : {
operator : 'is not' ,
pre _condition : 'specific' ,
value : [ 44 , 45 , 46 ] ,
} ,
'ticket.customer_id' : {
operator : 'is' ,
pre _condition : 'specific' ,
value : [ 30 , 31 , 32 ] ,
} ,
} ,
executions : {
'ticket.title' : {
value : 'some title new' ,
} ,
'ticket.owner_id' : {
pre _condition : 'specific' ,
value : [ 44 , 46 ] ,
} ,
} ,
}
new App . ControllerForm ( {
el : el ,
model : {
configure _attributes : [
{ name : 'condition' , display : 'Conditions' , tag : 'ticket_selector' , null : true } ,
{ name : 'executions' , display : 'Executions' , tag : 'ticket_perform_action' , null : true , notification : true } ,
]
} ,
params : defaults ,
autofocus : true
} )
var params = App . ControllerForm . params ( el )
var test _params = {
condition : {
'ticket.title' : {
operator : 'contains' ,
value : 'some title' ,
} ,
'ticket.organization_id' : {
operator : 'is' ,
pre _condition : 'specific' ,
value : [ '9' , '10' , '11' ] ,
value _completion : ''
} ,
'ticket.owner_id' : {
operator : 'is not' ,
pre _condition : 'specific' ,
value : [ '44' , '45' , '46' ] ,
value _completion : ''
} ,
'ticket.customer_id' : {
operator : 'is' ,
pre _condition : 'specific' ,
value : [ '30' , '31' , '32' ] ,
value _completion : ''
} ,
} ,
executions : {
'ticket.title' : {
value : 'some title new' ,
} ,
'ticket.owner_id' : {
pre _condition : 'specific' ,
value : [ '44' , '46' ] ,
value _completion : ''
} ,
} ,
}
assert . deepEqual ( params , test _params , 'form param condition check for multiple users and organisation' )
2018-05-14 16:01:15 +00:00
} ) ;