diff --git a/resources/docs/extras/advanced-property-syntax.md b/resources/docs/extras/advanced-property-syntax.md index 9bfa7e01..d6843481 100644 --- a/resources/docs/extras/advanced-property-syntax.md +++ b/resources/docs/extras/advanced-property-syntax.md @@ -83,6 +83,8 @@ Additionnal functions: - `unpack(x)`: remove an array's brackets (`unpack([1,2])` returns `"1, 2"`) - `pad(x, padding)`: add leading zeros if the length the integer part of `x` is smaller than `padding` (`pad(1,2)` returns `"01"`) - `length(x)`: returns the length of an array or string +- `keys(x)`: returns an array of a given object's property names (from [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)) +- `values(x)`: returns an array of a given object's own enumerable property values (from [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)) !!! tip "" A single widget property can contain multiple formulas. Variables and functions declared in a formula are available to subsequent formulas in the same property definition. diff --git a/src/browser/js/app/widgets/utils.js b/src/browser/js/app/widgets/utils.js index a08eb457..5a1a8d51 100644 --- a/src/browser/js/app/widgets/utils.js +++ b/src/browser/js/app/widgets/utils.js @@ -86,6 +86,8 @@ module.exports = { return dec ? int + '.' + dec : int }, length: function(x) { return x.length }, + values: function(x) { return Object.values(x) }, + keys: function(x) { return Object.keys(x) }, // basic relationnal to keep alphabetical string comparison (v4 change) equal: function(a, b) { return a == b }, unequal: function(a, b) { return a != b },