@saltcorn/server 0.9.6-beta.1 → 0.9.6-beta.3
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/public/saltcorn-common.js +47 -8
- package/public/saltcorn.js +8 -2
- package/routes/fields.js +1 -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.3",
|
|
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.3",
|
|
11
|
+
"@saltcorn/builder": "0.9.6-beta.3",
|
|
12
|
+
"@saltcorn/data": "0.9.6-beta.3",
|
|
13
|
+
"@saltcorn/admin-models": "0.9.6-beta.3",
|
|
14
|
+
"@saltcorn/filemanager": "0.9.6-beta.3",
|
|
15
|
+
"@saltcorn/markup": "0.9.6-beta.3",
|
|
16
|
+
"@saltcorn/plugins-loader": "0.9.6-beta.3",
|
|
17
|
+
"@saltcorn/sbadmin2": "0.9.6-beta.3",
|
|
18
18
|
"@socket.io/cluster-adapter": "^0.2.1",
|
|
19
19
|
"@socket.io/sticky": "^1.0.1",
|
|
20
20
|
"adm-zip": "0.5.10",
|
|
@@ -428,7 +428,7 @@ function get_form_record(e_in, select_labels) {
|
|
|
428
428
|
|
|
429
429
|
const e = e_in.viewname
|
|
430
430
|
? $(`form[data-viewname="${e_in.viewname}"]`)
|
|
431
|
-
: e_in.closest(".form-namespace");
|
|
431
|
+
: $(e_in).closest(".form-namespace");
|
|
432
432
|
|
|
433
433
|
const form = $(e).closest("form");
|
|
434
434
|
|
|
@@ -462,6 +462,38 @@ function get_form_record(e_in, select_labels) {
|
|
|
462
462
|
rec[name] = f(rec[name], $this);
|
|
463
463
|
}
|
|
464
464
|
});
|
|
465
|
+
|
|
466
|
+
const joinFieldsStr =
|
|
467
|
+
typeof e_in !== "string" && $(e_in).attr("data-show-if-joinfields");
|
|
468
|
+
if (joinFieldsStr) {
|
|
469
|
+
const joinFields = JSON.parse(decodeURIComponent(joinFieldsStr));
|
|
470
|
+
|
|
471
|
+
const joinVals = $(e_in).prop("data-join-values");
|
|
472
|
+
const kvals = $(e_in).prop("data-join-key-values") || {};
|
|
473
|
+
let differentKeys = false;
|
|
474
|
+
for (const { ref } of joinFields) {
|
|
475
|
+
if (rec[ref] != kvals[ref]) differentKeys = true;
|
|
476
|
+
}
|
|
477
|
+
if (!joinVals || differentKeys) {
|
|
478
|
+
$(e_in).prop("data-join-values", {});
|
|
479
|
+
const keyVals = {};
|
|
480
|
+
for (const { ref, target, refTable } of joinFields) {
|
|
481
|
+
keyVals[ref] = rec[ref];
|
|
482
|
+
$.ajax(`/api/${refTable}?id=${rec[ref]}`, {
|
|
483
|
+
success: (val) => {
|
|
484
|
+
const jvs = $(e_in).prop("data-join-values") || {};
|
|
485
|
+
|
|
486
|
+
jvs[ref] = val.success[0];
|
|
487
|
+
$(e_in).prop("data-join-values", jvs);
|
|
488
|
+
apply_showif();
|
|
489
|
+
},
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
$(e_in).prop("data-join-key-values", keyVals);
|
|
493
|
+
} else if (joinFieldsStr) {
|
|
494
|
+
Object.assign(rec, joinVals);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
465
497
|
return rec;
|
|
466
498
|
}
|
|
467
499
|
function showIfFormulaInputs(e, fml) {
|
|
@@ -1219,7 +1251,13 @@ function restore_old_button(btnId) {
|
|
|
1219
1251
|
btn.removeData("old-text");
|
|
1220
1252
|
}
|
|
1221
1253
|
|
|
1222
|
-
async function common_done(res,
|
|
1254
|
+
async function common_done(res, viewnameOrElem, isWeb = true) {
|
|
1255
|
+
const viewname =
|
|
1256
|
+
typeof viewnameOrElem === "string"
|
|
1257
|
+
? viewnameOrElem
|
|
1258
|
+
: $(viewnameOrElem)
|
|
1259
|
+
.closest("[data-sc-embed-viewname]")
|
|
1260
|
+
.attr("data-sc-embed-viewname");
|
|
1223
1261
|
if (window._sc_loglevel > 4)
|
|
1224
1262
|
console.log("ajax result directives", viewname, res);
|
|
1225
1263
|
const handle = async (element, fn) => {
|
|
@@ -1231,15 +1269,15 @@ async function common_done(res, viewname, isWeb = true) {
|
|
|
1231
1269
|
if (res.row && res.field_names) {
|
|
1232
1270
|
const f = new Function(`viewname, row, {${res.field_names}}`, s);
|
|
1233
1271
|
const evalres = await f(viewname, res.row, res.row);
|
|
1234
|
-
if (evalres) await common_done(evalres,
|
|
1272
|
+
if (evalres) await common_done(evalres, viewnameOrElem, isWeb);
|
|
1235
1273
|
} else if (res.row) {
|
|
1236
1274
|
const f = new Function(`viewname, row`, s);
|
|
1237
1275
|
const evalres = await f(viewname, res.row);
|
|
1238
|
-
if (evalres) await common_done(evalres,
|
|
1276
|
+
if (evalres) await common_done(evalres, viewnameOrElem, isWeb);
|
|
1239
1277
|
} else {
|
|
1240
1278
|
const f = new Function(`viewname`, s);
|
|
1241
1279
|
const evalres = await f(viewname);
|
|
1242
|
-
if (evalres) await common_done(evalres,
|
|
1280
|
+
if (evalres) await common_done(evalres, viewnameOrElem, isWeb);
|
|
1243
1281
|
}
|
|
1244
1282
|
};
|
|
1245
1283
|
if (res.notify) await handle(res.notify, notifyAlert);
|
|
@@ -1252,9 +1290,10 @@ async function common_done(res, viewname, isWeb = true) {
|
|
|
1252
1290
|
notifyAlert({ type: "success", text: text })
|
|
1253
1291
|
);
|
|
1254
1292
|
if (res.set_fields && (viewname || res.set_fields._viewname)) {
|
|
1255
|
-
const form =
|
|
1256
|
-
|
|
1257
|
-
|
|
1293
|
+
const form =
|
|
1294
|
+
typeof viewnameOrElem === "string"
|
|
1295
|
+
? $(`form[data-viewname="${res.set_fields._viewname || viewname}"]`)
|
|
1296
|
+
: $(viewnameOrElem).closest("form[data-viewname]");
|
|
1258
1297
|
if (form.length === 0 && set_state_fields) {
|
|
1259
1298
|
// assume this is a filter
|
|
1260
1299
|
set_state_fields(
|
package/public/saltcorn.js
CHANGED
|
@@ -236,7 +236,13 @@ function reset_spinners() {
|
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
function view_post(
|
|
239
|
+
function view_post(viewnameOrElem, route, data, onDone, sendState) {
|
|
240
|
+
const viewname =
|
|
241
|
+
typeof viewnameOrElem === "string"
|
|
242
|
+
? viewnameOrElem
|
|
243
|
+
: $(viewnameOrElem)
|
|
244
|
+
.closest("[data-sc-embed-viewname]")
|
|
245
|
+
.attr("data-sc-embed-viewname");
|
|
240
246
|
const query = sendState
|
|
241
247
|
? `?${new URL(get_current_state_url()).searchParams.toString()}`
|
|
242
248
|
: "";
|
|
@@ -254,7 +260,7 @@ function view_post(viewname, route, data, onDone, sendState) {
|
|
|
254
260
|
})
|
|
255
261
|
.done(function (res) {
|
|
256
262
|
if (onDone) onDone(res);
|
|
257
|
-
ajax_done(res,
|
|
263
|
+
ajax_done(res, viewnameOrElem);
|
|
258
264
|
reset_spinners();
|
|
259
265
|
})
|
|
260
266
|
.fail(function (res) {
|
package/routes/fields.js
CHANGED
|
@@ -1156,6 +1156,7 @@ router.post(
|
|
|
1156
1156
|
if (!fv) res.send(text(result));
|
|
1157
1157
|
else res.send(fv.run(result, req, { row, ...configuration }));
|
|
1158
1158
|
} catch (e) {
|
|
1159
|
+
console.error("show-calculated error", e);
|
|
1159
1160
|
return res.status(400).send(`Error: ${e.message}`);
|
|
1160
1161
|
}
|
|
1161
1162
|
})
|