@saltcorn/server 0.7.0-beta.4 → 0.7.1-beta.0

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/locales/en.json CHANGED
@@ -876,5 +876,7 @@
876
876
  "Could not verify code": "Could not verify code",
877
877
  "Disable two-factor authentication": "Disable two-factor authentication",
878
878
  "Enter your two-factor code in order to disable it": "Enter your two-factor code in order to disable it",
879
- "Allow the user to enter a new key that is not in the schema": "Allow the user to enter a new key that is not in the schema"
879
+ "Allow the user to enter a new key that is not in the schema": "Allow the user to enter a new key that is not in the schema",
880
+ "Check for updates": "Check for updates",
881
+ "Versions refreshed": "Versions refreshed"
880
882
  }
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@saltcorn/server",
3
- "version": "0.7.0-beta.4",
3
+ "version": "0.7.1-beta.0",
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
- "@saltcorn/base-plugin": "0.7.0-beta.4",
10
- "@saltcorn/builder": "0.7.0-beta.4",
11
- "@saltcorn/data": "0.7.0-beta.4",
12
- "@saltcorn/admin-models": "0.7.0-beta.4",
13
- "@saltcorn/markup": "0.7.0-beta.4",
14
- "@saltcorn/sbadmin2": "0.7.0-beta.4",
9
+ "@saltcorn/base-plugin": "0.7.1-beta.0",
10
+ "@saltcorn/builder": "0.7.1-beta.0",
11
+ "@saltcorn/data": "0.7.1-beta.0",
12
+ "@saltcorn/admin-models": "0.7.1-beta.0",
13
+ "@saltcorn/markup": "0.7.1-beta.0",
14
+ "@saltcorn/sbadmin2": "0.7.1-beta.0",
15
15
  "@socket.io/cluster-adapter": "^0.1.0",
16
16
  "@socket.io/sticky": "^1.0.1",
17
17
  "aws-sdk": "^2.1037.0",
@@ -767,15 +767,18 @@ async function fill_formula_btn_click(btn, k) {
767
767
  );
768
768
  const rec = get_form_record($(btn), true);
769
769
  const rec_ids = get_form_record($(btn));
770
+
770
771
  for (const fv of free_vars) {
771
772
  if (fv.includes(".")) {
772
773
  const kpath = fv.split(".");
773
774
  const [refNm, targetNm] = kpath;
774
775
  const reffield = table.fields.find((f) => f.name === refNm);
775
- const resp = await $.ajax(
776
- `/api/${reffield.reftable_name}?id=${rec_ids[refNm]}`
777
- );
778
- rec[refNm] = resp.success[0];
776
+ if (reffield && reffield.reftable_name) {
777
+ const resp = await $.ajax(
778
+ `/api/${reffield.reftable_name}?id=${rec_ids[refNm]}`
779
+ );
780
+ rec[refNm] = resp.success[0];
781
+ }
779
782
  }
780
783
  }
781
784
  const val = new Function(
package/routes/admin.js CHANGED
@@ -399,6 +399,15 @@ router.get(
399
399
  ? span(
400
400
  { class: "badge bg-primary ms-2" },
401
401
  req.__("Latest")
402
+ ) +
403
+ post_btn(
404
+ "/admin/check-for-upgrade",
405
+ req.__("Check for updates"),
406
+ req.csrfToken(),
407
+ {
408
+ btnClass: "btn-primary btn-sm px-1 py-0",
409
+ formClass: "d-inline",
410
+ }
402
411
  )
403
412
  : "")
404
413
  )
@@ -499,7 +508,15 @@ router.post(
499
508
  }
500
509
  })
501
510
  );
502
-
511
+ router.post(
512
+ "/check-for-upgrade",
513
+ isAdmin,
514
+ error_catcher(async (req, res) => {
515
+ await getState().deleteConfig("latest_npm_version");
516
+ req.flash("success", req.__(`Versions refreshed`));
517
+ res.redirect(`/admin/system`);
518
+ })
519
+ );
503
520
  /**
504
521
  * @name post/backup
505
522
  * @function
package/routes/fields.js CHANGED
@@ -631,14 +631,19 @@ router.post(
631
631
  if (fieldName.includes(".")) {
632
632
  //join field
633
633
  const kpath = fieldName.split(".");
634
-
635
634
  if (kpath.length === 2 && row[kpath[0]]) {
636
635
  const field = fields.find((f) => f.name === kpath[0]);
637
636
  const reftable = await Table.findOne({ name: field.reftable_name });
638
637
  const targetField = (await reftable.getFields()).find(
639
638
  (f) => f.name === kpath[1]
640
639
  );
641
- const fv = targetField.type.fieldviews[fieldview];
640
+ //console.log({ kpath, fieldview, targetField });
641
+ let fv = targetField.type.fieldviews[fieldview];
642
+ if (!fv) {
643
+ fv =
644
+ targetField.type.fieldviews.show ||
645
+ targetField.type.fieldviews.as_text;
646
+ }
642
647
  const q = { [reftable.pk_name]: row[kpath[0]] };
643
648
  const refRow = await reftable.getRow(q);
644
649
  const configuration = req.query;
@@ -648,6 +653,25 @@ router.post(
648
653
  readState(configuration, configFields);
649
654
  res.send(fv.run(refRow[kpath[1]], req, configuration));
650
655
  return;
656
+ } else if (row[kpath[0]]) {
657
+ let oldTable = table;
658
+ let oldRow = row;
659
+ for (const ref of kpath) {
660
+ const ofields = await oldTable.getFields();
661
+ const field = ofields.find((f) => f.name === ref);
662
+ if (field.is_fkey) {
663
+ const reftable = await Table.findOne({ name: field.reftable_name });
664
+ if (!oldRow[ref]) break;
665
+ const q = { [reftable.pk_name]: oldRow[ref] };
666
+ oldRow = await reftable.getRow(q);
667
+ oldTable = reftable;
668
+ }
669
+ }
670
+ if (oldRow) {
671
+ const value = oldRow[kpath[kpath.length - 1]];
672
+ res.send(value);
673
+ return;
674
+ }
651
675
  }
652
676
  res.send("");
653
677
  return;
@@ -100,8 +100,8 @@ describe("Field Endpoints", () => {
100
100
  await request(app)
101
101
  .post("/field/")
102
102
  .send("stepName=Basic properties")
103
- .send("name=Publisher")
104
- .send("label=Publisher")
103
+ .send("name=Editor")
104
+ .send("label=Editor")
105
105
  .send("type=String")
106
106
  .send("contextEnc=" + ctx)
107
107
  .set("Cookie", loginCookie)
@@ -33,9 +33,9 @@ describe("Table Endpoints", () => {
33
33
  .post("/table/")
34
34
  .send("name=mypostedtable")
35
35
  .set("Cookie", loginCookie)
36
- .expect(toRedirect("/table/6"));
36
+ .expect(toRedirect("/table/7"));
37
37
  await request(app)
38
- .get("/table/6")
38
+ .get("/table/7")
39
39
  .set("Cookie", loginCookie)
40
40
  .expect(toInclude("mypostedtable"));
41
41
  await request(app)
@@ -149,7 +149,7 @@ Pencil, 0.5,2, t`;
149
149
  .set("Cookie", loginCookie)
150
150
  .field("name", "expenses")
151
151
  .attach("file", Buffer.from(csv, "utf-8"))
152
- .expect(toRedirect("/table/7"));
152
+ .expect(toRedirect("/table/8"));
153
153
  });
154
154
  it("should upload csv to existing table", async () => {
155
155
  const csv = `author,Pages