@iamproperty/components 2.7.8 → 2.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iamproperty/components",
3
- "version": "2.7.8",
3
+ "version": "2.7.9",
4
4
  "private": false,
5
5
  "description": "Component library for iamproperty",
6
6
  "author": {
@@ -20,6 +20,21 @@
20
20
  import { ucfirst, unsnake } from '../../helpers/strings'
21
21
  import table from '../../../assets/js/modules/table.js'
22
22
 
23
+ let numericValue = function(value) {
24
+
25
+
26
+ console.log(value);
27
+
28
+ value = value.replace('£','')
29
+ value = value.replace('%','')
30
+
31
+ if (Number.isNaN(Number.parseFloat(value))) {
32
+ return 0;
33
+ }
34
+
35
+ return Number.parseFloat(value)
36
+ }
37
+
23
38
  export default {
24
39
  name: 'Table',
25
40
  props: {
@@ -65,14 +80,8 @@ export default {
65
80
  numericValue () {
66
81
  return (value) => {
67
82
 
68
- value = value.replace('£','')
69
- value = value.replace('%','')
70
-
71
- if (Number.isNaN(Number.parseFloat(value))) {
72
- return 0;
73
- }
74
-
75
- return Number.parseFloat(value)
83
+ value = numericValue(value);
84
+ return value;
76
85
  }
77
86
  }
78
87
  },
@@ -103,7 +112,11 @@ export default {
103
112
 
104
113
  let tbodyHTML = '';
105
114
  this.items.forEach((row, index) => {
106
- tbodyHTML += `<tr>${ Object.keys(row).map(col => `<td data-label="${ucfirst(unsnake(col))}">${row[col]}</td>` ).join("") }</tr>`;
115
+
116
+ let rowID = row['rowid'] ? row['rowid'] : '';
117
+ row = Object.fromEntries(Object.entries(row).filter(([key]) => key !== 'rowid'));
118
+
119
+ tbodyHTML += `<tr data-row-id="${rowID}">${ Object.keys(row).map(col => `<td data-label="${ucfirst(unsnake(col))}" data-numeric="${numericValue(row[col])}">${row[col]}</td>` ).join("") }</tr>`;
107
120
  });
108
121
  tbody.innerHTML = tbodyHTML;
109
122