@saltcorn/server 0.9.4-beta.18 → 0.9.4-beta.19

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.
Files changed (153) hide show
  1. package/locales/en.json +3 -1
  2. package/package.json +8 -8
  3. package/public/dayjslocales/af.js +1 -0
  4. package/public/dayjslocales/am.js +1 -0
  5. package/public/dayjslocales/ar-dz.js +1 -0
  6. package/public/dayjslocales/ar-iq.js +1 -0
  7. package/public/dayjslocales/ar-kw.js +1 -0
  8. package/public/dayjslocales/ar-ly.js +1 -0
  9. package/public/dayjslocales/ar-ma.js +1 -0
  10. package/public/dayjslocales/ar-sa.js +1 -0
  11. package/public/dayjslocales/ar-tn.js +1 -0
  12. package/public/dayjslocales/ar.js +1 -0
  13. package/public/dayjslocales/az.js +1 -0
  14. package/public/dayjslocales/be.js +1 -0
  15. package/public/dayjslocales/bg.js +1 -0
  16. package/public/dayjslocales/bi.js +1 -0
  17. package/public/dayjslocales/bm.js +1 -0
  18. package/public/dayjslocales/bn-bd.js +1 -0
  19. package/public/dayjslocales/bn.js +1 -0
  20. package/public/dayjslocales/bo.js +1 -0
  21. package/public/dayjslocales/br.js +1 -0
  22. package/public/dayjslocales/bs.js +1 -0
  23. package/public/dayjslocales/ca.js +1 -0
  24. package/public/dayjslocales/cs.js +1 -0
  25. package/public/dayjslocales/cv.js +1 -0
  26. package/public/dayjslocales/cy.js +1 -0
  27. package/public/dayjslocales/da.js +1 -0
  28. package/public/dayjslocales/de-at.js +1 -0
  29. package/public/dayjslocales/de-ch.js +1 -0
  30. package/public/dayjslocales/de.js +1 -0
  31. package/public/dayjslocales/dv.js +1 -0
  32. package/public/dayjslocales/el.js +1 -0
  33. package/public/dayjslocales/en-au.js +1 -0
  34. package/public/dayjslocales/en-ca.js +1 -0
  35. package/public/dayjslocales/en-gb.js +1 -0
  36. package/public/dayjslocales/en-ie.js +1 -0
  37. package/public/dayjslocales/en-il.js +1 -0
  38. package/public/dayjslocales/en-in.js +1 -0
  39. package/public/dayjslocales/en-nz.js +1 -0
  40. package/public/dayjslocales/en-sg.js +1 -0
  41. package/public/dayjslocales/en-tt.js +1 -0
  42. package/public/dayjslocales/en.js +1 -0
  43. package/public/dayjslocales/eo.js +1 -0
  44. package/public/dayjslocales/es-do.js +1 -0
  45. package/public/dayjslocales/es-mx.js +1 -0
  46. package/public/dayjslocales/es-pr.js +1 -0
  47. package/public/dayjslocales/es-us.js +1 -0
  48. package/public/dayjslocales/es.js +1 -0
  49. package/public/dayjslocales/et.js +1 -0
  50. package/public/dayjslocales/eu.js +1 -0
  51. package/public/dayjslocales/fa.js +1 -0
  52. package/public/dayjslocales/fi.js +1 -0
  53. package/public/dayjslocales/fo.js +1 -0
  54. package/public/dayjslocales/fr-ca.js +1 -0
  55. package/public/dayjslocales/fr-ch.js +1 -0
  56. package/public/dayjslocales/fr.js +1 -0
  57. package/public/dayjslocales/fy.js +1 -0
  58. package/public/dayjslocales/ga.js +1 -0
  59. package/public/dayjslocales/gd.js +1 -0
  60. package/public/dayjslocales/gl.js +1 -0
  61. package/public/dayjslocales/gom-latn.js +1 -0
  62. package/public/dayjslocales/gu.js +1 -0
  63. package/public/dayjslocales/he.js +1 -0
  64. package/public/dayjslocales/hi.js +1 -0
  65. package/public/dayjslocales/hr.js +1 -0
  66. package/public/dayjslocales/ht.js +1 -0
  67. package/public/dayjslocales/hu.js +1 -0
  68. package/public/dayjslocales/hy-am.js +1 -0
  69. package/public/dayjslocales/id.js +1 -0
  70. package/public/dayjslocales/is.js +1 -0
  71. package/public/dayjslocales/it-ch.js +1 -0
  72. package/public/dayjslocales/it.js +1 -0
  73. package/public/dayjslocales/ja.js +1 -0
  74. package/public/dayjslocales/jv.js +1 -0
  75. package/public/dayjslocales/ka.js +1 -0
  76. package/public/dayjslocales/kk.js +1 -0
  77. package/public/dayjslocales/km.js +1 -0
  78. package/public/dayjslocales/kn.js +1 -0
  79. package/public/dayjslocales/ko.js +1 -0
  80. package/public/dayjslocales/ku.js +1 -0
  81. package/public/dayjslocales/ky.js +1 -0
  82. package/public/dayjslocales/lb.js +1 -0
  83. package/public/dayjslocales/lo.js +1 -0
  84. package/public/dayjslocales/lt.js +1 -0
  85. package/public/dayjslocales/lv.js +1 -0
  86. package/public/dayjslocales/me.js +1 -0
  87. package/public/dayjslocales/mi.js +1 -0
  88. package/public/dayjslocales/mk.js +1 -0
  89. package/public/dayjslocales/ml.js +1 -0
  90. package/public/dayjslocales/mn.js +1 -0
  91. package/public/dayjslocales/mr.js +1 -0
  92. package/public/dayjslocales/ms-my.js +1 -0
  93. package/public/dayjslocales/ms.js +1 -0
  94. package/public/dayjslocales/mt.js +1 -0
  95. package/public/dayjslocales/my.js +1 -0
  96. package/public/dayjslocales/nb.js +1 -0
  97. package/public/dayjslocales/ne.js +1 -0
  98. package/public/dayjslocales/nl-be.js +1 -0
  99. package/public/dayjslocales/nl.js +1 -0
  100. package/public/dayjslocales/nn.js +1 -0
  101. package/public/dayjslocales/oc-lnc.js +1 -0
  102. package/public/dayjslocales/pa-in.js +1 -0
  103. package/public/dayjslocales/pl.js +1 -0
  104. package/public/dayjslocales/pt-br.js +1 -0
  105. package/public/dayjslocales/pt.js +1 -0
  106. package/public/dayjslocales/rn.js +1 -0
  107. package/public/dayjslocales/ro.js +1 -0
  108. package/public/dayjslocales/ru.js +1 -0
  109. package/public/dayjslocales/rw.js +1 -0
  110. package/public/dayjslocales/sd.js +1 -0
  111. package/public/dayjslocales/se.js +1 -0
  112. package/public/dayjslocales/si.js +1 -0
  113. package/public/dayjslocales/sk.js +1 -0
  114. package/public/dayjslocales/sl.js +1 -0
  115. package/public/dayjslocales/sq.js +1 -0
  116. package/public/dayjslocales/sr-cyrl.js +1 -0
  117. package/public/dayjslocales/sr.js +1 -0
  118. package/public/dayjslocales/ss.js +1 -0
  119. package/public/dayjslocales/sv-fi.js +1 -0
  120. package/public/dayjslocales/sv.js +1 -0
  121. package/public/dayjslocales/sw.js +1 -0
  122. package/public/dayjslocales/ta.js +1 -0
  123. package/public/dayjslocales/te.js +1 -0
  124. package/public/dayjslocales/tet.js +1 -0
  125. package/public/dayjslocales/tg.js +1 -0
  126. package/public/dayjslocales/th.js +1 -0
  127. package/public/dayjslocales/tk.js +1 -0
  128. package/public/dayjslocales/tl-ph.js +1 -0
  129. package/public/dayjslocales/tlh.js +1 -0
  130. package/public/dayjslocales/tr.js +1 -0
  131. package/public/dayjslocales/tzl.js +1 -0
  132. package/public/dayjslocales/tzm-latn.js +1 -0
  133. package/public/dayjslocales/tzm.js +1 -0
  134. package/public/dayjslocales/ug-cn.js +1 -0
  135. package/public/dayjslocales/uk.js +1 -0
  136. package/public/dayjslocales/ur.js +1 -0
  137. package/public/dayjslocales/uz-latn.js +1 -0
  138. package/public/dayjslocales/uz.js +1 -0
  139. package/public/dayjslocales/vi.js +1 -0
  140. package/public/dayjslocales/x-pseudo.js +1 -0
  141. package/public/dayjslocales/yo.js +1 -0
  142. package/public/dayjslocales/zh-cn.js +1 -0
  143. package/public/dayjslocales/zh-hk.js +1 -0
  144. package/public/dayjslocales/zh-tw.js +1 -0
  145. package/public/dayjslocales/zh.js +1 -0
  146. package/public/gridedit.js +2 -2
  147. package/public/saltcorn-common.js +1 -0
  148. package/routes/actions.js +44 -1
  149. package/routes/admin.js +7 -1
  150. package/routes/common_lists.js +37 -15
  151. package/routes/list.js +1 -1
  152. package/routes/tags.js +4 -0
  153. package/wrapper.js +9 -1
package/routes/actions.js CHANGED
@@ -219,6 +219,17 @@ const triggerForm = async (req, trigger) => {
219
219
  "The table for which the trigger condition is checked."
220
220
  ),
221
221
  },
222
+ {
223
+ name: "table_id",
224
+ label: req.__("Table"),
225
+ input_type: "select",
226
+ options: [
227
+ { value: "", label: "Table not set" },
228
+ ...tables.map((t) => ({ value: t.id, label: t.name })),
229
+ ],
230
+ showIf: { when_trigger: "Never" },
231
+ sublabel: req.__("Optionally associate a table with this trigger"),
232
+ },
222
233
  {
223
234
  name: "channel",
224
235
  label: req.__("Time of day"),
@@ -242,9 +253,41 @@ const triggerForm = async (req, trigger) => {
242
253
  attributes: {
243
254
  calcOptions: ["when_trigger", action_options],
244
255
  },
256
+ showIf: {
257
+ when_trigger: Trigger.when_options.filter((t) => t !== "Never"),
258
+ },
259
+ sublabel: req.__("The action to be taken when the trigger fires"),
260
+ },
261
+ {
262
+ name: "action",
263
+ label: req.__("Action"),
264
+ type: "String",
265
+ required: true,
266
+ help: { topic: "Actions" },
267
+ attributes: {
268
+ options: actionsNotRequiringRow,
269
+ },
270
+ showIf: {
271
+ when_trigger: "Never",
272
+ table_id: "",
273
+ },
274
+ sublabel: req.__("The action to be taken when the trigger fires"),
275
+ },
276
+ {
277
+ name: "action",
278
+ label: req.__("Action"),
279
+ type: "String",
280
+ required: true,
281
+ help: { topic: "Actions" },
282
+ attributes: {
283
+ options: allActions,
284
+ },
285
+ showIf: {
286
+ when_trigger: "Never",
287
+ table_id: tables.map((t) => t.id),
288
+ },
245
289
  sublabel: req.__("The action to be taken when the trigger fires"),
246
290
  },
247
-
248
291
  {
249
292
  name: "description",
250
293
  label: req.__("Description"),
package/routes/admin.js CHANGED
@@ -600,7 +600,13 @@ router.post(
600
600
  snap.created
601
601
  ).fromNow()}`
602
602
  );
603
- res.redirect(/^[a-z]+$/g.test(type) ? `/${type}edit` : "/");
603
+ res.redirect(
604
+ type === "trigger"
605
+ ? `/actions`
606
+ : /^[a-z]+$/g.test(type)
607
+ ? `/${type}edit`
608
+ : "/"
609
+ );
604
610
  })
605
611
  );
606
612
 
@@ -583,6 +583,34 @@ const getPageGroupList = (rows, roles, req) => {
583
583
  );
584
584
  };
585
585
 
586
+ const trigger_dropdown = (trigger, req, on_done_redirect_str = "") =>
587
+ settingsDropdown(`dropdownMenuButton${trigger.id}`, [
588
+ a(
589
+ {
590
+ class: "dropdown-item",
591
+ href: `/actions/edit/${trigger.id}${on_done_redirect_str}`,
592
+ },
593
+ '<i class="fas fa-edit"></i>&nbsp;' + req.__("Edit")
594
+ ),
595
+
596
+ a(
597
+ {
598
+ class: "dropdown-item",
599
+ href: `javascript:ajax_modal('/admin/snapshot-restore/trigger/${trigger.name}')`,
600
+ },
601
+ '<i class="fas fa-undo-alt"></i>&nbsp;' + req.__("Restore")
602
+ ),
603
+ div({ class: "dropdown-divider" }),
604
+
605
+ post_dropdown_item(
606
+ `/actions/delete/${trigger.id}${on_done_redirect_str}`,
607
+ '<i class="far fa-trash-alt"></i>&nbsp;' + req.__("Delete"),
608
+ req,
609
+ true,
610
+ trigger.name
611
+ ),
612
+ ]);
613
+
586
614
  const getTriggerList = async (
587
615
  triggers,
588
616
  req,
@@ -618,13 +646,7 @@ const getTriggerList = async (
618
646
  },
619
647
  ]),
620
648
  { label: req.__("Action"), key: "action" },
621
- {
622
- label: req.__("Table or Channel"),
623
- key: (r) =>
624
- r.table_name
625
- ? a({ href: `/table/${r.table_name}` }, r.table_name)
626
- : r.channel,
627
- },
649
+
628
650
  {
629
651
  label: req.__("When"),
630
652
  key: (act) =>
@@ -639,15 +661,15 @@ const getTriggerList = async (
639
661
  : ""),
640
662
  },
641
663
  {
642
- label: req.__("Test run"),
664
+ label: req.__("Table or Channel"),
643
665
  key: (r) =>
644
- r.table_id
645
- ? ""
646
- : link(`/actions/testrun/${r.id}`, req.__("Test run")),
666
+ r.table_name
667
+ ? a({ href: `/table/${r.table_name}` }, r.table_name)
668
+ : r.channel,
647
669
  },
648
670
  {
649
- label: req.__("Edit"),
650
- key: (r) => link(`/actions/edit/${r.id}`, req.__("Edit")),
671
+ label: req.__("Test run"),
672
+ key: (r) => link(`/actions/testrun/${r.id}`, req.__("Test run")),
651
673
  },
652
674
  {
653
675
  label: req.__("Configure"),
@@ -655,8 +677,8 @@ const getTriggerList = async (
655
677
  },
656
678
  !tagId
657
679
  ? {
658
- label: req.__("Delete"),
659
- key: (r) => post_delete_btn(`/actions/delete/${r.id}`, req),
680
+ label: "",
681
+ key: (r) => trigger_dropdown(r, req),
660
682
  }
661
683
  : {
662
684
  label: req.__("Remove From Tag"),
package/routes/list.js CHANGED
@@ -288,7 +288,7 @@ router.get(
288
288
  },
289
289
  //css for jsgrid - grid editor external component
290
290
  {
291
- css: `/static_assets/${db.connectObj.version_tag}/tabulator_bootstrap5.min.css`,
291
+ css: `/static_assets/${db.connectObj.version_tag}/tabulator_bootstrap4.min.css`,
292
292
  },
293
293
 
294
294
  // css for date flat picker external component
package/routes/tags.js CHANGED
@@ -27,6 +27,7 @@ const {
27
27
  const db = require("@saltcorn/data/db");
28
28
  const { getState } = require("@saltcorn/data/db/state");
29
29
  const { create_pack_from_tag } = require("@saltcorn/admin-models/models/pack");
30
+ const Table = require("@saltcorn/data/models/table");
30
31
 
31
32
  const router = new Router();
32
33
  module.exports = router;
@@ -161,6 +162,9 @@ router.get(
161
162
  await setTableRefs(views);
162
163
  const pages = await tag.getPages();
163
164
  const triggers = await tag.getTriggers();
165
+ triggers.forEach((tr) => {
166
+ if (tr.table_id) tr.table_name = Table.findOne(tr.table_id)?.name;
167
+ });
164
168
  const roles = await User.get_roles();
165
169
 
166
170
  const tablesDomId = "tablesListId";
package/wrapper.js CHANGED
@@ -185,17 +185,25 @@ const get_headers = (req, version_tag, description, extras = []) => {
185
185
  },
186
186
  ]
187
187
  : [];
188
+ const locale = req.getLocale();
188
189
  const stdHeaders = [
189
190
  {
190
191
  headerTag: `<script>var _sc_loglevel = ${
191
192
  state.logLevel
192
- }, _sc_globalCsrf = "${req.csrfToken()}", _sc_version_tag = "${version_tag}";</script>`,
193
+ }, _sc_globalCsrf = "${req.csrfToken()}", _sc_version_tag = "${version_tag}"${
194
+ locale ? `, _sc_locale = "${locale}"` : ""
195
+ };</script>`,
193
196
  },
194
197
  { css: `/static_assets/${version_tag}/saltcorn.css` },
195
198
  { script: `/static_assets/${version_tag}/saltcorn-common.js` },
196
199
  { script: `/static_assets/${version_tag}/saltcorn.js` },
197
200
  { script: `/static_assets/${version_tag}/dayjs.min.js` },
198
201
  ];
202
+ if (locale !== "en") {
203
+ stdHeaders.push({
204
+ script: `/static_assets/${version_tag}/dayjslocales/${locale}.js`,
205
+ });
206
+ }
199
207
  let from_cfg = [];
200
208
  if (state.getConfig("page_custom_css", ""))
201
209
  from_cfg.push({ style: state.getConfig("page_custom_css", "") });