Merge branch 'develop' of github.com:martini/zammad into develop
This commit is contained in:
commit
7b15f669d4
5 changed files with 59 additions and 34 deletions
|
@ -2093,6 +2093,9 @@ class App.ControllerForm extends App.Controller
|
||||||
# sort attribute.options
|
# sort attribute.options
|
||||||
_sortOptions: (attribute) ->
|
_sortOptions: (attribute) ->
|
||||||
|
|
||||||
|
# skip sorting if it is disabled by config
|
||||||
|
return if attribute.sortBy == null
|
||||||
|
|
||||||
return if !attribute.options
|
return if !attribute.options
|
||||||
|
|
||||||
if _.isArray( attribute.options )
|
if _.isArray( attribute.options )
|
||||||
|
|
|
@ -114,6 +114,9 @@ class App.Utils
|
||||||
# htmlOnlyWithRichtext = App.Utils.htmlRemoveRichtext( html )
|
# htmlOnlyWithRichtext = App.Utils.htmlRemoveRichtext( html )
|
||||||
@htmlRemoveRichtext: (html) ->
|
@htmlRemoveRichtext: (html) ->
|
||||||
|
|
||||||
|
# remove comments
|
||||||
|
@_removeComments( html )
|
||||||
|
|
||||||
# remove style and class
|
# remove style and class
|
||||||
@_removeAttributes( html )
|
@_removeAttributes( html )
|
||||||
|
|
||||||
|
@ -130,6 +133,9 @@ class App.Utils
|
||||||
# cleanHtmlWithRichText = App.Utils.htmlCleanup( html )
|
# cleanHtmlWithRichText = App.Utils.htmlCleanup( html )
|
||||||
@htmlCleanup: (html) ->
|
@htmlCleanup: (html) ->
|
||||||
|
|
||||||
|
# remove comments
|
||||||
|
@_removeComments( html )
|
||||||
|
|
||||||
# remove style and class
|
# remove style and class
|
||||||
@_removeAttributes( html )
|
@_removeAttributes( html )
|
||||||
|
|
||||||
|
@ -169,6 +175,13 @@ class App.Utils
|
||||||
.removeAttr( 'title' )
|
.removeAttr( 'title' )
|
||||||
html
|
html
|
||||||
|
|
||||||
|
@_removeComments: (html) ->
|
||||||
|
html.contents().each( ->
|
||||||
|
if @nodeType == 8
|
||||||
|
$(@).remove()
|
||||||
|
)
|
||||||
|
html
|
||||||
|
|
||||||
# signatureNeeded = App.Utils.signatureCheck( message, signature )
|
# signatureNeeded = App.Utils.signatureCheck( message, signature )
|
||||||
@signatureCheck: (message, signature) ->
|
@signatureCheck: (message, signature) ->
|
||||||
messageText = $( '<div>' + message + '</div>' ).text().trim()
|
messageText = $( '<div>' + message + '</div>' ).text().trim()
|
||||||
|
|
|
@ -15,40 +15,42 @@ load translations from online
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.load
|
def self.load
|
||||||
url = 'https://i18n.zammad.com/api/v1/translations'
|
Locale.where(active: true).each {|locale|
|
||||||
if !UserInfo.current_user_id
|
url = "https://i18n.zammad.com/api/v1/translations/#{locale.locale}"
|
||||||
UserInfo.current_user_id = 1
|
if !UserInfo.current_user_id
|
||||||
end
|
UserInfo.current_user_id = 1
|
||||||
result = UserAgent.get(
|
end
|
||||||
url,
|
result = UserAgent.get(
|
||||||
{},
|
url,
|
||||||
{
|
{},
|
||||||
json: true,
|
{
|
||||||
}
|
json: true,
|
||||||
)
|
}
|
||||||
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|
|
||||||
|
|
||||||
# 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['locale'], format: translation['format'], source: translation['source'])
|
||||||
translaten = nil
|
translaten = nil
|
||||||
exists.each {|item|
|
exists.each {|item|
|
||||||
if item.source == translation['source']
|
if item.source == translation['source']
|
||||||
translaten = item
|
translaten = item
|
||||||
|
end
|
||||||
|
}
|
||||||
|
if translaten
|
||||||
|
|
||||||
|
# verify if update is needed
|
||||||
|
translaten.update_attributes(translation.symbolize_keys!)
|
||||||
|
translaten.save
|
||||||
|
else
|
||||||
|
Translation.create(translation.symbolize_keys!)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
if translaten
|
end
|
||||||
|
}
|
||||||
# verify if update is needed
|
|
||||||
translaten.update_attributes(translation.symbolize_keys!)
|
|
||||||
translaten.save
|
|
||||||
else
|
|
||||||
Translation.create(translation.symbolize_keys!)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ returns
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
find organization image suggestion
|
find organization image suggestion and store it as app logo
|
||||||
|
|
||||||
result = Service::Image.organization_suggest('edenhofer.de')
|
result = Service::Image.organization_suggest('edenhofer.de')
|
||||||
|
|
||||||
|
@ -72,7 +72,14 @@ returns
|
||||||
backend = load_adapter_by_setting( 'image_backend' )
|
backend = load_adapter_by_setting( 'image_backend' )
|
||||||
return if !backend
|
return if !backend
|
||||||
|
|
||||||
backend.organization_suggest(domain)
|
result = backend.organization_suggest(domain)
|
||||||
|
|
||||||
|
# sync logo to assets folder
|
||||||
|
if result
|
||||||
|
StaticAssets.sync
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -256,7 +256,7 @@ test( "htmlRemoveTags", function() {
|
||||||
// htmlRemoveRichtext
|
// htmlRemoveRichtext
|
||||||
test( "htmlRemoveRichtext", function() {
|
test( "htmlRemoveRichtext", function() {
|
||||||
|
|
||||||
var source = "<div><a href=\"test\">test</a></div>"
|
var source = "<div><!--test comment--><a href=\"test\">test</a></div>"
|
||||||
var should = "test"
|
var should = "test"
|
||||||
var result = App.Utils.htmlRemoveRichtext( $(source) )
|
var result = App.Utils.htmlRemoveRichtext( $(source) )
|
||||||
equal( result.html(), should, source )
|
equal( result.html(), should, source )
|
||||||
|
@ -330,7 +330,7 @@ test( "htmlRemoveRichtext", function() {
|
||||||
// htmlCleanup
|
// htmlCleanup
|
||||||
test( "htmlCleanup", function() {
|
test( "htmlCleanup", function() {
|
||||||
|
|
||||||
var source = "<div><a href=\"test\">test</a></div>"
|
var source = "<div><!--test comment--><a href=\"test\">test</a></div>"
|
||||||
var should = "test"
|
var should = "test"
|
||||||
var result = App.Utils.htmlCleanup( $(source) )
|
var result = App.Utils.htmlCleanup( $(source) )
|
||||||
equal( result.html(), should, source )
|
equal( result.html(), should, source )
|
||||||
|
|
Loading…
Reference in a new issue