diff options
author | Dixsie Wolmers <dixsie@ibm.com> | 2021-09-07 23:33:16 +0300 |
---|---|---|
committer | Dixsie Wolmers <dixsie@ibm.com> | 2021-09-24 22:59:31 +0300 |
commit | 9726f9a7cb07a3dcee14d641c2fea7b4f013e5fc (patch) | |
tree | eb2b4ac5a53c8354324ec4cada6c2fbe00324811 /src/components/Mixins/DataFormatterMixin.js | |
parent | 6a192d526c9efebf7a614a9aa473eee62e555fc5 (diff) | |
download | webui-vue-9726f9a7cb07a3dcee14d641c2fea7b4f013e5fc.tar.xz |
Rename TableDataFormatter mixin to DataFormatter
Mixin was renamed to reflect usage on all components,
not only tables.
Signed-off-by: Dixsie Wolmers <dixsie@ibm.com>
Change-Id: Ic962ba879fffa39b9f6f93446771fbf6f67915d0
Diffstat (limited to 'src/components/Mixins/DataFormatterMixin.js')
-rw-r--r-- | src/components/Mixins/DataFormatterMixin.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/components/Mixins/DataFormatterMixin.js b/src/components/Mixins/DataFormatterMixin.js new file mode 100644 index 00000000..5ce79327 --- /dev/null +++ b/src/components/Mixins/DataFormatterMixin.js @@ -0,0 +1,30 @@ +const DataFormatterMixin = { + methods: { + dataFormatter(value) { + if (value === undefined || value === null || value === '') { + return '--'; + } else if (typeof value === 'number') { + return parseFloat(value.toFixed(3)); + } else { + return value; + } + }, + statusIcon(status) { + switch (status) { + case 'OK': + return 'success'; + case 'Warning': + return 'warning'; + case 'Critical': + return 'danger'; + default: + return ''; + } + }, + dataFormatterArray(value) { + return value.join(', '); + }, + }, +}; + +export default DataFormatterMixin; |