Improved toggle of action buttons.

This commit is contained in:
Martin Edenhofer 2015-11-19 14:25:39 +01:00
parent 579a15677a
commit 8cce0ef88c

View file

@ -13,9 +13,13 @@ class Index extends App.ControllerContent
@title 'Translations', true @title 'Translations', true
@locale = App.i18n.get() @locale = App.i18n.get()
@render() @render()
@bind( @bind('i18n:translation_update_todo', =>
'i18n:translation_update_todo i18n:translation_update_list i18n:translation_update', @load('i18n:translation_update_todo')
=> )
@bind('i18n:translation_update_list', =>
@load('i18n:translation_update_list')
)
@bind('i18n:translation_update', =>
@load() @load()
) )
@ -30,7 +34,7 @@ class Index extends App.ControllerContent
) )
@load() @load()
load: => load: (event) =>
@ajax( @ajax(
id: 'translations_admin' id: 'translations_admin'
type: 'GET' type: 'GET'
@ -41,12 +45,6 @@ class Index extends App.ControllerContent
@stringsNotTranslated = [] @stringsNotTranslated = []
@stringsTranslated = [] @stringsTranslated = []
for item in data.list for item in data.list
# if item has changed
if item[2] isnt item[3]
@showAction()
# collect items
if item[4] is 'time' if item[4] is 'time'
@times.push item @times.push item
else else
@ -62,6 +60,7 @@ class Index extends App.ControllerContent
updateOnServer: @updateOnServer updateOnServer: @updateOnServer
getAttributes: @getAttributes getAttributes: @getAttributes
) )
if !event || event is 'i18n:translation_update_todo'
@translationToDo.update( @translationToDo.update(
stringsNotTranslated: @stringsNotTranslated stringsNotTranslated: @stringsNotTranslated
stringsTranslated: @stringsTranslated stringsTranslated: @stringsTranslated
@ -74,16 +73,15 @@ class Index extends App.ControllerContent
updateOnServer: @updateOnServer updateOnServer: @updateOnServer
getAttributes: @getAttributes getAttributes: @getAttributes
) )
if !event || event is 'i18n:translation_update_list'
@translationList.update( @translationList.update(
stringsNotTranslated: @stringsNotTranslated stringsNotTranslated: @stringsNotTranslated
stringsTranslated: @stringsTranslated stringsTranslated: @stringsTranslated
times: @times times: @times
) )
@toggleAction()
) )
showAction: =>
@$('.js-changes').removeClass('hidden')
release: => release: =>
rerender = -> rerender = ->
App.Event.trigger('ui:rerender') App.Event.trigger('ui:rerender')
@ -91,9 +89,18 @@ class Index extends App.ControllerContent
if @translationList.changes() if @translationList.changes()
App.Delay.set(rerender, 400) App.Delay.set(rerender, 400)
showAction: =>
@$('.js-changes').removeClass('hidden')
hideAction: => hideAction: =>
@el.closest('.content').find('.js-changes').addClass('hidden') @el.closest('.content').find('.js-changes').addClass('hidden')
toggleAction: =>
if @$('.js-Reset:visible').length > 0
@showAction()
else
@hideAction()
pushChanges: => pushChanges: =>
@loader = new App.ControllerModalLoading( @loader = new App.ControllerModalLoading(
head: 'Push my changes' head: 'Push my changes'
@ -186,9 +193,10 @@ class Index extends App.ControllerContent
url: url url: url
data: JSON.stringify(params) data: JSON.stringify(params)
processData: false processData: false
success: (data, status, xhr) -> success: (data, status, xhr) =>
if event if event
App.Event.trigger(event) App.Event.trigger(event)
@toggleAction()
) )
getAttributes: (e) => getAttributes: (e) =>