discourse/app/assets/javascripts/admin/models/site_setting.js.coffee

43 lines
1.1 KiB
CoffeeScript
Raw Normal View History

2013-02-05 14:16:51 -05:00
window.Discourse.SiteSetting = Discourse.Model.extend Discourse.Presence,
# Whether a property is short.
short: (->
return true if @blank('value')
return @get('value').toString().length < 80
).property('value')
# Whether the site setting has changed
dirty: (->
@get('originalValue') != @get('value')
).property('originalValue', 'value')
overridden: (->
val = @get('value')
defaultVal = @get('default')
return val.toString() != defaultVal.toString() if (val and defaultVal)
return val != defaultVal
).property('value')
resetValue: ->
@set('value', @get('originalValue'))
save: ->
2013-02-07 10:45:24 -05:00
# Update the setting
2013-02-05 14:16:51 -05:00
$.ajax "/admin/site_settings/#{@get('setting')}",
data:
value: @get('value')
type: 'PUT'
success: => @set('originalValue', @get('value'))
2013-02-07 10:45:24 -05:00
2013-02-05 14:16:51 -05:00
window.Discourse.SiteSetting.reopenClass
2013-02-07 10:45:24 -05:00
findAll: ->
result = Em.A()
2013-02-05 14:16:51 -05:00
$.get "/admin/site_settings", (settings) ->
2013-02-07 10:45:24 -05:00
settings.each (s) ->
2013-02-05 14:16:51 -05:00
s.originalValue = s.value
result.pushObject(Discourse.SiteSetting.create(s))
result