mirror of
https://github.com/pebble-dev/clay.git
synced 2026-09-05 16:47:37 -04:00
change "value" to "defaultValue"
This commit is contained in:
+10
-10
@@ -5,12 +5,12 @@ module.exports = [
|
|||||||
{
|
{
|
||||||
"type": "heading",
|
"type": "heading",
|
||||||
"id": "main-heading",
|
"id": "main-heading",
|
||||||
"value": "Clay Test Page",
|
"defaultValue": "Clay Test Page",
|
||||||
"size": 1
|
"size": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"value": "Some arbitrary text explaining how this all works. " +
|
"defaultValue": "Some arbitrary text explaining how this all works. " +
|
||||||
"It's cool if this wraps across multiple lines"
|
"It's cool if this wraps across multiple lines"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -18,12 +18,12 @@ module.exports = [
|
|||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"type": "heading",
|
"type": "heading",
|
||||||
"value": "This is a section"
|
"defaultValue": "This is a section"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "input",
|
"type": "input",
|
||||||
"appKey": "email",
|
"appKey": "email",
|
||||||
"value": "",
|
"defaultValue": "",
|
||||||
"label": "Email",
|
"label": "Email",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"placeholder": "eg: name@domain.com",
|
"placeholder": "eg: name@domain.com",
|
||||||
@@ -36,19 +36,19 @@ module.exports = [
|
|||||||
"type": "toggle",
|
"type": "toggle",
|
||||||
"appKey": "cool_stuff",
|
"appKey": "cool_stuff",
|
||||||
"label": "Enable Cool Stuff",
|
"label": "Enable Cool Stuff",
|
||||||
"value": true
|
"defaultValue": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "color",
|
"type": "color",
|
||||||
"appKey": "background",
|
"appKey": "colorTest",
|
||||||
"value": "FF0000",
|
"defaultValue": "FF0000",
|
||||||
"label": "Background Color",
|
"label": "Background Color",
|
||||||
"sunlight": false
|
"sunlight": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "color",
|
"type": "color",
|
||||||
"appKey": "background",
|
"appKey": "background",
|
||||||
"value": "00FF00",
|
"defaultValue": "00FF00",
|
||||||
"label": "Sunny Color",
|
"label": "Sunny Color",
|
||||||
"sunlight": true
|
"sunlight": true
|
||||||
}
|
}
|
||||||
@@ -59,13 +59,13 @@ module.exports = [
|
|||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"type": "heading",
|
"type": "heading",
|
||||||
"value": "More Settings"
|
"defaultValue": "More Settings"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "flavor",
|
"id": "flavor",
|
||||||
"type": "select",
|
"type": "select",
|
||||||
"appKey": "flavor",
|
"appKey": "flavor",
|
||||||
"value": "grape",
|
"defaultValue": "grape",
|
||||||
"label": "Favorite Flavor",
|
"label": "Favorite Flavor",
|
||||||
"options": [
|
"options": [
|
||||||
{ "label": "Berry things", "value": "berry" },
|
{ "label": "Berry things", "value": "berry" },
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* A Clay config Item
|
* A Clay config Item
|
||||||
* @typedef {object} Clay~ConfigItem
|
* @typedef {object} Clay~ConfigItem
|
||||||
* @property {string} type
|
* @property {string} type
|
||||||
* @property {string|boolean|number} value
|
* @property {string|boolean|number} defaultValue
|
||||||
* @property {string} [appKey]
|
* @property {string} [appKey]
|
||||||
* @property {string} [id]
|
* @property {string} [id]
|
||||||
* @property {string} [label]
|
* @property {string} [label]
|
||||||
@@ -68,7 +68,7 @@ function ClayConfig(settings, config, $rootContainer) {
|
|||||||
// set the value of the item via the manipulator to ensure consistency
|
// set the value of the item via the manipulator to ensure consistency
|
||||||
var value = typeof _settings[item.appKey] !== 'undefined' ?
|
var value = typeof _settings[item.appKey] !== 'undefined' ?
|
||||||
_settings[item.appKey] :
|
_settings[item.appKey] :
|
||||||
(item.value || '');
|
(item.defaultValue || '');
|
||||||
|
|
||||||
clayItem.set(value);
|
clayItem.set(value);
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ describe('component - color', function() {
|
|||||||
type: 'color',
|
type: 'color',
|
||||||
sunlight: true,
|
sunlight: true,
|
||||||
id: '1',
|
id: '1',
|
||||||
value: 'ff0000'
|
defaultValue: 'ff0000'
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
var colorItem = clayConfig.getItemById('1');
|
var colorItem = clayConfig.getItemById('1');
|
||||||
@@ -41,7 +41,7 @@ describe('component - color', function() {
|
|||||||
type: 'color',
|
type: 'color',
|
||||||
sunlight: false,
|
sunlight: false,
|
||||||
id: '1',
|
id: '1',
|
||||||
value: 'ff0000'
|
defaultValue: 'ff0000'
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
var colorItem = clayConfig.getItemById('1');
|
var colorItem = clayConfig.getItemById('1');
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ describe('component - color', function() {
|
|||||||
var clayConfig = fixture.clayConfig([
|
var clayConfig = fixture.clayConfig([
|
||||||
{
|
{
|
||||||
type: 'select',
|
type: 'select',
|
||||||
value: 'value-1',
|
defaultValue: 'value-1',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'label 1', value: 'value-1' },
|
{ label: 'label 1', value: 'value-1' },
|
||||||
{ label: 'label 2', value: 'value-2' }
|
{ label: 'label 2', value: 'value-2' }
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ describe('ClayConfig', function() {
|
|||||||
it('returns the correct settings', function() {
|
it('returns the correct settings', function() {
|
||||||
var clayConfig = fixtures.clayConfig(
|
var clayConfig = fixtures.clayConfig(
|
||||||
[
|
[
|
||||||
{type: 'input', appKey: 'test1', value: 'not this'},
|
{type: 'input', appKey: 'test1', defaultValue: 'default val'},
|
||||||
{type: 'select', appKey: 'test2', options: [
|
{type: 'select', appKey: 'test2', options: [
|
||||||
{label: 'label-1', value: 'val-1'},
|
{label: 'label-1', value: 'val-1'},
|
||||||
{label: 'label-2', value: 'val-2'}
|
{label: 'label-2', value: 'val-2'}
|
||||||
@@ -97,11 +97,17 @@ describe('ClayConfig', function() {
|
|||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
{
|
{
|
||||||
test1: 'val-1' // set one of the values via settings
|
test2: 'val-2' // set one of the values via settings
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
clayConfig.getItemByAppKey('test2').set('val-2');
|
assert.deepEqual(clayConfig.getSettings(), {
|
||||||
|
test1: 'default val',
|
||||||
|
test2: 'val-2',
|
||||||
|
test3: false
|
||||||
|
});
|
||||||
|
|
||||||
|
clayConfig.getItemByAppKey('test1').set('val-1');
|
||||||
clayConfig.getItemByAppKey('test3').set(true);
|
clayConfig.getItemByAppKey('test3').set(true);
|
||||||
|
|
||||||
assert.deepEqual(clayConfig.getSettings(), {
|
assert.deepEqual(clayConfig.getSettings(), {
|
||||||
|
|||||||
Reference in New Issue
Block a user