mirror of
https://github.com/pebble-dev/clay.git
synced 2026-08-28 04:46:57 -04:00
Renamed ClayConfig.getSettings() to ClayConfig.serialize()
This commit is contained in:
@@ -523,7 +523,7 @@ Eg: If you run the `.show()` manipulator on an item that is already visible, the
|
||||
| Method | Returns | Event Fired | Description |
|
||||
|--------|---------|-------------| ------------|
|
||||
| `.set( [boolean\|int] value)` | `ClayItem` | `change` | Check/uncheck the state of this item. |
|
||||
| `.get()` | `boolean` | | `true` if checked, `false` if not. **NOTE** this will be converted to a `1` or `0` when sent to the watch. See [`ClayConfig.getSettings()`](#methods) |
|
||||
| `.get()` | `boolean` | | `true` if checked, `false` if not. **NOTE** this will be converted to a `1` or `0` when sent to the watch. See [`Clay.getSettings()`](#methods) |
|
||||
| `.disable()` | `ClayItem` | `disabled` | Prevents this item from being edited by the user. |
|
||||
| `.enable()` | `ClayItem` | `enabled` | Allows this item to be edited by the user. |
|
||||
| `.hide()` | `ClayItem` | `hide` | Hides the item |
|
||||
@@ -556,7 +556,7 @@ Eg: If you run the `.show()` manipulator on an item that is already visible, the
|
||||
| Method | Returns | Event Fired | Description |
|
||||
|--------|---------|-------------| ------------|
|
||||
| `.set( [array] value)` | `ClayItem` | `change` | Checks the checkboxes that corresponds to the provided list of values. |
|
||||
| `.get()` | `Array.<string>` | | Gets an array of strings representing the list of the values of the checked items. **NOTE:** each item in the array will be separated by a zero when sent to the watch. See [`ClayConfig.getSettings()`](#methods) |
|
||||
| `.get()` | `Array.<string>` | | Gets an array of strings representing the list of the values of the checked items. **NOTE:** each item in the array will be separated by a zero when sent to the watch. See [`Clay.getSettings()`](#methods) |
|
||||
| `.disable()` | `ClayItem` | `disabled` | Prevents this item from being edited by the user. |
|
||||
| `.enable()` | `ClayItem` | `enabled` | Allows this item to be edited by the user. |
|
||||
| `.hide()` | `ClayItem` | `hide` | Hides the item |
|
||||
|
||||
@@ -28,7 +28,7 @@ var clayConfig = new ClayConfig(settings, config, $mainForm, clayMeta);
|
||||
$mainForm.on('submit', function() {
|
||||
// Set the return URL depending on the runtime environment
|
||||
location.href = returnTo +
|
||||
encodeURIComponent(JSON.stringify(clayConfig.getSettings()));
|
||||
encodeURIComponent(JSON.stringify(clayConfig.serialize()));
|
||||
});
|
||||
|
||||
// Run the custom function in the context of the ClayConfig
|
||||
|
||||
@@ -155,8 +155,8 @@ function ClayConfig(settings, config, $rootContainer, meta) {
|
||||
/**
|
||||
* @returns {Object}
|
||||
*/
|
||||
self.getSettings = function() {
|
||||
_checkBuilt('getSettings');
|
||||
self.serialize = function() {
|
||||
_checkBuilt('serialize');
|
||||
_.eachObj(_itemsByAppKey, function(appKey, item) {
|
||||
_settings[appKey] = item.get();
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ describe('ClayConfig', function() {
|
||||
'getItemByAppKey',
|
||||
'getItemById',
|
||||
'getItemsByType',
|
||||
'getSettings',
|
||||
'serialize',
|
||||
'registerComponent',
|
||||
'build',
|
||||
'on',
|
||||
@@ -39,7 +39,7 @@ describe('ClayConfig', function() {
|
||||
'getItemByAppKey',
|
||||
'getItemById',
|
||||
'getItemsByType',
|
||||
'getSettings'
|
||||
'serialize'
|
||||
].forEach(function(method) {
|
||||
it('.' + method + '()', function() {
|
||||
var clayConfig = fixtures.clayConfig(['input', 'text'], false);
|
||||
@@ -99,7 +99,7 @@ describe('ClayConfig', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('.getSettings()', function() {
|
||||
describe('.serialize()', function() {
|
||||
it('returns the correct settings', function() {
|
||||
var config = [
|
||||
{type: 'input', appKey: 'test1', defaultValue: 'default val'},
|
||||
@@ -120,7 +120,7 @@ describe('ClayConfig', function() {
|
||||
|
||||
var clayConfig = fixtures.clayConfig(config, true, true, settings);
|
||||
|
||||
assert.deepEqual(clayConfig.getSettings(), {
|
||||
assert.deepEqual(clayConfig.serialize(), {
|
||||
test1: 'default val',
|
||||
test2: 'val-2',
|
||||
test3: false,
|
||||
@@ -131,17 +131,17 @@ describe('ClayConfig', function() {
|
||||
clayConfig.getItemByAppKey('test3').set(true);
|
||||
clayConfig.getItemByAppKey('test4').set(['cb-1', 'cb-3']);
|
||||
|
||||
assert.deepEqual(clayConfig.getSettings(), {
|
||||
assert.deepEqual(clayConfig.serialize(), {
|
||||
test1: 'val-1',
|
||||
test2: 'val-2',
|
||||
test3: true,
|
||||
test4: ['cb-1', 'cb-3']
|
||||
});
|
||||
|
||||
// make sure the result of getSettings() can actually be fed back in to
|
||||
// make sure the result of serialize() can actually be fed back in to
|
||||
// a new instance of ClayConfig
|
||||
assert.doesNotThrow(function() {
|
||||
settings = clayConfig.getSettings();
|
||||
settings = clayConfig.serialize();
|
||||
fixtures.clayConfig(config, true, true, settings);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user