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
diff --git a/src/components/Mixins/DataFormatterMixin.js b/src/components/Mixins/DataFormatterMixin.js
new file mode 100644
index 0000000..5ce7932
--- /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;