pebble / clay

Pebble Config Framework
MIT License
121 stars 29 forks source link

Allow devs to select config items by group #124

Closed keegan-lillo closed 7 years ago

keegan-lillo commented 8 years ago
[
  {
    "type": "input",
    "messageKey": "COOL_THINGS[0]",
    "defaultValue": "",
    "label": "Input Field",
    "group": "COOL_THINGS"
  },
  {
    "type": "input",
    "messageKey": "COOL_THINGS[1]",
    "defaultValue": "",
    "label": "Input Field",
    "group": "COOL_THINGS"
  },
]

Then to get the items in the group you would do:

var coolThingsItems = clayConfig.getItemsByGroup('COOL_THINGS')

As a temporary workaround you can do the following in your custom function:

clayConfig.getItemsByGroup = function(group) {
  return this.getAllItems().filter(function(item) {
    return item.config.group === group;
  });
}

var coolThingsItems = getItemsByGroup('COOL_THINGS')