Merge branch 'develop' of github.com:martini/zammad into develop

This commit is contained in:
Felix Niklas 2015-10-28 14:01:25 +01:00
commit 93705710d4
2 changed files with 26 additions and 17 deletions

View file

@ -346,7 +346,7 @@ class App.ControllerTable extends App.Controller
table
adjustHeaderWidths: (headers) ->
availableWidth = @el.width()
availableWidth = @el.width()
if availableWidth is 0
availableWidth = @minTableWidth
@ -361,7 +361,7 @@ class App.ControllerTable extends App.Controller
if unit is '%'
percentage = parseInt col.width, 10
col.width = percentage / 100 * availableWidth + "px"
col.width = percentage / 100 * availableWidth + 'px'
return col
@ -372,33 +372,33 @@ class App.ControllerTable extends App.Controller
headers = _.map headers, (col) =>
if !col.unresizable
value = parseInt col.width, 10
col.width = Math.max(@minColWidth, value - shrinkBy) + "px"
col.width = Math.max(@minColWidth, value - shrinkBy) + 'px'
return col
# give left-over space from rounding to last column to get to 100%
roundingLeftOver = availableWidth - @getHeaderWidths headers
# but only if there is something left over (will get negative when there are too many columns for each column to stay in their min width)
if roundingLeftOver > 0
headers[headers.length - 1].width = parseInt(headers[headers.length - 1].width, 10) + roundingLeftOver + "px"
headers[headers.length - 1].width = parseInt(headers[headers.length - 1].width, 10) + roundingLeftOver + 'px'
return headers
getShrinkableHeadersCount: (headers) ->
_.reduce headers, (memo, col) ->
_.reduce headers, (memo, col) ->
return if col.unresizable then memo else memo+1
, 0
getHeaderWidths: (headers) ->
widths = _.reduce headers, (memo, col, i) =>
widths = _.reduce headers, (memo, col, i) =>
if col.width
value = parseInt col.width, 10
unit = col.width.match(/[px|%]+/)[0]
else
# !!! sets the width to default width if not set
headers[i].width = @baseColWidth+'px'
headers[i].width = @baseColWidth + 'px'
value = @baseColWidth
unit = 'px'
return if unit is 'px' then memo + value else memo
, 0

View file

@ -45,23 +45,32 @@ dedicated:
fail "Can't load translations from #{url}: #{result.error}" if !result.success?
ActiveRecord::Base.transaction do
result.data.each {|translation|
result.data.each {|translation_raw|
# handle case insensitive sql
exists = Translation.where(locale: translation['locale'], format: translation['format'], source: translation['source'])
translaten = nil
exists = Translation.where(locale: translation_raw['locale'], format: translation_raw['format'], source: translation_raw['source'])
translation = nil
exists.each {|item|
if item.source == translation['source']
translaten = item
if item.source == translation_raw['source']
translation = item
end
}
if translaten
if translation
# verify if update is needed
translaten.update_attributes(translation.symbolize_keys!)
translaten.save
update_needed = false
translation_raw.each {|key, _value|
if translation_raw[key] != translation[key]
update_needed = true
break
end
}
if update_needed
translation.update_attributes(translation_raw.symbolize_keys!)
translation.save
end
else
Translation.create(translation.symbolize_keys!)
Translation.create(translation_raw.symbolize_keys!)
end
}
end