Improved controller rerender after language change.
This commit is contained in:
parent
2269ef8e4e
commit
10b1fe0690
14 changed files with 340 additions and 38 deletions
|
@ -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!' )
|
||||
|
|
|
@ -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!' )
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')(
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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 )
|
||||
)
|
||||
|
|
|
@ -69,18 +69,12 @@ class _taskManagerSingleton extends Spine.Module
|
|||
else
|
||||
@el = $('#app')
|
||||
@offlineModus = params.offlineModus
|
||||
@workers = {}
|
||||
@workersStarted = {}
|
||||
@allTasks = []
|
||||
@tasksToUpdate = {}
|
||||
@activeTaskHistory = []
|
||||
@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 = []
|
||||
for task in tasks
|
||||
@allTasks.push task.attributes()
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<div class="dashboard main flex center">
|
||||
<div class="tabs wide-tabs horizontal">
|
||||
<div class="tab my-stats active">My Stats</div>
|
||||
<div class="tab my-groups">My Group</div>
|
||||
<div class="tab all-stats">All</div>
|
||||
<div class="tab my-stats active"><%- @T('My Stats') %></div>
|
||||
<div class="tab my-groups"><%- @T('My Group') %></div>
|
||||
<div class="tab all-stats"><%- @T('All') %></div>
|
||||
</div>
|
||||
|
||||
<div class="stat-widgets three-columns horizontal">
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue