Browse Source

Cleanup for new multiple attribute of user org selector.

Martin Edenhofer 9 years ago
parent
commit
0e5e8d0573

+ 8 - 2
app/assets/javascripts/app/controllers/_ui_element/ticket_selector.coffee

@@ -274,12 +274,12 @@ class App.UiElement.ticket_selector
       options =
         'current_user.id': App.i18n.translateInline('current user')
         'specific': App.i18n.translateInline('specific user')
-        #'set': App.i18n.translateInline('set')
+        'not_set': App.i18n.translateInline('not set (not defined)')
     else if preCondition is 'org'
       options =
         'current_user.organization_id': App.i18n.translateInline('current user organization')
         'specific': App.i18n.translateInline('specific organization')
-        #'set': App.i18n.translateInline('set')
+        'not_set': App.i18n.translateInline('not set (not defined)')
 
     for key, value of options
       selected = ''
@@ -317,6 +317,12 @@ class App.UiElement.ticket_selector
       if 'multiple' of config
         config.multiple = true
         config.nulloption = false
+      if config.relation is 'User'
+        config.multiple = false
+        config.nulloption = false
+      if config.relation is 'Organization'
+        config.multiple = false
+        config.nulloption = false
       if config.tag is 'checkbox'
         config.tag = 'select'
       tagSearch = "#{config.tag}_search"

+ 9 - 6
app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.coffee

@@ -44,7 +44,7 @@ class App.UserOrganizationAutocompletion extends App.Controller
   open: =>
     # prevent rebinding of keydown event
     return if @el.hasClass 'open'
-    
+
     @el.addClass('open')
     $(window).on 'click.UserOrganizationAutocompletion', @close
     $(window).on 'keydown.UserOrganizationAutocompletion', @navigateByKeyboard
@@ -94,7 +94,7 @@ class App.UserOrganizationAutocompletion extends App.Controller
     else
       if user.email
         name += " <#{user.email}>"
-      
+
       @userSelect.val(name)
 
     if @callback
@@ -116,7 +116,7 @@ class App.UserOrganizationAutocompletion extends App.Controller
         return if not token.size()
       else
         token = which
-    
+
     # remove userId from input
     index = @$('.token').index(token)
     ids = @userId.val().split(',')
@@ -237,10 +237,10 @@ class App.UserOrganizationAutocompletion extends App.Controller
     value = ''
 
     if @attribute.multiple && @attribute.value
+
       # fallback for if the value is not an array
-      if typeof @attribute.value is not 'object'
+      if typeof @attribute.value isnt 'object'
         @attribute.value = [@attribute.value]
-
       value = @attribute.value.join ','
 
       # create tokens
@@ -256,7 +256,10 @@ class App.UserOrganizationAutocompletion extends App.Controller
       value = @attribute.value
       if value
         if App.User.exists value
-          name = App.User.find(value).displayName()
+          user = App.User.find(value)
+          name = user.displayName()
+          if user.email
+            name += " <#{user.email}>"
         else
           @log 'userId doesn\'t exist', value
 

+ 0 - 6
test/browser/agent_user_manage_test.rb

@@ -91,14 +91,8 @@ class AgentUserManageTest < TestCase
       css: '.active .newTicket input[name="customer_id_completion"]',
       value: customer_user_email,
     )
-
-    # check if pulldown is open, it's not working stable via selenium
-    @browser.execute_script( "$('.active .newTicket .js-recipientDropdown').addClass('open')" )
-
     sleep 3
-    sendkey( value: :arrow_down )
 
-    sleep 0.5
     click( css: '.active .newTicket .recipientList-entry.js-user.is-active' )
     sleep 1
 

+ 9 - 16
test/browser_test_helper.rb

@@ -71,7 +71,15 @@ class TestCase < Test::Unit::TestCase
       # just try again
       sleep 10
       log('browser_instance', { rescure: true })
-      browser_instance_preferences(local_browser)
+      begin
+        browser_instance_preferences(local_browser)
+      rescue
+        # just try again
+        sleep 10
+        log('browser_instance', { rescure: true })
+        browser_instance_preferences(local_browser)
+      end
+
     end
 
     # upload files from remote dir
@@ -1383,11 +1391,6 @@ wait untill text in selector disabppears
     element.send_keys(params[:customer])
     sleep 2.5
 
-    # check if pulldown is open, it's not working stable via selenium
-    #instance.execute_script("$('#{params[:css]} .js-recipientDropdown').addClass('open')")
-    #sleep 0.5
-    element.send_keys(:arrow_down)
-    sleep 0.2
     element.send_keys(:enter)
     #instance.find_elements(css: params[:css] + ' .recipientList-entry.js-user.is-active')[0].click
     sleep 0.4
@@ -1721,11 +1724,6 @@ wait untill text in selector disabppears
       element.send_keys(data[:customer])
       sleep 2.5
 
-      # check if pulldown is open, it's not working stable via selenium
-      #instance.execute_script("$('.active .newTicket .js-recipientDropdown').addClass('open')")
-      #sleep 0.5
-      element.send_keys(:arrow_down)
-      sleep 0.2
       element.send_keys(:enter)
       #instance.find_elements(css: '.active .newTicket .recipientList-entry.js-user.is-active')[0].click
       sleep 0.4
@@ -1850,11 +1848,6 @@ wait untill text in selector disabppears
       element.send_keys(data[:customer])
       sleep 2.5
 
-      # check if pulldown is open, it's not working stable via selenium
-      #instance.execute_script("$('.modal .user_autocompletion .js-recipientDropdown').addClass('open')")
-      #sleep 0.5
-      element.send_keys(:arrow_down)
-      sleep 0.4
       element.send_keys(:enter)
       #instance.find_elements(css: '.modal .user_autocompletion .recipientList-entry.js-user.is-active')[0].click
       sleep 0.2