Fixed issue #859 - Changing "Product Name" breaks "Admin" menu.
This commit is contained in:
parent
72c4de570e
commit
90fcff7bd9
4 changed files with 53 additions and 44 deletions
|
@ -47,37 +47,10 @@ class App.SettingsAreaItem extends App.Controller
|
|||
for item in @setting.options['form']
|
||||
directValue += 1
|
||||
directData = params[item.name]
|
||||
|
||||
value = undefined
|
||||
if directValue > 1
|
||||
state_current = {
|
||||
value: params
|
||||
}
|
||||
#App.Config.set((@setting.name, params)
|
||||
value = params
|
||||
else
|
||||
state_current = {
|
||||
value: directData
|
||||
}
|
||||
#App.Config.set(@setting.name, directData)
|
||||
value = directData
|
||||
|
||||
@setting['state_current'] = state_current
|
||||
ui = @
|
||||
@setting.save(
|
||||
done: =>
|
||||
ui.formEnable(e)
|
||||
App.Event.trigger 'notify', {
|
||||
type: 'success'
|
||||
msg: App.i18n.translateContent('Update successful!')
|
||||
timeout: 2000
|
||||
}
|
||||
|
||||
# rerender ui || get new collections and session data
|
||||
App.Setting.preferencesPost(@setting)
|
||||
|
||||
fail: (settings, details) ->
|
||||
ui.formEnable(e)
|
||||
App.Event.trigger 'notify', {
|
||||
type: 'error'
|
||||
msg: App.i18n.translateContent(details.error_human || details.error || 'Unable to update object!')
|
||||
timeout: 2000
|
||||
}
|
||||
)
|
||||
App.Setting.set(@setting['name'], value)
|
||||
|
|
|
@ -5,10 +5,12 @@ class App.Setting extends App.Model
|
|||
|
||||
@get: (name) ->
|
||||
setting = App.Setting.findByAttribute('name', name)
|
||||
throw "No such setting '#{name}' found!" if !setting
|
||||
setting.state_current.value
|
||||
|
||||
@set: (name, value, options = {}) ->
|
||||
setting = App.Setting.findByAttribute('name', name)
|
||||
throw "No such setting '#{name}' found!" if !setting
|
||||
setting.state_current.value = value
|
||||
if !options.done
|
||||
options.done = ->
|
||||
|
@ -27,22 +29,25 @@ class App.Setting extends App.Model
|
|||
msg: App.i18n.translateContent(details.error_human || details.error || 'Unable to update object!')
|
||||
timeout: 2000
|
||||
}
|
||||
App.Config.set(name, value)
|
||||
if setting.frontend
|
||||
App.Config.set(name, value)
|
||||
setting.save(options)
|
||||
|
||||
@preferencesPost: (setting) ->
|
||||
return if !setting.preferences
|
||||
if setting.preferences.render
|
||||
App.Event.trigger('ui:rerender')
|
||||
setting.preferences.trigger ||= []
|
||||
setting.preferences.trigger.push 'ui:rerender'
|
||||
|
||||
if setting.preferences.trigger
|
||||
events = setting.preferences.trigger
|
||||
if !_.isArray(setting.preferences.trigger)
|
||||
events = [setting.preferences.trigger]
|
||||
delay = ->
|
||||
for event in events
|
||||
return if _.isEmpty(setting.preferences.trigger)
|
||||
events = setting.preferences.trigger
|
||||
if !_.isArray(setting.preferences.trigger)
|
||||
events = [setting.preferences.trigger]
|
||||
|
||||
count = 0
|
||||
for event in events
|
||||
count += 1
|
||||
do (event, count) ->
|
||||
delay = ->
|
||||
App.Event.trigger(event)
|
||||
App.Delay.set(delay, 20)
|
||||
|
||||
if setting.preferences.session_check
|
||||
App.Auth.loginCheck()
|
||||
App.Delay.set(delay, 300 * count)
|
||||
|
|
|
@ -115,7 +115,6 @@ Setting.create_if_not_exists(
|
|||
},
|
||||
preferences: {
|
||||
render: true,
|
||||
session_check: true,
|
||||
prio: 1,
|
||||
placeholder: true,
|
||||
permission: ['admin.branding'],
|
||||
|
|
|
@ -140,4 +140,36 @@ class SettingTest < TestCase
|
|||
value: 'facebook',
|
||||
)
|
||||
end
|
||||
|
||||
def test_product_name
|
||||
@browser = browser_instance
|
||||
login(
|
||||
username: 'master@example.com',
|
||||
password: 'test',
|
||||
url: browser_url,
|
||||
)
|
||||
tasks_close_all()
|
||||
|
||||
verify_title(value: 'Zammad Test System')
|
||||
|
||||
click(css: 'a[href="#manage"]')
|
||||
click(css: '.content.active a[href="#settings/branding"]')
|
||||
set(
|
||||
css: '.content.active [name="product_name"]',
|
||||
value: 'ABC App',
|
||||
)
|
||||
click(css: '.content.active #product_name button[type=submit]')
|
||||
|
||||
sleep 2
|
||||
verify_title(value: 'ABC App')
|
||||
set(
|
||||
css: '.content.active [name="product_name"]',
|
||||
value: 'Zammad Test System',
|
||||
)
|
||||
click(css: '.content.active #product_name button[type=submit]')
|
||||
|
||||
sleep 2
|
||||
verify_title(value: 'Zammad Test System')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue