Merge branch 'develop' of github.com:martini/zammad into develop
This commit is contained in:
commit
93705710d4
|
@ -346,7 +346,7 @@ class App.ControllerTable extends App.Controller
|
||||||
table
|
table
|
||||||
|
|
||||||
adjustHeaderWidths: (headers) ->
|
adjustHeaderWidths: (headers) ->
|
||||||
availableWidth = @el.width()
|
availableWidth = @el.width()
|
||||||
|
|
||||||
if availableWidth is 0
|
if availableWidth is 0
|
||||||
availableWidth = @minTableWidth
|
availableWidth = @minTableWidth
|
||||||
|
@ -361,7 +361,7 @@ class App.ControllerTable extends App.Controller
|
||||||
|
|
||||||
if unit is '%'
|
if unit is '%'
|
||||||
percentage = parseInt col.width, 10
|
percentage = parseInt col.width, 10
|
||||||
col.width = percentage / 100 * availableWidth + "px"
|
col.width = percentage / 100 * availableWidth + 'px'
|
||||||
|
|
||||||
return col
|
return col
|
||||||
|
|
||||||
|
@ -372,33 +372,33 @@ class App.ControllerTable extends App.Controller
|
||||||
headers = _.map headers, (col) =>
|
headers = _.map headers, (col) =>
|
||||||
if !col.unresizable
|
if !col.unresizable
|
||||||
value = parseInt col.width, 10
|
value = parseInt col.width, 10
|
||||||
col.width = Math.max(@minColWidth, value - shrinkBy) + "px"
|
col.width = Math.max(@minColWidth, value - shrinkBy) + 'px'
|
||||||
return col
|
return col
|
||||||
|
|
||||||
# give left-over space from rounding to last column to get to 100%
|
# give left-over space from rounding to last column to get to 100%
|
||||||
roundingLeftOver = availableWidth - @getHeaderWidths headers
|
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)
|
# 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
|
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
|
return headers
|
||||||
|
|
||||||
getShrinkableHeadersCount: (headers) ->
|
getShrinkableHeadersCount: (headers) ->
|
||||||
_.reduce headers, (memo, col) ->
|
_.reduce headers, (memo, col) ->
|
||||||
return if col.unresizable then memo else memo+1
|
return if col.unresizable then memo else memo+1
|
||||||
, 0
|
, 0
|
||||||
|
|
||||||
getHeaderWidths: (headers) ->
|
getHeaderWidths: (headers) ->
|
||||||
widths = _.reduce headers, (memo, col, i) =>
|
widths = _.reduce headers, (memo, col, i) =>
|
||||||
if col.width
|
if col.width
|
||||||
value = parseInt col.width, 10
|
value = parseInt col.width, 10
|
||||||
unit = col.width.match(/[px|%]+/)[0]
|
unit = col.width.match(/[px|%]+/)[0]
|
||||||
else
|
else
|
||||||
# !!! sets the width to default width if not set
|
# !!! sets the width to default width if not set
|
||||||
headers[i].width = @baseColWidth+'px'
|
headers[i].width = @baseColWidth + 'px'
|
||||||
value = @baseColWidth
|
value = @baseColWidth
|
||||||
unit = 'px'
|
unit = 'px'
|
||||||
|
|
||||||
return if unit is 'px' then memo + value else memo
|
return if unit is 'px' then memo + value else memo
|
||||||
, 0
|
, 0
|
||||||
|
|
||||||
|
|
|
@ -45,23 +45,32 @@ dedicated:
|
||||||
fail "Can't load translations from #{url}: #{result.error}" if !result.success?
|
fail "Can't load translations from #{url}: #{result.error}" if !result.success?
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
result.data.each {|translation|
|
result.data.each {|translation_raw|
|
||||||
|
|
||||||
# handle case insensitive sql
|
# handle case insensitive sql
|
||||||
exists = Translation.where(locale: translation['locale'], format: translation['format'], source: translation['source'])
|
exists = Translation.where(locale: translation_raw['locale'], format: translation_raw['format'], source: translation_raw['source'])
|
||||||
translaten = nil
|
translation = nil
|
||||||
exists.each {|item|
|
exists.each {|item|
|
||||||
if item.source == translation['source']
|
if item.source == translation_raw['source']
|
||||||
translaten = item
|
translation = item
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
if translaten
|
if translation
|
||||||
|
|
||||||
# verify if update is needed
|
# verify if update is needed
|
||||||
translaten.update_attributes(translation.symbolize_keys!)
|
update_needed = false
|
||||||
translaten.save
|
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
|
else
|
||||||
Translation.create(translation.symbolize_keys!)
|
Translation.create(translation_raw.symbolize_keys!)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue