@saltcorn/server 0.7.2-beta.0 → 0.7.2-beta.4
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/app.js +64 -9
- package/auth/routes.js +37 -13
- package/load_plugins.js +29 -24
- package/locales/da.json +1 -1
- package/locales/de.json +155 -155
- package/locales/en.json +8 -5
- package/locales/it.json +1 -1
- package/locales/ru.json +52 -18
- package/locales/zh.json +3 -3
- package/package.json +11 -8
- package/public/saltcorn-common.js +105 -0
- package/public/saltcorn.css +61 -0
- package/public/saltcorn.js +55 -83
- package/routes/admin.js +1 -1
- package/routes/api.js +36 -1
- package/routes/edit.js +2 -1
- package/routes/fields.js +12 -0
- package/routes/viewedit.js +9 -0
- package/tests/admin.test.js +72 -1
- package/tests/clientjs.test.js +1 -0
- package/tests/viewedit.test.js +94 -0
- package/wrapper.js +1 -0
package/routes/fields.js
CHANGED
|
@@ -181,6 +181,7 @@ const fieldFlow = (req) =>
|
|
|
181
181
|
var attributes = context.attributes || {};
|
|
182
182
|
attributes.default = context.default;
|
|
183
183
|
attributes.summary_field = context.summary_field;
|
|
184
|
+
attributes.include_fts = context.include_fts;
|
|
184
185
|
attributes.on_delete_cascade = context.on_delete_cascade;
|
|
185
186
|
const {
|
|
186
187
|
table_id,
|
|
@@ -370,6 +371,11 @@ const fieldFlow = (req) =>
|
|
|
370
371
|
value: f.name,
|
|
371
372
|
label: f.label,
|
|
372
373
|
}));
|
|
374
|
+
const textfields = orderedFields
|
|
375
|
+
.filter(
|
|
376
|
+
(f) => (!f.calculated || f.stored) && f.type?.sql_name === "text"
|
|
377
|
+
)
|
|
378
|
+
.map((f) => f.name);
|
|
373
379
|
return new Form({
|
|
374
380
|
fields: [
|
|
375
381
|
new Field({
|
|
@@ -378,6 +384,12 @@ const fieldFlow = (req) =>
|
|
|
378
384
|
input_type: "select",
|
|
379
385
|
options: keyfields,
|
|
380
386
|
}),
|
|
387
|
+
new Field({
|
|
388
|
+
name: "include_fts",
|
|
389
|
+
label: req.__("Include in full-text search"),
|
|
390
|
+
type: "Bool",
|
|
391
|
+
showIf: { summary_field: textfields },
|
|
392
|
+
}),
|
|
381
393
|
new Field({
|
|
382
394
|
name: "on_delete_cascade",
|
|
383
395
|
label: req.__("On delete cascade"),
|
package/routes/viewedit.js
CHANGED
package/tests/admin.test.js
CHANGED
|
@@ -12,6 +12,7 @@ const {
|
|
|
12
12
|
respondJsonWith,
|
|
13
13
|
} = require("../auth/testhelp");
|
|
14
14
|
const db = require("@saltcorn/data/db");
|
|
15
|
+
const { sleep } = require("@saltcorn/data/tests/mocks");
|
|
15
16
|
const fs = require("fs").promises;
|
|
16
17
|
const File = require("@saltcorn/data/models/file");
|
|
17
18
|
const User = require("@saltcorn/data/models/user");
|
|
@@ -30,7 +31,12 @@ beforeAll(async () => {
|
|
|
30
31
|
4
|
|
31
32
|
);
|
|
32
33
|
});
|
|
33
|
-
|
|
34
|
+
|
|
35
|
+
afterAll(async () => {
|
|
36
|
+
await sleep(200);
|
|
37
|
+
db.close();
|
|
38
|
+
});
|
|
39
|
+
|
|
34
40
|
const adminPageContains = (specs) =>
|
|
35
41
|
it("adminPageContains " + specs.map((s) => s[1]).join(","), async () => {
|
|
36
42
|
const app = await getApp({ disableCsrf: true });
|
|
@@ -456,6 +462,71 @@ describe("actions", () => {
|
|
|
456
462
|
.expect(toRedirect("/actions/"));
|
|
457
463
|
});
|
|
458
464
|
});
|
|
465
|
+
describe("localizer", () => {
|
|
466
|
+
itShouldRedirectUnauthToLogin("/site-structure/localizer");
|
|
467
|
+
itShouldRedirectUnauthToLogin("/site-structure/localizer/add-lang");
|
|
468
|
+
it("redirects site struct to menu", async () => {
|
|
469
|
+
const app = await getApp({ disableCsrf: true });
|
|
470
|
+
const loginCookie = await getAdminLoginCookie();
|
|
471
|
+
await request(app)
|
|
472
|
+
.get("/site-structure")
|
|
473
|
+
.set("Cookie", loginCookie)
|
|
474
|
+
.expect(toRedirect("/menu"));
|
|
475
|
+
});
|
|
476
|
+
it("shows languages", async () => {
|
|
477
|
+
const app = await getApp({ disableCsrf: true });
|
|
478
|
+
const loginCookie = await getAdminLoginCookie();
|
|
479
|
+
await request(app)
|
|
480
|
+
.get("/site-structure/localizer")
|
|
481
|
+
.set("Cookie", loginCookie)
|
|
482
|
+
.expect(toInclude("Languages"));
|
|
483
|
+
});
|
|
484
|
+
it("shows add language form", async () => {
|
|
485
|
+
const app = await getApp({ disableCsrf: true });
|
|
486
|
+
const loginCookie = await getAdminLoginCookie();
|
|
487
|
+
await request(app)
|
|
488
|
+
.get("/site-structure/localizer/add-lang")
|
|
489
|
+
.set("Cookie", loginCookie)
|
|
490
|
+
.expect(toInclude("Locale identifier short code"));
|
|
491
|
+
});
|
|
492
|
+
it("add language", async () => {
|
|
493
|
+
const app = await getApp({ disableCsrf: true });
|
|
494
|
+
const loginCookie = await getAdminLoginCookie();
|
|
495
|
+
await request(app)
|
|
496
|
+
.post("/site-structure/localizer/save-lang")
|
|
497
|
+
.set("Cookie", loginCookie)
|
|
498
|
+
.send("name=dansk")
|
|
499
|
+
.send("locale=da")
|
|
500
|
+
.expect(toRedirect("/site-structure/localizer/edit/da"));
|
|
501
|
+
});
|
|
502
|
+
it("shows new in languages", async () => {
|
|
503
|
+
const app = await getApp({ disableCsrf: true });
|
|
504
|
+
const loginCookie = await getAdminLoginCookie();
|
|
505
|
+
await request(app)
|
|
506
|
+
.get("/site-structure/localizer")
|
|
507
|
+
.set("Cookie", loginCookie)
|
|
508
|
+
.expect(toInclude("dansk"));
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it("shows edit language form", async () => {
|
|
512
|
+
const app = await getApp({ disableCsrf: true });
|
|
513
|
+
const loginCookie = await getAdminLoginCookie();
|
|
514
|
+
await request(app)
|
|
515
|
+
.get("/site-structure/localizer/edit/da")
|
|
516
|
+
.set("Cookie", loginCookie)
|
|
517
|
+
.expect(toInclude("Hello world"));
|
|
518
|
+
});
|
|
519
|
+
it("set string language", async () => {
|
|
520
|
+
const app = await getApp({ disableCsrf: true });
|
|
521
|
+
const loginCookie = await getAdminLoginCookie();
|
|
522
|
+
await request(app)
|
|
523
|
+
.post("/site-structure/localizer/save-string/da/Hello%20world")
|
|
524
|
+
.set("Cookie", loginCookie)
|
|
525
|
+
.send("value=Hej+verden")
|
|
526
|
+
.expect(toRedirect("/site-structure/localizer/edit/da"));
|
|
527
|
+
});
|
|
528
|
+
});
|
|
529
|
+
|
|
459
530
|
/**
|
|
460
531
|
* Pages tests
|
|
461
532
|
*/
|
package/tests/clientjs.test.js
CHANGED
package/tests/viewedit.test.js
CHANGED
|
@@ -8,6 +8,7 @@ const {
|
|
|
8
8
|
toInclude,
|
|
9
9
|
toNotInclude,
|
|
10
10
|
resetToFixtures,
|
|
11
|
+
succeedJsonWith,
|
|
11
12
|
} = require("../auth/testhelp");
|
|
12
13
|
const db = require("@saltcorn/data/db");
|
|
13
14
|
const View = require("@saltcorn/data/models/view");
|
|
@@ -371,3 +372,96 @@ describe("viewedit new Show", () => {
|
|
|
371
372
|
.expect(toRedirect("/viewedit"));
|
|
372
373
|
});
|
|
373
374
|
});
|
|
375
|
+
describe("Library", () => {
|
|
376
|
+
it("should save new from builder", async () => {
|
|
377
|
+
const loginCookie = await getAdminLoginCookie();
|
|
378
|
+
const app = await getApp({ disableCsrf: true });
|
|
379
|
+
await request(app)
|
|
380
|
+
.post("/library/savefrombuilder/")
|
|
381
|
+
.set("Cookie", loginCookie)
|
|
382
|
+
.send({
|
|
383
|
+
layout: {
|
|
384
|
+
columns: [],
|
|
385
|
+
layout: {
|
|
386
|
+
type: "card",
|
|
387
|
+
contents: {
|
|
388
|
+
above: [
|
|
389
|
+
null,
|
|
390
|
+
{
|
|
391
|
+
besides: [
|
|
392
|
+
{
|
|
393
|
+
above: [
|
|
394
|
+
null,
|
|
395
|
+
{
|
|
396
|
+
type: "blank",
|
|
397
|
+
contents: "Hello world",
|
|
398
|
+
block: false,
|
|
399
|
+
inline: false,
|
|
400
|
+
textStyle: "",
|
|
401
|
+
isFormula: {},
|
|
402
|
+
labelFor: "",
|
|
403
|
+
style: {},
|
|
404
|
+
font: "",
|
|
405
|
+
},
|
|
406
|
+
],
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
above: [
|
|
410
|
+
null,
|
|
411
|
+
{
|
|
412
|
+
type: "blank",
|
|
413
|
+
contents: "Bye bye",
|
|
414
|
+
block: false,
|
|
415
|
+
inline: false,
|
|
416
|
+
textStyle: "",
|
|
417
|
+
isFormula: {},
|
|
418
|
+
labelFor: "",
|
|
419
|
+
style: {},
|
|
420
|
+
font: "",
|
|
421
|
+
},
|
|
422
|
+
],
|
|
423
|
+
},
|
|
424
|
+
],
|
|
425
|
+
breakpoints: ["", ""],
|
|
426
|
+
style: {},
|
|
427
|
+
widths: [6, 6],
|
|
428
|
+
},
|
|
429
|
+
],
|
|
430
|
+
},
|
|
431
|
+
title: "header",
|
|
432
|
+
style: {},
|
|
433
|
+
},
|
|
434
|
+
},
|
|
435
|
+
icon: "far fa-angry",
|
|
436
|
+
name: "ShinyCard",
|
|
437
|
+
})
|
|
438
|
+
.set("Content-Type", "application/json")
|
|
439
|
+
.set("Accept", "application/json")
|
|
440
|
+
.expect(succeedJsonWith(() => true));
|
|
441
|
+
});
|
|
442
|
+
it("shows library with item", async () => {
|
|
443
|
+
const app = await getApp({ disableCsrf: true });
|
|
444
|
+
const loginCookie = await getAdminLoginCookie();
|
|
445
|
+
await request(app)
|
|
446
|
+
.get("/library/list")
|
|
447
|
+
.set("Cookie", loginCookie)
|
|
448
|
+
.expect(toInclude("ShinyCard"));
|
|
449
|
+
});
|
|
450
|
+
it("deletes in library", async () => {
|
|
451
|
+
const app = await getApp({ disableCsrf: true });
|
|
452
|
+
const loginCookie = await getAdminLoginCookie();
|
|
453
|
+
await request(app)
|
|
454
|
+
.post("/library/delete/1")
|
|
455
|
+
.set("Cookie", loginCookie)
|
|
456
|
+
.expect(toRedirect("/library/list"));
|
|
457
|
+
});
|
|
458
|
+
it("shows empty library", async () => {
|
|
459
|
+
const app = await getApp({ disableCsrf: true });
|
|
460
|
+
const loginCookie = await getAdminLoginCookie();
|
|
461
|
+
await request(app)
|
|
462
|
+
.get("/library/list")
|
|
463
|
+
.set("Cookie", loginCookie)
|
|
464
|
+
.expect(toInclude("Library"))
|
|
465
|
+
.expect(toNotInclude("ShinyCard"))
|
|
466
|
+
});
|
|
467
|
+
});
|
package/wrapper.js
CHANGED
|
@@ -167,6 +167,7 @@ const get_headers = (req, version_tag, description, extras = []) => {
|
|
|
167
167
|
headerTag: `<script>var _sc_globalCsrf = "${req.csrfToken()}"; var _sc_version_tag = "${version_tag}";</script>`,
|
|
168
168
|
},
|
|
169
169
|
{ css: `/static_assets/${version_tag}/saltcorn.css` },
|
|
170
|
+
{ script: `/static_assets/${version_tag}/saltcorn-common.js` },
|
|
170
171
|
{ script: `/static_assets/${version_tag}/saltcorn.js` },
|
|
171
172
|
];
|
|
172
173
|
let from_cfg = [];
|