ywana-core8 0.0.781 → 0.0.783
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/dist/index.cjs +45 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +45 -28
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +45 -28
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/table.js +18 -8
- package/src/html/table.test.js +10 -10
- package/src/incubator/task.js +28 -20
package/package.json
CHANGED
package/src/html/table.js
CHANGED
@@ -174,7 +174,7 @@ const DataTableRow = (props) => {
|
|
174
174
|
const DataTableCell = ({ index, row, column, cell, editable }) => {
|
175
175
|
|
176
176
|
const render = (type) => {
|
177
|
-
const { id, disabled = false, min, max, onChange, format, options, item, action } = column
|
177
|
+
const { id, disabled = false, min, max, onChange, format, options, item, action, maxDecimals } = column
|
178
178
|
|
179
179
|
|
180
180
|
if (id === "checked") {
|
@@ -198,7 +198,7 @@ const DataTableCell = ({ index, row, column, cell, editable }) => {
|
|
198
198
|
case "ICON": return <Icon icon={cell} />
|
199
199
|
case "Boolean": return <BooleanCellViewer id={id} value={cell} />
|
200
200
|
case "String": return <StringCellViewer id={id} value={cell} format={format} options={options} action={action} />
|
201
|
-
case "Number": return <NumberCellViewer id={id} value={cell} format={format} />
|
201
|
+
case "Number": return <NumberCellViewer id={id} value={cell} format={format} maxDecimals={maxDecimals} />
|
202
202
|
default: return cell
|
203
203
|
}
|
204
204
|
}
|
@@ -260,7 +260,7 @@ const BooleanCellViewer = ({ id, value = false }) => {
|
|
260
260
|
* NumberCellViewer
|
261
261
|
*/
|
262
262
|
const NumberCellViewer = ({ id, value, format, maxDecimals }) => {
|
263
|
-
|
263
|
+
/*
|
264
264
|
function formatNumber(number) {
|
265
265
|
// convert number to numeric
|
266
266
|
if (number === null) return "null"
|
@@ -273,6 +273,20 @@ const NumberCellViewer = ({ id, value, format, maxDecimals }) => {
|
|
273
273
|
const thousands = /\B(?=(\d{3})+(?!\d))/g;
|
274
274
|
return numberPart.replace(thousands, ".") + (decimalPart ? "," + decimalPart : "");
|
275
275
|
}
|
276
|
+
*/
|
277
|
+
function formatNumber(number, maxDecimals = 0) {
|
278
|
+
if (number === null) return "null"
|
279
|
+
let result = number.toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
280
|
+
// thousands separator is a dot
|
281
|
+
var parts = result.toString().split(",");
|
282
|
+
const numberPart = parts[0];
|
283
|
+
const decimalPart = parts[1];
|
284
|
+
const thousands = /\B(?=(\d{3})+(?!\d))/g;
|
285
|
+
|
286
|
+
// limit decimal part to maxdecimals
|
287
|
+
const decimal = decimalPart ? decimalPart.substring(0, maxDecimals) : null;
|
288
|
+
return numberPart.replace(thousands, ".") + (decimal ? "," + decimal : "");
|
289
|
+
}
|
276
290
|
|
277
291
|
if (format) {
|
278
292
|
switch (format) {
|
@@ -288,11 +302,8 @@ const NumberCellViewer = ({ id, value, format, maxDecimals }) => {
|
|
288
302
|
// if value is not a number, return value
|
289
303
|
if (isNaN(number)) return value
|
290
304
|
|
291
|
-
// if maxDecimals is defined, round number
|
292
|
-
if (maxDecimals) number = number.toFixed(maxDecimals)
|
293
|
-
|
294
305
|
// format number
|
295
|
-
return <span>{formatNumber(number)}</span>
|
306
|
+
return <span>{formatNumber(number, maxDecimals)}</span>
|
296
307
|
|
297
308
|
default:
|
298
309
|
return <span>{value}</span>
|
@@ -370,7 +381,6 @@ export const StringCellEditor = ({ id, value = '', options, onChange }) => {
|
|
370
381
|
*/
|
371
382
|
const SortIcon = (props) => {
|
372
383
|
const { sortDir, onChange } = props
|
373
|
-
console.log("sortDir", sortDir)
|
374
384
|
const icon = sortDir ? sortDir > 0 ? "arrow_upward" : "arrow_downward" : "swap_vert"
|
375
385
|
return <Icon icon={icon} size="small" clickable action={onChange} />
|
376
386
|
}
|
package/src/html/table.test.js
CHANGED
@@ -6,15 +6,15 @@ export const TableTest = (prop) => {
|
|
6
6
|
|
7
7
|
const [rows, setRows] = useState(
|
8
8
|
[
|
9
|
-
{ id: 1, checked: false, name: "John Smith" , description: "lorem ipsum 9", color: "#CACAFF", num: 25, thumb: "https://w7.pngwing.com/pngs/881/826/png-transparent-pikachu-ash-ketchum-pokemon-vrste-pikachu-leaf-flower-meme-thumbnail.png" },
|
10
|
-
{ id: 2, checked: false, name: "Ann Martin" , description: "lorem ipsum 2", color: "#CCFFFF", num: 1234567890.1234567890 },
|
11
|
-
{ id: 3, checked: false, name: "Ann Martin" , description: "lorem ipsum 8", color: "#CCFFFF", num: 12340.1234567890 },
|
12
|
-
{ id: 4, checked: false, name: "Zack McCracken", description: "lorem ipsum 4", color: "#CCFFFF", num: 567890.1234567890 },
|
13
|
-
{ id: 5, checked: false, name: "Ann Martin" , description: "lorem ipsum 1", color: "#CCFFFF", num: 23670.190 },
|
14
|
-
{ id: 6, checked: false, name: "John Smith" , description: "lorem ipsum 2", color: "#CCFFFF", num: 71230.10 },
|
15
|
-
{ id: 7, checked: false, name: "Ann Martin" , description: "lorem ipsum 1", color: "#CCFFFF", num: 3490.23 },
|
16
|
-
{ id: 8, checked: false, name: "Martin Freeman", description: "lorem ipsum 4", color: "#CCFFFF" , num: 890.1234567890 },
|
17
|
-
{ id: 9, checked: false, name: "Ann Martin" , description: "lorem ipsum 5", color: "#CCFFFF", date: new Date().toString() },
|
9
|
+
{ id: 1, checked: false, name: "John Smith" , description: "lorem ipsum 9", color: "#CACAFF", num: "25", thumb: "https://w7.pngwing.com/pngs/881/826/png-transparent-pikachu-ash-ketchum-pokemon-vrste-pikachu-leaf-flower-meme-thumbnail.png" },
|
10
|
+
{ id: 2, checked: false, name: "Ann Martin" , description: "lorem ipsum 2", color: "#CCFFFF", num: "1234567890.1234567890" },
|
11
|
+
{ id: 3, checked: false, name: "Ann Martin" , description: "lorem ipsum 8", color: "#CCFFFF", num: "12340.1234567890" },
|
12
|
+
{ id: 4, checked: false, name: "Zack McCracken", description: "lorem ipsum 4", color: "#CCFFFF", num: "567890.1234567890" },
|
13
|
+
{ id: 5, checked: false, name: "Ann Martin" , description: "lorem ipsum 1", color: "#CCFFFF", num: "23670.190" },
|
14
|
+
{ id: 6, checked: false, name: "John Smith" , description: "lorem ipsum 2", color: "#CCFFFF", num: "71230.10" },
|
15
|
+
{ id: 7, checked: false, name: "Ann Martin" , description: "lorem ipsum 1", color: "#CCFFFF", num: "3490.23" },
|
16
|
+
{ id: 8, checked: false, name: "Martin Freeman", description: "lorem ipsum 4", color: "#CCFFFF" , num: "890.1234567890" },
|
17
|
+
{ id: 9, checked: false, name: "Ann Martin" , description: "lorem ipsum 5", color: "#CCFFFF", num: "365", date: new Date().toString() },
|
18
18
|
]
|
19
19
|
)
|
20
20
|
|
@@ -55,7 +55,7 @@ export const TableTest = (prop) => {
|
|
55
55
|
return (
|
56
56
|
<>
|
57
57
|
<div style={{ maxHeight: "20rem", overflow: "auto", margin: "2rem", display: "flex" }}>
|
58
|
-
|
58
|
+
z<DataTable {...table1} onRowSelection={select} outlined multisort={true}/>
|
59
59
|
</div>
|
60
60
|
<div style={{ maxHeight: "20rem", overflow: "auto", margin: "2rem" }}>
|
61
61
|
<DataTable {...table1} onRowSelection={select} onCheckAll={checkAll} />
|
package/src/incubator/task.js
CHANGED
@@ -167,7 +167,6 @@ export const TaskMonitor = (props) => {
|
|
167
167
|
}
|
168
168
|
|
169
169
|
async function remove(task) {
|
170
|
-
console.log("remove", task)
|
171
170
|
await context.removeTask(task)
|
172
171
|
refresh()
|
173
172
|
}
|
@@ -175,30 +174,39 @@ export const TaskMonitor = (props) => {
|
|
175
174
|
const table = {
|
176
175
|
columns: [
|
177
176
|
{ id: "state", label: "Estado" },
|
177
|
+
{ id: "init", label: "Inicio", type: TYPES.STRING, format: FORMATS.DATE},
|
178
|
+
{ id: "end", label: "Fin", type: TYPES.STRING, format: FORMATS.DATE },
|
178
179
|
{ id: "description", label: "Descripcion" },
|
179
180
|
{ id: "progress", label: "%" },
|
180
181
|
{ id: "percentage", label: "" },
|
181
|
-
{ id: "
|
182
|
-
{ id: "
|
183
|
-
{ id: "resourceID", label: "Recurso" },
|
184
|
-
{ id: "owner", label: "Propietario" },
|
182
|
+
// { id: "resourceID", label: "Recurso" },
|
183
|
+
// { id: "owner", label: "Propietario" },
|
185
184
|
{ id: "actions", label: "" }
|
186
185
|
],
|
187
|
-
rows: tasks
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
186
|
+
rows: tasks
|
187
|
+
|
188
|
+
// sort by init date from recent to old
|
189
|
+
.sort((a, b) => {
|
190
|
+
if (a.init > b.init) return -1
|
191
|
+
if (a.init < b.init) return 1
|
192
|
+
return 0
|
193
|
+
})
|
194
|
+
|
195
|
+
.map(task => {
|
196
|
+
return {
|
197
|
+
id: task.id,
|
198
|
+
state: task.state,
|
199
|
+
description: task.description,
|
200
|
+
progress: <LinearProgress progress={task.percentage} />,
|
201
|
+
percentage: task.percentage,
|
202
|
+
init: task.init,
|
203
|
+
end: task.end,
|
204
|
+
resourceID: task.resourceID,
|
205
|
+
owner: task.owner,
|
206
|
+
actions: <Icon size="small" icon="cancel" clickable action={() => remove(task)} />,
|
207
|
+
info: editors && task.result ? <TaskInfo task={task} editors={editors} /> : null
|
208
|
+
}
|
209
|
+
})
|
202
210
|
}
|
203
211
|
|
204
212
|
return (
|