@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 CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@saltcorn/server",
3
- "version": "0.9.6-beta.5",
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.5",
11
- "@saltcorn/builder": "0.9.6-beta.5",
12
- "@saltcorn/data": "0.9.6-beta.5",
13
- "@saltcorn/admin-models": "0.9.6-beta.5",
14
- "@saltcorn/filemanager": "0.9.6-beta.5",
15
- "@saltcorn/markup": "0.9.6-beta.5",
16
- "@saltcorn/plugins-loader": "0.9.6-beta.5",
17
- "@saltcorn/sbadmin2": "0.9.6-beta.5",
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 = child_relations.map(
439
- ({ table, key_field, through }) => {
440
- const aggKey =
441
- (through ? `${through.name}->` : "") +
442
- `${table.name}.${key_field.name}`;
443
- aggStatOptions[aggKey] = [
444
- "Count",
445
- "CountUnique",
446
- "Avg",
447
- "Sum",
448
- "Max",
449
- "Min",
450
- "Array_Agg",
451
- ];
452
- table.fields.forEach((f) => {
453
- if (f.type && f.type.name === "Date") {
454
- aggStatOptions[aggKey].push(`Latest ${f.name}`);
455
- aggStatOptions[aggKey].push(`Earliest ${f.name}`);
456
- }
457
- });
458
- return {
459
- name: `agg_field`,
460
- label: req.__("On Field"),
461
- type: "String",
462
- required: true,
463
- attributes: {
464
- options: table.fields
465
- .filter((f) => !f.calculated || f.stored)
466
- .map((f) => ({
467
- label: f.name,
468
- name: `${f.name}@${f.type_name}`,
469
- })),
470
- },
471
- showIf: {
472
- agg_relation: aggKey,
473
- expression_type: "Aggregation",
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"),
package/routes/tables.js CHANGED
@@ -681,6 +681,10 @@ const attribBadges = (f) => {
681
681
  "on_delete_cascade",
682
682
  "on_delete",
683
683
  "unique_error_msg",
684
+ "ref",
685
+ "table",
686
+ "agg_field",
687
+ "agg_relation",
684
688
  ].includes(k)
685
689
  )
686
690
  return;