backend-plus 2.7.0-beta.11 → 2.7.0-beta.12
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/for-client/my-tables.js +16 -16
- package/lib/backend-plus.js +35 -10
- package/package.json +2 -2
package/for-client/my-tables.js
CHANGED
|
@@ -1740,23 +1740,23 @@ myOwn.dialogDownload = function dialogDownload(grid){
|
|
|
1740
1740
|
var excelExport = function(){
|
|
1741
1741
|
var sheet1name=grid.def.name.length>27?grid.def.name.slice(0,27)+'...':grid.def.name;
|
|
1742
1742
|
var sheet2name=grid.def.name!=="metadata"?"metadata":"meta-data";
|
|
1743
|
-
var
|
|
1744
|
-
|
|
1743
|
+
var dataSheet = {
|
|
1744
|
+
name: sheet1name,
|
|
1745
1745
|
freezeRows: 1,
|
|
1746
1746
|
freezeColumns: grid.def.primaryKey?.length ?? 0,
|
|
1747
1747
|
autoWidthMax: 40,
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1748
|
+
rows: tableRowsXLS(grid.depotsToDisplay, fieldsDef2Export)
|
|
1749
|
+
};
|
|
1750
|
+
var metadataSheet = {
|
|
1751
|
+
name:sheet2name,
|
|
1752
|
+
autoWidthMax: 40,
|
|
1753
|
+
rows: [
|
|
1754
|
+
[],
|
|
1755
|
+
[{v:'table',s:'header'}, grid.def.name],
|
|
1756
|
+
[{v:'date' ,s:'header'}, new Date().toISOString()],
|
|
1757
|
+
[{v:'user' ,s:'header'}, my.config.username],
|
|
1758
|
+
]
|
|
1759
|
+
};
|
|
1760
1760
|
if(grid.def.exportMetadata){
|
|
1761
1761
|
if(grid.def.exportMetadata.fieldProperties){
|
|
1762
1762
|
var fieldPropertiesDefs=grid.def.exportMetadata.fieldProperties.map(function(propName, i){
|
|
@@ -1768,11 +1768,11 @@ myOwn.dialogDownload = function dialogDownload(grid){
|
|
|
1768
1768
|
return {row:fieldDef};
|
|
1769
1769
|
});
|
|
1770
1770
|
extraColumns={};
|
|
1771
|
-
rows
|
|
1771
|
+
metadataSheet.rows.push(...(tableRowsXLS(fieldPropertiesDepot,fieldPropertiesDefs,1)));
|
|
1772
1772
|
}
|
|
1773
1773
|
}
|
|
1774
1774
|
xlsxNowBrowser.createXlsxBlob({
|
|
1775
|
-
|
|
1775
|
+
sheets: [dataSheet, metadataSheet],
|
|
1776
1776
|
styles:XLSX_STYLES
|
|
1777
1777
|
}).then(function(blob){
|
|
1778
1778
|
mainDiv.setAttribute("current-state", "ready");
|
package/lib/backend-plus.js
CHANGED
|
@@ -63,7 +63,37 @@ var myOwn = require('../for-client/my-things.js');
|
|
|
63
63
|
|
|
64
64
|
var typeStore = require('type-store');
|
|
65
65
|
var json4all = require('json4all');
|
|
66
|
-
var
|
|
66
|
+
var xlsxNow = require('xlsx-now/node');
|
|
67
|
+
var xlsxNowCore = require('xlsx-now');
|
|
68
|
+
var Big = require('big.js');
|
|
69
|
+
|
|
70
|
+
// Los tipos que las queries devuelven y no son valores nativos de una celda.
|
|
71
|
+
// Sin esto xlsx-now los rechaza, porque un objeto que nadie reclama no tiene
|
|
72
|
+
// una única forma correcta de escribirse.
|
|
73
|
+
var xlsxTypes = xlsxNowCore.defaultTypes;
|
|
74
|
+
// Un timestamp es una fecha: se escribe como tal y no como texto.
|
|
75
|
+
xlsxTypes = xlsxNowCore.withType(xlsxTypes, bestGlobals.Datetime, {
|
|
76
|
+
convert: (value, context) => xlsxNowCore.dateValue(new Date(value.getTime()), context)
|
|
77
|
+
});
|
|
78
|
+
// Igual que en la exportación del cliente: días, con formato de duración.
|
|
79
|
+
xlsxTypes = xlsxNowCore.withType(xlsxTypes, bestGlobals.TimeInterval, {
|
|
80
|
+
convert: (value) => ({v:value.timeInterval.ms?value.timeInterval.ms/(1000*60*60*24):null, numFmt:'[h]:mm:ss'})
|
|
81
|
+
});
|
|
82
|
+
// decimal y hugeint. Como texto cuando el double ya no los representa exacto,
|
|
83
|
+
// para no devolver un número redondeado con apariencia de exacto.
|
|
84
|
+
xlsxTypes = xlsxNowCore.withType(xlsxTypes, Big, {
|
|
85
|
+
convert: function(value){
|
|
86
|
+
var text = value.toString();
|
|
87
|
+
var asNumber = Number(text);
|
|
88
|
+
return Number.isSafeInteger(asNumber) || String(asNumber) === text
|
|
89
|
+
? {v:asNumber}
|
|
90
|
+
: {v:text, t:'inlineStr'};
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
// jsonb, jsona, gpoint, point y cualquier otro objeto sin tipo propio.
|
|
94
|
+
xlsxTypes = xlsxNowCore.withType(xlsxTypes, Object, {
|
|
95
|
+
convert: (value) => ({v:JSON.stringify(value), t:'inlineStr'})
|
|
96
|
+
});
|
|
67
97
|
|
|
68
98
|
var loginPlus = require('login-plus');
|
|
69
99
|
var dashDashDir=Array.prototype.indexOf.call(process.argv,'--dir')
|
|
@@ -3822,21 +3852,16 @@ AppBackend.prototype.exportacionesGenerico = async function exportacionesGeneric
|
|
|
3822
3852
|
}
|
|
3823
3853
|
if(fileName){
|
|
3824
3854
|
context.informProgress({message:'armando XLSX'})
|
|
3825
|
-
var
|
|
3826
|
-
result.map(({title, rows})=>{
|
|
3855
|
+
var sheets = result.map(({title, rows})=>{
|
|
3827
3856
|
var rowsA = rows.map(row=>Object.values(row));
|
|
3828
3857
|
if(rows[0]){
|
|
3829
|
-
rowsA.unshift(Object.keys(rows[0]));
|
|
3858
|
+
rowsA.unshift({'#line': 'array', values:Object.keys(rows[0]), s: {bold: true}});
|
|
3830
3859
|
}
|
|
3831
|
-
|
|
3832
|
-
XLSX.utils.book_append_sheet(wb, ws, title);
|
|
3833
|
-
return ws;
|
|
3860
|
+
return {name:title, rows:rowsA};
|
|
3834
3861
|
})
|
|
3835
3862
|
context.informProgress({message:`guardando XLSX: ${fileName}`})
|
|
3836
3863
|
await bestGlobals.sleep(100);
|
|
3837
|
-
await
|
|
3838
|
-
(err)=>err?reject(err):resolve()
|
|
3839
|
-
))
|
|
3864
|
+
await xlsxNow.writeXlsxFile(`dist/client/${fileName}`, {sheets, types:xlsxTypes, autoWidthMax:50, freezeRows:1});
|
|
3840
3865
|
}
|
|
3841
3866
|
return [
|
|
3842
3867
|
...(fileName?[{url:fileName, label:csvFileName?'xlsx de control':fileName}]:[]),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "backend-plus",
|
|
3
3
|
"description": "Backend for the anti Pareto rule",
|
|
4
|
-
"version": "2.7.0-beta.
|
|
4
|
+
"version": "2.7.0-beta.12",
|
|
5
5
|
"author": "Codenautas <codenautas@googlegroups.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "codenautas/backend-plus",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"type-store": "^0.6.0",
|
|
77
77
|
"typed-controls": "^0.12.7",
|
|
78
78
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz",
|
|
79
|
-
"xlsx-now": "^0.1
|
|
79
|
+
"xlsx-now": "^0.2.1"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@types/big.js": "^7.0.0",
|