From 7759cd617bb06047c5a15b3d893bb47f0dd19933 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 21 Feb 2013 22:10:07 +0100 Subject: [PATCH] Improved generic setting widget. --- .../app/controllers/_settings/area.js.coffee | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_settings/area.js.coffee b/app/assets/javascripts/app/controllers/_settings/area.js.coffee index 154c16528..bdbe7d7ea 100644 --- a/app/assets/javascripts/app/controllers/_settings/area.js.coffee +++ b/app/assets/javascripts/app/controllers/_settings/area.js.coffee @@ -29,11 +29,14 @@ class App.SettingsAreaItem extends App.Controller render: => # defaults + directValue = 0 for item in @setting.options['form'] - if typeof @setting.state.value is 'object' - item['default'] = @setting.state.value[item.name] - else - item['default'] = @setting.state.value + directValue = +1 + + if directValue > 1 + item['default'] = @setting.state.value[item.name] + else + item['default'] = @setting.state.value # form @configure_attributes = @setting.options['form'] @@ -53,7 +56,11 @@ class App.SettingsAreaItem extends App.Controller e.preventDefault() params = @formParam(e.target) @log 'submit', @setting, params, e.target, typeof @setting.state.value - if typeof @setting.state.value is 'object' + directValue = 0 + for item in @setting.options['form'] + directValue = +1 + + if directValue > 1 state = { value: params }