diff --git a/app/assets/javascripts/app/controllers/_profile/language.js.coffee b/app/assets/javascripts/app/controllers/_profile/language.js.coffee index 70aae6ec2..6a4869c8c 100644 --- a/app/assets/javascripts/app/controllers/_profile/language.js.coffee +++ b/app/assets/javascripts/app/controllers/_profile/language.js.coffee @@ -50,7 +50,6 @@ class Index extends App.Controller => App.i18n.set( @locale ) App.Event.trigger( 'ui:rerender' ) - App.Event.trigger( 'ui:page:rerender' ) @notify( type: 'success' msg: App.i18n.translateContent( 'Successfully!' ) diff --git a/app/assets/javascripts/app/controllers/_profile/notification.js.coffee b/app/assets/javascripts/app/controllers/_profile/notification.js.coffee index 25e0159d1..112707ba7 100644 --- a/app/assets/javascripts/app/controllers/_profile/notification.js.coffee +++ b/app/assets/javascripts/app/controllers/_profile/notification.js.coffee @@ -129,7 +129,6 @@ class Index extends App.Controller App.Session.get( 'id' ), => App.Event.trigger( 'ui:rerender' ) - App.Event.trigger( 'ui:page:rerender' ) @notify( type: 'success' msg: App.i18n.translateContent( 'Successfully!' ) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee index b993aa514..5241b747d 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -37,6 +37,11 @@ class App.TicketCreate extends App.Controller @log 'notice', 'error', defaults @render(defaults) + # rerender view, e. g. on langauge change + @bind 'ui:rerender', => + return if !@authenticate(true) + @render() + changeFormType: (e) => type = $(e.target).data('type') if !type diff --git a/app/assets/javascripts/app/controllers/dashboard.js.coffee b/app/assets/javascripts/app/controllers/dashboard.js.coffee index 6a69bb761..5c933c2e6 100644 --- a/app/assets/javascripts/app/controllers/dashboard.js.coffee +++ b/app/assets/javascripts/app/controllers/dashboard.js.coffee @@ -53,6 +53,11 @@ class App.Dashboard extends App.Controller # render page @render() + # rerender view, e. g. on langauge change + @bind 'ui:rerender', => + return if !@authenticate(true) + @render() + render: -> @html App.view('dashboard')( @@ -83,7 +88,7 @@ class App.Dashboard extends App.Controller renderWidgetClockFace: (time) => canvas = @el.find 'canvas' - ctx = canvas.get(0).getContext '2d' + ctx = canvas.get(0).getContext '2d' radius = 26 @el.find('.time.stat-widget .stat-amount').text time diff --git a/app/assets/javascripts/app/controllers/navigation.js.coffee b/app/assets/javascripts/app/controllers/navigation.js.coffee index 58cb9c5f2..90e33563d 100644 --- a/app/assets/javascripts/app/controllers/navigation.js.coffee +++ b/app/assets/javascripts/app/controllers/navigation.js.coffee @@ -5,7 +5,7 @@ class App.Navigation extends App.Controller super @render() - # rerender view + # rerender view, e. g. on langauge change @bind 'ui:rerender', (data) => @renderMenu() @renderPersonal() diff --git a/app/assets/javascripts/app/controllers/organization_profile.js.coffee b/app/assets/javascripts/app/controllers/organization_profile.js.coffee index 9e0449e6b..390ed6b66 100644 --- a/app/assets/javascripts/app/controllers/organization_profile.js.coffee +++ b/app/assets/javascripts/app/controllers/organization_profile.js.coffee @@ -7,11 +7,14 @@ class App.OrganizationProfile extends App.Controller App.TaskManager.remove( @task_key ) return - @navupdate '#' - # fetch new data if needed App.Organization.full( @organization_id, @render ) + # rerender view, e. g. on langauge change + @bind 'ui:rerender', => + return if !@authenticate(true) + @render( App.Organization.fullLocal( @organization_id ) ) + meta: => meta = url: @url() diff --git a/app/assets/javascripts/app/controllers/ticket_overview.js.coffee b/app/assets/javascripts/app/controllers/ticket_overview.js.coffee index 9d2997eb5..91e0dd767 100644 --- a/app/assets/javascripts/app/controllers/ticket_overview.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_overview.js.coffee @@ -102,6 +102,11 @@ class Table extends App.Controller @bind 'ticket_overview_local', => @render(true) + # rerender view, e. g. on langauge change + @bind 'ui:rerender', => + return if !@authenticate(true) + @render() + update: (params) => for key, value of params @[key] = value diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index 54dbaae29..64114788c 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -53,6 +53,11 @@ class App.TicketZoom extends App.Controller @delay( update, 1800, 'ticket-zoom-' + @ticket_id ) ) + # rerender view, e. g. on langauge change + @bind 'ui:rerender', => + return if !@authenticate(true) + @render(true) + meta: => # default attributes @@ -239,7 +244,7 @@ class App.TicketZoom extends App.Controller App.Event.trigger 'task:render' @formEnable( @$('.submit') ) - if !@renderDone + if force || !@renderDone @renderDone = true @html App.view('ticket_zoom')( ticket: @ticket diff --git a/app/assets/javascripts/app/controllers/user_profile.js.coffee b/app/assets/javascripts/app/controllers/user_profile.js.coffee index d8896a41a..f5826e88b 100644 --- a/app/assets/javascripts/app/controllers/user_profile.js.coffee +++ b/app/assets/javascripts/app/controllers/user_profile.js.coffee @@ -7,11 +7,14 @@ class App.UserProfile extends App.Controller App.TaskManager.remove( @task_key ) return - @navupdate '#' - # fetch new data if needed @subscribeId = App.User.full( @user_id, @render ) + # rerender view, e. g. on langauge change + @bind 'ui:rerender', => + return if !@authenticate(true) + @render( App.User.fullLocal( @user_id ) ) + release: => App.User.unsubscribe(@subscribeId) diff --git a/app/assets/javascripts/app/lib/app_post/interface_handle.js.coffee b/app/assets/javascripts/app/lib/app_post/interface_handle.js.coffee index df50eba05..1d896b6b0 100644 --- a/app/assets/javascripts/app/lib/app_post/interface_handle.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/interface_handle.js.coffee @@ -91,13 +91,6 @@ class App.Content extends App.Controller new callback( params ) controller( params ) - # rerender view on ui:rerender event - App.Event.bind( - 'ui:page:rerender', => - controller( params ) - 'page' - ) - # scroll to top / remember last screen position # @scrollTo( 0, 0, 100 ) ) diff --git a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee index 088af5e25..2c662b75d 100644 --- a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee @@ -68,19 +68,13 @@ class _taskManagerSingleton extends Spine.Module @el = params.el else @el = $('#app') - @offlineModus = params.offlineModus - @workers = {} - @workersStarted = {} - @allTasks = [] - @tasksToUpdate = {} - @activeTaskHistory = [] + @offlineModus = params.offlineModus @tasksInitial() # render on login App.Event.bind( 'auth:login' => - @reset() @tasksInitial() 'task' ) @@ -96,6 +90,14 @@ class _taskManagerSingleton extends Spine.Module # send updates to server App.Interval.set( @taskUpdateLoop, 2500, 'check_update_to_server_pending', 'task' ) + init: -> + @workers = {} + @workersStarted = {} + @tasksStarted = {} + @allTasks = [] + @tasksToUpdate = {} + @activeTaskHistory = [] + all: -> # sort by prio @@ -125,6 +127,12 @@ class _taskManagerSingleton extends Spine.Module # input validation params.key = App.Utils.htmlAttributeCleanup(params.key) + # remember started task / prevent to open task twice + createNewTask = true + if @tasksStarted[params.key] + createNewTask = false + @tasksStarted[params.key] = true + # if we have init task startups, let the controller know this if params.init params.params.init = true @@ -138,13 +146,14 @@ class _taskManagerSingleton extends Spine.Module if params.show @activeTaskHistory.push _.clone(params) - # create new task if not exists + # check if task already exists in storage / e. g. from last session task = @get( params.key ) + #console.log 'debug', 'execute', params, 'task', task # create new online task if not exists and if not persistent - if !task && !params.persistent - @log 'debug', 'add, create new taskbar in backend' + if !task && createNewTask && !params.persistent + #console.log 'debug', 'add, create new taskbar in backend' task = new App.Taskbar task.load( key: params.key @@ -286,6 +295,10 @@ class _taskManagerSingleton extends Spine.Module # remove task certain task from tasks remove: ( key ) => + + # remember started task + delete @tasksStarted[key] + task = @get( key ) return if !task @@ -337,6 +350,7 @@ class _taskManagerSingleton extends Spine.Module delete @workersStarted[ key ] delete @workers[ key ] + delete @tasksStarted[ key ] # reset while tasks reset: => @@ -350,9 +364,7 @@ class _taskManagerSingleton extends Spine.Module @release(key) # clear instance vars - @tasksToUpdate = {} - @allTasks = [] - @activeTaskHistory = [] + @init() # clear in mem tasks App.Taskbar.deleteAll() @@ -434,10 +446,10 @@ class _taskManagerSingleton extends Spine.Module return tasksInitial: => + @init() # set taskbar collection stored in database - tasks = App.Taskbar.all() - @allTasks = [] + tasks = App.Taskbar.all() for task in tasks @allTasks.push task.attributes() diff --git a/app/assets/javascripts/app/views/dashboard.jst.eco b/app/assets/javascripts/app/views/dashboard.jst.eco index 07d1f6902..d1c962f43 100644 --- a/app/assets/javascripts/app/views/dashboard.jst.eco +++ b/app/assets/javascripts/app/views/dashboard.jst.eco @@ -1,8 +1,8 @@
-
My Stats
-
My Group
-
All
+
<%- @T('My Stats') %>
+
<%- @T('My Group') %>
+
<%- @T('All') %>
diff --git a/test/browser/prefereces_test.rb b/test/browser/prefereces_test.rb index f0db3455c..2f4a03ea4 100644 --- a/test/browser/prefereces_test.rb +++ b/test/browser/prefereces_test.rb @@ -5,10 +5,43 @@ class PreferencesTest < TestCase def test_preferences @browser = browser_instance login( - :username => 'nicole.braun@zammad.org', + :username => 'master@example.com', :password => 'test', :url => browser_url, ) + tasks_close_all() + + # start ticket create + ticket_create( + :data => { + :customer => 'nicole', + :group => 'Users', + :title => 'preferences lang check #1', + :body => 'preferences lang check #1', + }, + :do_not_submit => true, + ) + + # start ticket zoom + ticket = ticket_create( + :data => { + :customer => 'nicole', + :group => 'Users', + :title => 'preferences lang check #2', + :body => 'preferences lang check #2', + }, + ) + + # start user profile + user_open_by_search( + :value => 'Nicole', + ) + + # start organization profile + organization_open_by_search( + :value => 'Zammad Foundation', + ) + click( :css => 'a[href="#current_user"]' ) click( :css => 'a[href="#profile"]' ) click( :css => 'a[href="#profile/language"]' ) @@ -21,6 +54,103 @@ class PreferencesTest < TestCase :css => 'body', :value => 'Sprache', ) + + # check language in navbar + watch_for( + :css => '#navigation', + :value => 'Übersicht' + ) + + # check language in dashboard + click( :css => '#navigation a[href="#dashboard"]' ) + watch_for( + :css => '.content.active', + :value => 'Meine zugewiesenen' + ) + + # check language in overview + click( :css => '#navigation a[href="#ticket/view"]' ) + watch_for( + :css => '.content.active', + :value => 'Meine' + ) + verify_title( + :value => 'Meine zugewiesenen', + ) + + # check language in ticket create + verify_task( + :data => { + :title => 'anruf', + } + ) + open_task( + :data => { + :title => 'preferences lang check #1', + } + ) + watch_for( + :css => '.content.active', + :value => 'kunde' + ) + watch_for( + :css => '.content.active', + :value => 'priorität' + ) + watch_for( + :css => '.content.active [data-name="body"]', + :value => 'preferences lang check #1' + ) + verify_title( + :value => 'anruf', + ) + + # check language in ticket zoom + ticket_open_by_search( + :number => ticket[:number], + ) + watch_for( + :css => '.content.active', + :value => 'erstellt' + ) + watch_for( + :css => '.content.active', + :value => 'priorität' + ) + + # check language in user profile + open_task( + :data => { + :title => 'Nicole', + } + ) + watch_for( + :css => '.content.active', + :value => 'notiz' + ) + watch_for( + :css => '.content.active', + :value => 'e-mail' + ) + watch_for( + :css => '.content.active', + :value => 'aktion' + ) + + # check language in organization profile + open_task( + :data => { + :title => 'Zammad', + } + ) + watch_for( + :css => '.content.active', + :value => 'notiz' + ) + + click( :css => 'a[href="#current_user"]' ) + click( :css => 'a[href="#profile"]' ) + click( :css => 'a[href="#profile/language"]' ) select( :css => '.language_item select[name="locale"]', :value => 'English (United States)', @@ -31,6 +161,104 @@ class PreferencesTest < TestCase :css => 'body', :value => 'Language', ) + + # check language in navbar + watch_for( + :css => '#navigation', + :value => 'Overview' + ) + + # check language in dashboard + click( :css => '#navigation a[href="#dashboard"]' ) + watch_for( + :css => '.content.active', + :value => 'My assig' + ) + + # check language in overview + click( :css => '#navigation a[href="#ticket/view"]' ) + watch_for( + :css => '.content.active', + :value => 'My' + ) + verify_title( + :value => 'My assig', + ) + + # check language in ticket create + verify_task( + :data => { + :title => 'call', + } + ) + open_task( + :data => { + :title => 'preferences lang check #1', + } + ) + watch_for( + :css => '.content.active', + :value => 'customer' + ) + watch_for( + :css => '.content.active', + :value => 'priority' + ) + watch_for( + :css => '.content.active [data-name="body"]', + :value => 'preferences lang check #1' + ) + verify_title( + :value => 'call', + ) + + # check language in ticket zoom + ticket_open_by_search( + :number => ticket[:number], + ) + watch_for( + :css => '.content.active', + :value => 'create' + ) + watch_for( + :css => '.content.active', + :value => 'priority' + ) + + # check language in user profile + open_task( + :data => { + :title => 'Nicole', + } + ) + watch_for( + :css => '.content.active', + :value => 'note' + ) + watch_for( + :css => '.content.active', + :value => 'email' + ) + + # check language in organization profile + open_task( + :data => { + :title => 'Zammad', + } + ) + watch_for( + :css => '.content.active', + :value => 'note' + ) + watch_for( + :css => '.content.active', + :value => 'action' + ) + + # switch to de again + click( :css => 'a[href="#current_user"]' ) + click( :css => 'a[href="#profile"]' ) + click( :css => 'a[href="#profile/language"]' ) select( :css => '.language_item select[name="locale"]', :value => 'Deutsch', @@ -41,11 +269,33 @@ class PreferencesTest < TestCase :css => 'body', :value => 'Sprache', ) - sleep 2 + sleep 4 + + # check if language is still used after reload reload() watch_for( :css => 'body', :value => 'Sprache', ) + + # check language in navbar + watch_for( + :css => '#navigation', + :value => 'Übersicht' + ) + + # check language in dashboard + click( :css => '#navigation a[href="#dashboard"]' ) + watch_for( + :css => '.content.active', + :value => 'Meine' + ) + + # check language in overview + click( :css => '#navigation a[href="#ticket/view"]' ) + watch_for( + :css => '.content.active', + :value => 'Meine' + ) end end \ No newline at end of file diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 748d070d2..2a2564fc0 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -571,6 +571,29 @@ class TestCase < Test::Unit::TestCase true end +=begin + + open_task( + :browser => browser1, + :data => { + :title => 'some title', + } + ) + +=end + + def open_task(params = {}, fallback = false) + instance = params[:browser] || @browser + data = params[:data] + + element = instance.find_elements( { :partial_link_text => data[:title] } )[0] + if !element + raise "no task with title '#{data[:title]}' found" + end + element.click + true + end + =begin file_upload( @@ -614,7 +637,7 @@ class TestCase < Test::Unit::TestCase if params[:timeout] timeout = params[:timeout] end - loops = (timeout).to_i + loops = (timeout).to_i * 2 text = '' (1..loops).each { |loop| element = instance.find_elements( { :css => params[:css] } )[0] @@ -638,7 +661,7 @@ class TestCase < Test::Unit::TestCase # just try again end end - sleep 1 + sleep 0.5 } raise "'#{params[:value]}' found in '#{text}'" end