diff --git a/app/assets/javascripts/app/controllers/widget/organization.coffee b/app/assets/javascripts/app/controllers/widget/organization.coffee index 77ba6b3ad..9eb2ac433 100644 --- a/app/assets/javascripts/app/controllers/widget/organization.coffee +++ b/app/assets/javascripts/app/controllers/widget/organization.coffee @@ -28,12 +28,20 @@ class App.WidgetOrganization extends App.Controller if nameNew of organization name = nameNew - # add to show if value exists - if ( organization[name]? || attributeConfig.tag is 'richtext' ) && attributeConfig.shown + # do not show name since it's already shown via diplayName() + continue if name is 'name' - # do not show firstname and lastname / already show via diplayName() - if name isnt 'name' && organization[name] isnt '' - organizationData.push attributeConfig + # do not show if configured to be not shown + continue if !attributeConfig.shown + + # Fix for issue #2277 - note is not shown for customer/organisations if it's empty + # Always show for these two conditions: + # 1. the attribute exists and is not empty + # 2. it is a richtext note field + continue if ( !organization[name]? || organization[name] is '' ) && attributeConfig.tag isnt 'richtext' + + # add to show if all checks passed + organizationData.push attributeConfig # insert userData @html App.view('widget/organization')( diff --git a/app/assets/javascripts/app/controllers/widget/user.coffee b/app/assets/javascripts/app/controllers/widget/user.coffee index 07631843c..f0ad335c5 100644 --- a/app/assets/javascripts/app/controllers/widget/user.coffee +++ b/app/assets/javascripts/app/controllers/widget/user.coffee @@ -30,12 +30,20 @@ class App.WidgetUser extends App.Controller if nameNew of user name = nameNew - # add to show if value exists - if ( user[name]? || attributeConfig.tag is 'richtext' ) && attributeConfig.shown + # do not show firstname and lastname since they are already shown via diplayName() + continue if name is 'firstname' || name is 'lastname' || name is 'organization' - # do not show firstname and lastname / already show via displayName() - if name isnt 'firstname' && name isnt 'lastname' && name isnt 'organization' && user[name] isnt '' - userData.push attributeConfig + # do not show if configured to be not shown + continue if !attributeConfig.shown + + # Fix for issue #2277 - note is not shown for customer/organisations if it's empty + # Always show for these two conditions: + # 1. the attribute exists and is not empty + # 2. it is a richtext note field + continue if ( !user[name]? || user[name] is '' ) && attributeConfig.tag isnt 'richtext' + + # add to show if all checks passed + userData.push attributeConfig if user.preferences items = [] diff --git a/test/browser/admin_object_manager_test.rb b/test/browser/admin_object_manager_test.rb index d2e9e23ff..d4b131cfe 100644 --- a/test/browser/admin_object_manager_test.rb +++ b/test/browser/admin_object_manager_test.rb @@ -776,6 +776,7 @@ class AdminObjectManagerTest < TestCase end # verify fix for issue #2233 - Boolean object set to false is not visible + # verify fix for issue #2277 - Note is not shown for customer / organisations if it's empty def test_false_boolean_attributes_gets_displayed_for_organizations @browser = browser_instance login( @@ -830,6 +831,10 @@ class AdminObjectManagerTest < TestCase css: '.content.active .sidebar[data-tab="organization"] .sidebar-content', value: 'text_test', ) + match( + css: '.content.active .sidebar[data-tab="organization"] .sidebar-content', + value: 'note', + ) object_manager_attribute_delete( data: { @@ -847,6 +852,7 @@ class AdminObjectManagerTest < TestCase end # verify fix for issue #2233 - Boolean object set to false is not visible + # verify fix for issue #2277 - Note is not shown for customer / organisations if it's empty def test_false_boolean_attributes_gets_displayed_for_users @browser = browser_instance login( @@ -901,6 +907,10 @@ class AdminObjectManagerTest < TestCase css: '.content.active .sidebar[data-tab="customer"] .sidebar-content', value: 'text_test', ) + match( + css: '.content.active .sidebar[data-tab="customer"] .sidebar-content', + value: 'note', + ) object_manager_attribute_delete( data: {