diff options
Diffstat (limited to 'app/assets/javascripts/registry/shared/utils.js')
-rw-r--r-- | app/assets/javascripts/registry/shared/utils.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/assets/javascripts/registry/shared/utils.js b/app/assets/javascripts/registry/shared/utils.js new file mode 100644 index 00000000000..d85a3ad28c2 --- /dev/null +++ b/app/assets/javascripts/registry/shared/utils.js @@ -0,0 +1,19 @@ +export const findDefaultOption = options => { + const item = options.find(o => o.default); + return item ? item.key : null; +}; + +export const mapComputedToEvent = (list, root) => { + const result = {}; + list.forEach(e => { + result[e] = { + get() { + return this[root][e]; + }, + set(value) { + this.$emit('input', { ...this[root], [e]: value }); + }, + }; + }); + return result; +}; |