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,10 +13,14 @@ 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')
=> )
@load() @bind('i18n:translation_update_list', =>
@load('i18n:translation_update_list')
)
@bind('i18n:translation_update', =>
@load()
) )
render: => render: =>
@ -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,11 +60,12 @@ class Index extends App.ControllerContent
updateOnServer: @updateOnServer updateOnServer: @updateOnServer
getAttributes: @getAttributes getAttributes: @getAttributes
) )
@translationToDo.update( if !event || event is 'i18n:translation_update_todo'
stringsNotTranslated: @stringsNotTranslated @translationToDo.update(
stringsTranslated: @stringsTranslated stringsNotTranslated: @stringsNotTranslated
times: @times stringsTranslated: @stringsTranslated
) times: @times
)
if !@translationList if !@translationList
@translationList = new TranslationList( @translationList = new TranslationList(
el: @$('.js-List') el: @$('.js-List')
@ -74,16 +73,15 @@ class Index extends App.ControllerContent
updateOnServer: @updateOnServer updateOnServer: @updateOnServer
getAttributes: @getAttributes getAttributes: @getAttributes
) )
@translationList.update( if !event || event is 'i18n:translation_update_list'
stringsNotTranslated: @stringsNotTranslated @translationList.update(
stringsTranslated: @stringsTranslated stringsNotTranslated: @stringsNotTranslated
times: @times stringsTranslated: @stringsTranslated
) 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) =>