backend-plus 2.0.8 → 2.0.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
package/unlogged/my-ajax.js
CHANGED
|
@@ -522,6 +522,23 @@ function agregar_class_textInDiv(td, className, text){
|
|
|
522
522
|
td.appendChild(div);
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
+
function containsObjectsWithTheSameColumns(o){
|
|
526
|
+
var keys = Object.keys(o);
|
|
527
|
+
if (!keys.length) return false;
|
|
528
|
+
var separator = Math.random();
|
|
529
|
+
var colNamesFirstObject = Object.keys(o[keys[0]]).join(separator);
|
|
530
|
+
return !keys.find(k => o[k] == null || !(o[k] instanceof Object) || Object.keys(o[k]).join(separator) != colNamesFirstObject);
|
|
531
|
+
}
|
|
532
|
+
/* test
|
|
533
|
+
var cases = [
|
|
534
|
+
[false, {}],
|
|
535
|
+
[false, {a:"hola"}],
|
|
536
|
+
[false, {a:{a:1, b:2, c:2}, b:{a:1, x:2, c:2}}],
|
|
537
|
+
[true , {a:{a:1, b:2, c:2}, b:{a:1, b:2, c:2}}]
|
|
538
|
+
];
|
|
539
|
+
cases.forEach(([expected, param]) => console.log(param, containsObjectsWithTheSameColumns(param), containsObjectsWithTheSameColumns(param) == expected ? 'ok' : 'fail'))
|
|
540
|
+
*/
|
|
541
|
+
|
|
525
542
|
/**
|
|
526
543
|
*
|
|
527
544
|
* @param {HTMLElement} div
|
|
@@ -533,7 +550,7 @@ function agregar_json(div, o, ubicaciones=agregar_json_default_ubicaciones){
|
|
|
533
550
|
return ;
|
|
534
551
|
}
|
|
535
552
|
if(typeof o == "object" && !(o instanceof Date) && !o.isRealDateTime){
|
|
536
|
-
if(o instanceof Array && o[0] && o[0] instanceof Object && !(o[0] instanceof Array) && !(o[0].isRealDateTime)){
|
|
553
|
+
if((o instanceof Array && o[0] || containsObjectsWithTheSameColumns(o)) && o[0] instanceof Object && !(o[0] instanceof Array) && !(o[0].isRealDateTime)){
|
|
537
554
|
var table = document.createElement('table');
|
|
538
555
|
div.appendChild(table);
|
|
539
556
|
var titleRow = table.insertRow(-1);
|