Added setting preferences options.
This commit is contained in:
parent
9c0a535d28
commit
0e95df4fe1
3 changed files with 47 additions and 8 deletions
|
@ -19,11 +19,19 @@ class App.SettingsArea extends App.Controller
|
||||||
)
|
)
|
||||||
|
|
||||||
render: =>
|
render: =>
|
||||||
|
|
||||||
|
# serach area settings
|
||||||
settings = App.Setting.search(
|
settings = App.Setting.search(
|
||||||
filter:
|
filter:
|
||||||
area: @area
|
area: @area
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# sort by prio
|
||||||
|
settings = _.sortBy( settings, (setting) ->
|
||||||
|
return if !setting.preferences
|
||||||
|
setting.preferences.prio
|
||||||
|
)
|
||||||
|
|
||||||
html = $('<div></div>')
|
html = $('<div></div>')
|
||||||
for setting in settings
|
for setting in settings
|
||||||
if setting.name is 'product_logo'
|
if setting.name is 'product_logo'
|
||||||
|
@ -101,11 +109,15 @@ class App.SettingsAreaItem extends App.Controller
|
||||||
msg: App.i18n.translateContent('Update successful!')
|
msg: App.i18n.translateContent('Update successful!')
|
||||||
timeout: 2000
|
timeout: 2000
|
||||||
}
|
}
|
||||||
ui.render()
|
|
||||||
|
|
||||||
|
# rerender ui || get new collections and session data
|
||||||
|
if @setting.preferences
|
||||||
|
|
||||||
|
if @setting.preferences.render
|
||||||
|
ui.render()
|
||||||
App.Event.trigger( 'ui:rerender' )
|
App.Event.trigger( 'ui:rerender' )
|
||||||
|
|
||||||
# login check
|
if @setting.preferences.session_check
|
||||||
App.Auth.loginCheck()
|
App.Auth.loginCheck()
|
||||||
fail: =>
|
fail: =>
|
||||||
ui.formEnable(e)
|
ui.formEnable(e)
|
||||||
|
@ -174,16 +186,12 @@ class App.SettingsAreaLogo extends App.Controller
|
||||||
success: (data, status, xhr) =>
|
success: (data, status, xhr) =>
|
||||||
@formEnable(e)
|
@formEnable(e)
|
||||||
if data.result is 'ok'
|
if data.result is 'ok'
|
||||||
@formEnable(e)
|
|
||||||
|
|
||||||
App.Event.trigger 'notify', {
|
App.Event.trigger 'notify', {
|
||||||
type: 'success'
|
type: 'success'
|
||||||
msg: App.i18n.translateContent('Update successful!')
|
msg: App.i18n.translateContent('Update successful!')
|
||||||
timeout: 2000
|
timeout: 2000
|
||||||
}
|
}
|
||||||
@render()
|
|
||||||
|
|
||||||
App.Event.trigger( 'ui:rerender' )
|
|
||||||
for key, value of data.settings
|
for key, value of data.settings
|
||||||
App.Config.set( key, value )
|
App.Config.set( key, value )
|
||||||
else
|
else
|
||||||
|
|
|
@ -4,6 +4,7 @@ class Setting < ApplicationModel
|
||||||
store :options
|
store :options
|
||||||
store :state
|
store :state
|
||||||
store :state_initial
|
store :state_initial
|
||||||
|
store :preferences
|
||||||
before_create :state_check, :set_initial
|
before_create :state_check, :set_initial
|
||||||
before_update :state_check
|
before_update :state_check
|
||||||
after_create :delete_cache
|
after_create :delete_cache
|
||||||
|
|
30
db/migrate/20150712000002_update_setting2.rb
Normal file
30
db/migrate/20150712000002_update_setting2.rb
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
class UpdateSetting2 < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
|
||||||
|
# add preferences
|
||||||
|
add_column :settings, :preferences, :string, limit: 2000, null: true
|
||||||
|
|
||||||
|
# update settings
|
||||||
|
%w(product_name ticket_hook chat).each {|setting_name|
|
||||||
|
setting = Setting.find_by(name: setting_name)
|
||||||
|
next if !setting
|
||||||
|
setting.preferences[:render] = true
|
||||||
|
setting.save
|
||||||
|
}
|
||||||
|
%w(product_name).each {|setting_name|
|
||||||
|
setting = Setting.find_by(name: setting_name)
|
||||||
|
next if !setting
|
||||||
|
setting.preferences[:session_check] = true
|
||||||
|
setting.save
|
||||||
|
}
|
||||||
|
setting = Setting.find_by(name: 'product_name')
|
||||||
|
setting.preferences[:prio] = 1
|
||||||
|
setting.save
|
||||||
|
setting = Setting.find_by(name: 'organization')
|
||||||
|
setting.preferences[:prio] = 2
|
||||||
|
setting.save
|
||||||
|
setting = Setting.find_by(name: 'product_logo')
|
||||||
|
setting.preferences[:prio] = 3
|
||||||
|
setting.save
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue