@saltcorn/server 0.9.6-beta.5 → 0.9.6-beta.6
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 +9 -9
- package/routes/fields.js +60 -40
- package/routes/tables.js +4 -0
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/server",
|
|
3
|
-
"version": "0.9.6-beta.
|
|
3
|
+
"version": "0.9.6-beta.6",
|
|
4
4
|
"description": "Server app for Saltcorn, open-source no-code platform",
|
|
5
5
|
"homepage": "https://saltcorn.com",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@aws-sdk/client-s3": "^3.451.0",
|
|
10
|
-
"@saltcorn/base-plugin": "0.9.6-beta.
|
|
11
|
-
"@saltcorn/builder": "0.9.6-beta.
|
|
12
|
-
"@saltcorn/data": "0.9.6-beta.
|
|
13
|
-
"@saltcorn/admin-models": "0.9.6-beta.
|
|
14
|
-
"@saltcorn/filemanager": "0.9.6-beta.
|
|
15
|
-
"@saltcorn/markup": "0.9.6-beta.
|
|
16
|
-
"@saltcorn/plugins-loader": "0.9.6-beta.
|
|
17
|
-
"@saltcorn/sbadmin2": "0.9.6-beta.
|
|
10
|
+
"@saltcorn/base-plugin": "0.9.6-beta.6",
|
|
11
|
+
"@saltcorn/builder": "0.9.6-beta.6",
|
|
12
|
+
"@saltcorn/data": "0.9.6-beta.6",
|
|
13
|
+
"@saltcorn/admin-models": "0.9.6-beta.6",
|
|
14
|
+
"@saltcorn/filemanager": "0.9.6-beta.6",
|
|
15
|
+
"@saltcorn/markup": "0.9.6-beta.6",
|
|
16
|
+
"@saltcorn/plugins-loader": "0.9.6-beta.6",
|
|
17
|
+
"@saltcorn/sbadmin2": "0.9.6-beta.6",
|
|
18
18
|
"@socket.io/cluster-adapter": "^0.2.1",
|
|
19
19
|
"@socket.io/sticky": "^1.0.1",
|
|
20
20
|
"adm-zip": "0.5.10",
|
package/routes/fields.js
CHANGED
|
@@ -255,6 +255,7 @@ const fieldFlow = (req) =>
|
|
|
255
255
|
expression = "__aggregation";
|
|
256
256
|
attributes.agg_relation = context.agg_relation;
|
|
257
257
|
attributes.agg_field = context.agg_field;
|
|
258
|
+
attributes.agg_order_by = context.agg_order_by;
|
|
258
259
|
attributes.aggwhere = context.aggwhere;
|
|
259
260
|
attributes.aggregate = context.aggregate;
|
|
260
261
|
const [table, ref] = context.agg_relation.split(".");
|
|
@@ -435,46 +436,64 @@ const fieldFlow = (req) =>
|
|
|
435
436
|
|
|
436
437
|
const { child_field_list, child_relations } =
|
|
437
438
|
await table.get_child_relations(true);
|
|
438
|
-
const agg_field_opts =
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
|
|
439
|
+
const agg_field_opts = [];
|
|
440
|
+
const agg_order_opts = [];
|
|
441
|
+
child_relations.forEach(({ table, key_field, through }) => {
|
|
442
|
+
const aggKey =
|
|
443
|
+
(through ? `${through.name}->` : "") +
|
|
444
|
+
`${table.name}.${key_field.name}`;
|
|
445
|
+
aggStatOptions[aggKey] = [
|
|
446
|
+
"Count",
|
|
447
|
+
"CountUnique",
|
|
448
|
+
"Avg",
|
|
449
|
+
"Sum",
|
|
450
|
+
"Max",
|
|
451
|
+
"Min",
|
|
452
|
+
"Array_Agg",
|
|
453
|
+
];
|
|
454
|
+
table.fields.forEach((f) => {
|
|
455
|
+
if (f.type && f.type.name === "Date") {
|
|
456
|
+
aggStatOptions[aggKey].push(`Latest ${f.name}`);
|
|
457
|
+
aggStatOptions[aggKey].push(`Earliest ${f.name}`);
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
agg_field_opts.push({
|
|
461
|
+
name: `agg_field`,
|
|
462
|
+
label: req.__("On Field"),
|
|
463
|
+
type: "String",
|
|
464
|
+
required: true,
|
|
465
|
+
attributes: {
|
|
466
|
+
options: table.fields
|
|
467
|
+
.filter((f) => !f.calculated || f.stored)
|
|
468
|
+
.map((f) => ({
|
|
469
|
+
label: f.name,
|
|
470
|
+
name: `${f.name}@${f.type_name}`,
|
|
471
|
+
})),
|
|
472
|
+
},
|
|
473
|
+
showIf: {
|
|
474
|
+
agg_relation: aggKey,
|
|
475
|
+
expression_type: "Aggregation",
|
|
476
|
+
},
|
|
477
|
+
});
|
|
478
|
+
agg_order_opts.push({
|
|
479
|
+
name: `agg_order_by`,
|
|
480
|
+
label: req.__("Order by"),
|
|
481
|
+
type: "String",
|
|
482
|
+
attributes: {
|
|
483
|
+
options: table.fields
|
|
484
|
+
.filter((f) => !f.calculated || f.stored)
|
|
485
|
+
.map((f) => ({
|
|
486
|
+
label: f.name,
|
|
487
|
+
name: f.name,
|
|
488
|
+
})),
|
|
489
|
+
},
|
|
490
|
+
showIf: {
|
|
491
|
+
agg_relation: aggKey,
|
|
492
|
+
expression_type: "Aggregation",
|
|
493
|
+
aggregate: "Array_Agg",
|
|
494
|
+
},
|
|
495
|
+
});
|
|
496
|
+
});
|
|
478
497
|
return new Form({
|
|
479
498
|
fields: [
|
|
480
499
|
{
|
|
@@ -520,6 +539,7 @@ const fieldFlow = (req) =>
|
|
|
520
539
|
required: false,
|
|
521
540
|
showIf: { expression_type: "Aggregation" },
|
|
522
541
|
},
|
|
542
|
+
...agg_order_opts,
|
|
523
543
|
{
|
|
524
544
|
name: "model",
|
|
525
545
|
label: req.__("Model"),
|