Follow up fix for issue #1952 - New ticket attributes is also show for customers (which should not).

This commit is contained in:
Martin Edenhofer 2018-04-16 02:11:17 +02:00
parent 6b2e43baef
commit 7fac7501f7
2 changed files with 92 additions and 3 deletions

View file

@ -466,9 +466,9 @@ class App.ControllerForm extends App.Controller
uncheckParam = {}
lookupForm.find('input[type=checkbox]').each( (index) ->
type = $(@).data('field-type')
checked = $(@).attr('checked')
checked = $(@).prop('checked')
name = $(@).attr('name')
if name && !checked && (!(name of param) || param[name] is '')
if name && !checked && !(name of param)
if !(name of uncheckParam)
if type is 'boolean'
uncheckParam[name] = false
@ -482,7 +482,7 @@ class App.ControllerForm extends App.Controller
# verify if we have not checked radios
lookupForm.find('input[type=radio]').each( (index) ->
type = $(@).data('field-type')
checked = $(@).attr('checked')
checked = $(@).prop('checked')
name = $(@).attr('name')
if name && !checked && !(name of param)
if type is 'boolean'

View file

@ -1176,3 +1176,92 @@ test("object manager form 2", function() {
deepEqual(params, test_params, 'form param check')
});
test("object manager form 3", function() {
$('#forms').append('<hr><h1>object manager 3</h1><form id="form13"></form>')
var el = $('#form13')
var defaults = {}
new App.ControllerForm({
el: el,
model: {
configure_attributes: [
{ name: 'data_type', display: 'Format', tag: 'object_manager_attribute', null: false },
],
},
params: $.extend(defaults, { object: 'Ticket' }),
autofocus: true
});
var params = App.ControllerForm.params(el)
var test_params = {
data_option: {
default: "",
maxlength: 120,
type: "text"
},
data_type: "input",
screens: {
create_middle: {
"ticket.agent": {
shown: true,
required: false,
},
"ticket.customer": {
shown: true,
required: false,
}
},
edit: {
"ticket.agent": {
shown: true,
required: false,
},
"ticket.customer": {
shown: true,
required: false,
}
}
}
}
deepEqual(params, test_params, 'form param check')
el.find('[name="screens::create_middle::ticket.customer::shown"]').click()
el.find('[name="screens::edit::ticket.customer::shown"]').click()
params = App.ControllerForm.params(el)
test_params = {
data_option: {
default: "",
maxlength: 120,
type: "text"
},
data_type: "input",
screens: {
create_middle: {
"ticket.agent": {
shown: true,
required: false,
},
"ticket.customer": {
shown: false,
required: false,
}
},
edit: {
"ticket.agent": {
shown: true,
required: false,
},
"ticket.customer": {
shown: false,
required: false,
}
}
}
}
deepEqual(params, test_params, 'form param check')
});