Fixed issue #2233 - Boolean object set to false is not visible (fixes #2233)

This commit is contained in:
Billy Zhou 2018-09-16 00:22:56 +08:00
parent 9a7118123d
commit 8bf3ab24d5
4 changed files with 93 additions and 8 deletions

View file

@ -29,7 +29,7 @@ class App.WidgetOrganization extends App.Controller
name = nameNew name = nameNew
# add to show if value exists # add to show if value exists
if ( organization[name] || attributeConfig.tag is 'richtext' ) && attributeConfig.shown if ( organization[name]? || attributeConfig.tag is 'richtext' ) && attributeConfig.shown
# do not show firstname and lastname / already show via diplayName() # do not show firstname and lastname / already show via diplayName()
if name isnt 'name' if name isnt 'name'

View file

@ -8,7 +8,7 @@
</div> </div>
<% for row in @organizationData: %> <% for row in @organizationData: %>
<% if @organization[row.name] || row.name is 'note': %> <% if @organization[row.name]? || row.name is 'note': %>
<div class="sidebar-block"> <div class="sidebar-block">
<% if row.tag isnt 'richtext': %> <% if row.tag isnt 'richtext': %>
<label><%- @T(row.display) %></label> <label><%- @T(row.display) %></label>

View file

@ -774,4 +774,56 @@ class AdminObjectManagerTest < TestCase
object_manager_attribute_migrate object_manager_attribute_migrate
end end
# verify fix for issue #2233 - Boolean object set to false is not visible
def test_false_boolean_attributes_gets_displayed
@browser = browser_instance
login(
username: 'master@example.com',
password: 'test',
url: browser_url,
)
tasks_close_all()
object_manager_attribute_create(
data: {
object: 'Organization',
name: 'bool_test',
display: 'bool_test',
data_type: 'Boolean',
data_option: {
options: {
# rubocop:disable Lint/BooleanSymbol
true: 'YES',
false: 'NO',
# rubocop:enable Lint/BooleanSymbol
}
},
},
)
object_manager_attribute_migrate
ticket_open_by_title(title: 'select')
click( css: '.content.active .tabsSidebar-tab[data-tab="organization"]' )
click( css: '.content.active .sidebar[data-tab="organization"] .js-actions .dropdown-toggle' )
click( css: '.content.active .sidebar[data-tab="organization"] .js-actions [data-type="organization-edit"]' )
modal_ready
select(css: '.content.active .modal select[name="bool_test"]', value: 'NO')
click( css: '.content.active .modal .js-submit' )
modal_disappear
watch_for(
css: '.content.active .sidebar[data-tab="organization"] .sidebar-content',
value: 'bool_test',
)
object_manager_attribute_delete(
data: {
object: 'Organization',
name: 'bool_test',
},
)
object_manager_attribute_migrate
end
end end

View file

