1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-06 12:00:08 +02:00

Hopefully make SettingsService work with boolean values.

This commit is contained in:
Simo Kinnunen 2014-07-14 19:31:47 +09:00
parent 1d77d8c97d
commit 85d71f43b8

View file

@ -54,8 +54,12 @@ module.exports = function SettingsServiceFactory(
}
SettingsService.bind = function(scope, options) {
function value(possibleValue, defaultValue) {
return (possibleValue !== void 0) ? possibleValue : defaultValue
}
var source = options.source || options.target
, defaultValue = options.defaultValue || scope[options.target]
, defaultValue = value(options.defaultValue, scope[options.target])
scope.$watch(
options.target
@ -79,13 +83,13 @@ module.exports = function SettingsServiceFactory(
// settings were reset, for example. In that case we fall back
// to the default value.
if (newValue !== oldValue) {
scope[options.target] = newValue || defaultValue
scope[options.target] = value(newValue, defaultValue)
}
}
, true
)
scope[options.target] = settings[source] || defaultValue
scope[options.target] = value(settings[source], defaultValue)
}
SettingsService.sync = function(object, options, monitor) {