diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 6c3e06714..19ef6498e 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -75,6 +75,7 @@ module.exports = { ['/api/sector', `${subDivider}Sector`], ['/api/property', `${subDivider}Property`], ['/api/property_number', `${subDivider}PropertyNumber`], + ['/api/property_select', `${subDivider}PropertySelect`], ['/api/storage_manager', 'Storage Manager'], ['/api/device_manager', 'Device Manager'], ['/api/device', `${subDivider}Device`], diff --git a/docs/api.js b/docs/api.js index cf00bbf06..d3c0698ed 100644 --- a/docs/api.js +++ b/docs/api.js @@ -24,6 +24,7 @@ async function generateDocs () { ['style_manager/model/Sector.js', 'sector.md'], ['style_manager/model/Property.js', 'property.md'], ['style_manager/model/PropertyNumber.js', 'property_number.md'], + ['style_manager/model/PropertySelect.js', 'property_select.md'], ['storage_manager/index.js', 'storage_manager.md'], ['device_manager/index.js', 'device_manager.md'], ['device_manager/model/Device.js', 'device.md'], diff --git a/docs/api/property_select.md b/docs/api/property_select.md new file mode 100644 index 000000000..750a78f22 --- /dev/null +++ b/docs/api/property_select.md @@ -0,0 +1,72 @@ + + +## PropertySelect + +**Extends Property** + +### Properties + +* `options` **[Array][1]<[Object][2]>** Array of option definitions, eg `[{ id: '100', label: 'Set 100' }]` + +### getOptions + +Get available options. + +Returns **[Array][1]<[Object][2]>** Array of options + +### getOption + +Get current selected option or by id. + +#### Parameters + +* `id` **[String][3]** Option id. + +Returns **([Object][2] | null)** + +### setOptions + +Update options. + +#### Parameters + +* `value` **[Array][1]<[Object][2]>** New array of options, eg. `[{ id: 'val-1', label: 'Value 1' }]` (optional, default `[]`) + +### addOption + +Add new option. + +#### Parameters + +* `value` **[Object][2]** Option object, eg. `{ id: 'val-1', label: 'Value 1' }` + +### getOptionId + +Get the option id from the option object. + +#### Parameters + +* `option` **[Object][2]** Option object + +Returns **[String][3]** Option id + +### getOptionLabel + +Get option label. + +#### Parameters + +* `id` **[String][3]** Option id +* `opts` **[Object][2]** Options (optional, default `{}`) + + * `opts.locale` **[Boolean][4]** Use the locale string from i18n module (optional, default `true`) + +Returns **[String][3]** Option label + +[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array + +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object + +[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String + +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean diff --git a/src/style_manager/model/PropertySelect.js b/src/style_manager/model/PropertySelect.js index 364377452..7b50f9b9a 100644 --- a/src/style_manager/model/PropertySelect.js +++ b/src/style_manager/model/PropertySelect.js @@ -25,7 +25,7 @@ export default class PropertySelect extends Property { /** * Get current selected option or by id. - * @param {String} id Option id. + * @param {String} [id] Option id. * @returns {Object | null} */ getOption(id) {