ywana-core8 0.0.213 → 0.0.217

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": "ywana-core8",
3
- "version": "0.0.213",
3
+ "version": "0.0.217",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
package/src/html/table.js CHANGED
@@ -74,9 +74,9 @@ export const DataTable = (props) => {
74
74
  <table>
75
75
  <thead>
76
76
  <tr>
77
- {columns.map(({ id, label, type, sortable }) => {
77
+ {columns.map(({ id, label, type, item, sortable }) => {
78
78
  const sort = sortDir[id] ? sortDir[id] : null
79
- const [rowspan, colspan] = type === TYPES.ENTITY ? [1, 3] : [2, 1]
79
+ const [rowspan, colspan] = type === TYPES.ENTITY ? [1, Object.keys(item).length] : [2, 1]
80
80
  return (
81
81
  <th rowSpan={rowspan} colSpan={colspan}>
82
82
  {id === "checked" ? <CheckBox onChange={checkAll} /> : <Text key={`th_${id}`}>{label}</Text>}
@@ -94,7 +94,7 @@ export const DataTable = (props) => {
94
94
  const { item } = column
95
95
  const fields = item ? Object.values(item) : []
96
96
  return fields
97
- .filter(field => !field.column)
97
+ .filter(field => field.column === true)
98
98
  .map(field => <th>{field.label}</th>)
99
99
  })
100
100
  }
@@ -145,7 +145,7 @@ const DataTableRow = (props) => {
145
145
  const DataTableCell = ({ row, column, cell, editable }) => {
146
146
 
147
147
  const render = (type) => {
148
- const { id, disabled = false, min, max, onChange, format, options } = column
148
+ const { id, disabled = false, min, max, onChange, format, options, item } = column
149
149
  if (id === "checked") {
150
150
  return <CheckBox id={id} value={cell} onChange={(id, value) => onChange(row.id, id, value)} />
151
151
  } else if (editable && onChange) {
@@ -166,25 +166,27 @@ const DataTableCell = ({ row, column, cell, editable }) => {
166
166
  case "ICON": return <Icon icon={cell} />
167
167
  case "Boolean": return <BooleanCellViewer id={id} value={cell} />
168
168
  case "String": return <StringCellViewer id={id} value={cell} format={format} options={options} />
169
- case TYPES.ENTITY: return <EntityCellViewer id={id} value={cell} />
170
169
  default: return cell
171
170
  }
172
171
  }
173
172
  }
174
173
 
175
- return (
174
+ return column.type === TYPES.ENTITY ? <EntityCellViewer id={column.id} item={column.item} value={cell} /> : (
176
175
  <td key={column.id} className={column.id}>{render(column.type)}</td>
177
176
  )
178
177
  }
179
178
 
180
- const EntityCellViewer = ({ id, value }) => {
181
- console.log(id, value)
182
- const subcells = value ? Object.values(value) : [1, 2, 3]
183
- return (
184
- <div className='entity-cell-viewer'>
185
- {subcells.filter(v => !v).map(v => <div>{v}</div>)}
186
- </div>
187
- )
179
+ /**
180
+ * Entity Cell Viewer
181
+ * @param {*} param0
182
+ * @returns
183
+ */
184
+ const EntityCellViewer = ({ id, item, value }) => {
185
+ console.log(id, item, value)
186
+ const fields = Object.values(item).filter(field => field.column === true)
187
+ return fields.map( field => {
188
+ return (<td key={column.id} className={`entity-cell ${column.id}`} >{value[field.id]}</td>)
189
+ })
188
190
  }
189
191
 
190
192
  /**
package/src/test.js CHANGED
@@ -6,7 +6,7 @@ const Test = (props) => {
6
6
 
7
7
  <div>
8
8
 
9
- <table>
9
+ <table border="1">
10
10
  <thead>
11
11
  <tr>
12
12
  <th rowspan="2" colspan="1"><div class="checkbox"><input type="checkbox" value=""/><span class="checkmark"></span><label></label></div></th>
@@ -14,8 +14,7 @@ const Test = (props) => {
14
14
  <th rowspan="2" colspan="1"><span>Fecha de Entrada</span></th>
15
15
  <th rowspan="2" colspan="1"><span>Circuito</span></th>
16
16
  <th rowspan="2" colspan="1"><span>Clase de Muestra</span></th>
17
- <th rowspan="2" colspan="3"><span>Referencia</span></th>
18
- <th rowspan="2" colspan="1"></th>
17
+ <th colspan="3"><span>Referencia</span></th>
19
18
  <th></th>
20
19
  </tr>
21
20
  <tr>