@ -3895,6 +3895,7 @@ wait untill text in selector disabppears
object_manager_attribute_create( object_manager_attribute_create(
browser: browser2, browser: browser2,
data: { data: {
object: 'Ticket', # optional, defaults to Ticket
name: 'field_name' + random, name: 'field_name' + random,
display: 'Display Name of Field', display: 'Display Name of Field',
data_type: 'Select', data_type: 'Select',
@ -3913,6 +3914,7 @@ wait untill text in selector disabppears
object_manager_attribute_create( object_manager_attribute_create(
browser: browser2, browser: browser2,
data: { data: {
object: 'Ticket', # optional, defaults to Ticket
name: 'field_name' + random, name: 'field_name' + random,
display: 'Display Name of Field', display: 'Display Name of Field',
data_type: 'Text', data_type: 'Text',
@ -3927,6 +3929,7 @@ wait untill text in selector disabppears
object_manager_attribute_create( object_manager_attribute_create(
browser: browser2, browser: browser2,
data: { data: {
object: 'Ticket', # optional, defaults to Ticket
name: 'field_name' + random, name: 'field_name' + random,
display: 'Display Name of Field', display: 'Display Name of Field',
data_type: 'Integer', data_type: 'Integer',
@ -3942,6 +3945,7 @@ wait untill text in selector disabppears
object_manager_attribute_create( object_manager_attribute_create(
browser: browser2, browser: browser2,
data: { data: {
object: 'Ticket', # optional, defaults to Ticket
name: 'field_name' + random, name: 'field_name' + random,
display: 'Display Name of Field', display: 'Display Name of Field',
data_type: 'Datetime', data_type: 'Datetime',
@ -3957,6 +3961,7 @@ wait untill text in selector disabppears
object_manager_attribute_create( object_manager_attribute_create(
browser: browser2, browser: browser2,
data: { data: {
object: 'Ticket', # optional, defaults to Ticket
name: 'field_name' + random, name: 'field_name' + random,
display: 'Display Name of Field', display: 'Display Name of Field',
data_type: 'Date', data_type: 'Date',
@ -3972,6 +3977,7 @@ wait untill text in selector disabppears
object_manager_attribute_create( object_manager_attribute_create(
browser: browser2, browser: browser2,
data: { data: {
object: 'Ticket', # optional, defaults to Ticket
name: 'field_name' + random, name: 'field_name' + random,
display: 'Display Name of Field', display: 'Display Name of Field',
data_type: 'Boolean', data_type: 'Boolean',
@ -3995,6 +4001,9 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
data = params[:data] data = params[:data]
data[:object] = data[:object] || 'Ticket'
raise 'invalid object parameter in object_manager_attribute_create' if %w[Ticket User Organization Group].exclude? data[:object]
# make sure that required params are supplied # make sure that required params are supplied
%i[name display data_type].each do |s| %i[name display data_type].each do |s|
next if data.key? s next if data.key? s
@ -4017,7 +4026,12 @@ wait untill text in selector disabppears
) )
click( click(
browser: instance, browser: instance,
css: '.content.active .js-new', css: ".content.active a[href='#c-#{data[:object]}']",
mute_log: true,
)
click(
browser: instance,
css: ".content.active #c-#{data[:object]} .js-new",
mute_log: true, mute_log: true,
) )
@ -4029,6 +4043,7 @@ wait untill text in selector disabppears
object_manager_attribute_update( object_manager_attribute_update(
browser: browser2, browser: browser2,
data: { data: {
object: 'Ticket', # optional, defaults to Ticket
name: 'field_name' + random, name: 'field_name' + random,
display: 'Display Name of Field', display: 'Display Name of Field',
data_type: 'Select', data_type: 'Select',
@ -4053,6 +4068,9 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
data = params[:data] data = params[:data]
data[:object] = data[:object] || 'Ticket'
raise 'invalid object parameter in object_manager_attribute_update' if %w[Ticket User Organization Group].exclude? data[:object]
click( click(
browser: instance, browser: instance,
css: 'a[href="#manage"]', css: 'a[href="#manage"]',
@ -4067,7 +4085,12 @@ wait untill text in selector disabppears
browser: instance, browser: instance,
css: '.content.active .js-new', css: '.content.active .js-new',
) )
instance.execute_script("$(\".content.active td:contains('#{data[:name]}')\").first().click()") click(
browser: instance,
css: ".content.active a[href='#c-#{data[:object]}']",
mute_log: true,
)
instance.execute_script("$(\".content.active #c-#{data[:object]} td:contains('#{data[:name]}')\").first().click()")
object_manager_attribute_perform('update', params) object_manager_attribute_perform('update', params)
end end
@ -4077,6 +4100,7 @@ wait untill text in selector disabppears
object_manager_attribute_delete( object_manager_attribute_delete(
browser: browser2, browser: browser2,
data: { data: {
object: 'Ticket', # optional, defaults to Ticket
name: 'field_name' + random, name: 'field_name' + random,
}, },
) )
@ -4090,6 +4114,9 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
data = params[:data] data = params[:data]
data[:object] = data[:object] || 'Ticket'
raise 'invalid object parameter in object_manager_attribute_delete' if %w[Ticket User Organization Group].exclude? data[:object]
click( click(
browser: instance, browser: instance,
css: 'a[href="#manage"]', css: 'a[href="#manage"]',
@ -4100,12 +4127,18 @@ wait untill text in selector disabppears
css: '.content.active a[href="#system/object_manager"]', css: '.content.active a[href="#system/object_manager"]',
mute_log: true, mute_log: true,
) )
watch_for(
browser: instance,
css: '.content.active .js-new',
)
click(
browser: instance,
css: ".content.active a[href='#c-#{data[:object]}']",
mute_log: true,
)
sleep 4 sleep 4
instance = params[:browser] || @browser r = instance.execute_script("$(\".content.active #c-#{data[:object]} td:contains('#{data[:name]}')\").first().closest('tr').find('.js-delete').click()")
data = params[:data]
r = instance.execute_script("$(\".content.active td:contains('#{data[:name]}')\").first().closest('tr').find('.js-delete').click()")
#p "rrr #{r.inspect}"
end end
=begin =begin