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