@saltcorn/server 0.6.3 → 0.6.4-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 +3 -1
- package/auth/resetpw.js +7 -7
- package/auth/routes.js +1 -1
- package/locales/en.json +9 -1
- package/package.json +17 -14
- package/public/gridedit.js +162 -221
- package/public/saltcorn.js +107 -12
- package/public/tabulator.min.js +3 -0
- package/public/tabulator_bootstrap4.min.css +2 -0
- package/restart_watcher.js +1 -1
- package/routes/admin.js +9 -3
- package/routes/api.js +10 -5
- package/routes/fields.js +31 -2
- package/routes/files.js +2 -1
- package/routes/homepage.js +1 -1
- package/routes/list.js +167 -89
- package/routes/packs.js +1 -1
- package/routes/pageedit.js +1 -1
- package/routes/plugins.js +3 -1
- package/routes/scapi.js +1 -1
- package/routes/tables.js +3 -1
- package/routes/tenant.js +19 -9
- package/routes/view.js +2 -0
- package/routes/viewedit.js +1 -1
- package/serve.js +38 -27
- package/wrapper.js +5 -2
package/public/saltcorn.js
CHANGED
|
@@ -177,6 +177,14 @@ function rep_down(e) {
|
|
|
177
177
|
apply_form_subset_record(theform, vals1);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
+
|
|
181
|
+
function reload_on_init() {
|
|
182
|
+
localStorage.setItem("reload_on_init", true);
|
|
183
|
+
}
|
|
184
|
+
if (localStorage.getItem("reload_on_init")) {
|
|
185
|
+
localStorage.removeItem("reload_on_init");
|
|
186
|
+
location.reload();
|
|
187
|
+
}
|
|
180
188
|
function initialize_page() {
|
|
181
189
|
$("form").change(apply_showif);
|
|
182
190
|
apply_showif();
|
|
@@ -228,13 +236,15 @@ function initialize_page() {
|
|
|
228
236
|
});
|
|
229
237
|
if (codes.length > 0)
|
|
230
238
|
enable_codemirror(() => {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
239
|
+
setTimeout(() => {
|
|
240
|
+
codes.forEach((el) => {
|
|
241
|
+
//console.log($(el).attr("mode"), el);
|
|
242
|
+
CodeMirror.fromTextArea(el, {
|
|
243
|
+
lineNumbers: true,
|
|
244
|
+
mode: $(el).attr("mode"),
|
|
245
|
+
});
|
|
236
246
|
});
|
|
237
|
-
});
|
|
247
|
+
}, 100);
|
|
238
248
|
});
|
|
239
249
|
const locale =
|
|
240
250
|
navigator.userLanguage ||
|
|
@@ -245,6 +255,7 @@ function initialize_page() {
|
|
|
245
255
|
navigator.browserLanguage ||
|
|
246
256
|
navigator.systemLanguage ||
|
|
247
257
|
"en";
|
|
258
|
+
window.detected_locale = locale;
|
|
248
259
|
const parse = (s) => JSON.parse(decodeURIComponent(s));
|
|
249
260
|
$("time[locale-time-options]").each(function () {
|
|
250
261
|
var el = $(this);
|
|
@@ -264,6 +275,7 @@ function initialize_page() {
|
|
|
264
275
|
const options = parse(el.attr("locale-date-options"));
|
|
265
276
|
el.text(date.toLocaleDateString(locale, options));
|
|
266
277
|
});
|
|
278
|
+
$('a[data-toggle="tab"]').historyTabs();
|
|
267
279
|
}
|
|
268
280
|
|
|
269
281
|
$(initialize_page);
|
|
@@ -482,7 +494,7 @@ function press_store_button(clicked) {
|
|
|
482
494
|
|
|
483
495
|
function ajax_modal(url, opts = {}) {
|
|
484
496
|
if ($("#scmodal").length === 0) {
|
|
485
|
-
$("body").append(`<div id="scmodal", class="modal"
|
|
497
|
+
$("body").append(`<div id="scmodal", class="modal">
|
|
486
498
|
<div class="modal-dialog">
|
|
487
499
|
<div class="modal-content">
|
|
488
500
|
<div class="modal-header">
|
|
@@ -506,6 +518,7 @@ function ajax_modal(url, opts = {}) {
|
|
|
506
518
|
if (title) $("#scmodal .modal-title").html(decodeURIComponent(title));
|
|
507
519
|
$("#scmodal .modal-body").html(res);
|
|
508
520
|
$("#scmodal").modal();
|
|
521
|
+
initialize_page();
|
|
509
522
|
(opts.onOpen || function () {})(res);
|
|
510
523
|
$("#scmodal").on("hidden.bs.modal", function (e) {
|
|
511
524
|
(opts.onClose || function () {})(res);
|
|
@@ -514,7 +527,7 @@ function ajax_modal(url, opts = {}) {
|
|
|
514
527
|
});
|
|
515
528
|
}
|
|
516
529
|
|
|
517
|
-
function saveAndContinue(e) {
|
|
530
|
+
function saveAndContinue(e, k) {
|
|
518
531
|
var form = $(e).closest("form");
|
|
519
532
|
var url = form.attr("action");
|
|
520
533
|
var form_data = form.serialize();
|
|
@@ -535,6 +548,9 @@ function saveAndContinue(e) {
|
|
|
535
548
|
$("#page-inner-content").html(request.responseText);
|
|
536
549
|
initialize_page();
|
|
537
550
|
},
|
|
551
|
+
complete: function () {
|
|
552
|
+
if (k) k();
|
|
553
|
+
},
|
|
538
554
|
});
|
|
539
555
|
|
|
540
556
|
return false;
|
|
@@ -604,7 +620,41 @@ function ajax_post_btn(e, reload_on_done, reload_delay) {
|
|
|
604
620
|
|
|
605
621
|
return false;
|
|
606
622
|
}
|
|
607
|
-
|
|
623
|
+
function make_unique_field(
|
|
624
|
+
id,
|
|
625
|
+
table_id,
|
|
626
|
+
field_name,
|
|
627
|
+
value,
|
|
628
|
+
space,
|
|
629
|
+
start,
|
|
630
|
+
always_append
|
|
631
|
+
) {
|
|
632
|
+
if (!value) return;
|
|
633
|
+
$.ajax(
|
|
634
|
+
`/api/${table_id}?approximate=true&${encodeURIComponent(
|
|
635
|
+
field_name
|
|
636
|
+
)}=${encodeURIComponent(value)}&fields=${encodeURIComponent(field_name)}`,
|
|
637
|
+
{
|
|
638
|
+
type: "GET",
|
|
639
|
+
success: function (res) {
|
|
640
|
+
if (res.success) {
|
|
641
|
+
const vals = res.success
|
|
642
|
+
.map((o) => o[field_name])
|
|
643
|
+
.filter((s) => s.startsWith(value));
|
|
644
|
+
if (vals.includes(value) || always_append) {
|
|
645
|
+
for (let i = start || 0; i < vals.length + (start || 0) + 2; i++) {
|
|
646
|
+
const newname = `${value}${space ? " " : ""}${i}`;
|
|
647
|
+
if (!vals.includes(newname)) {
|
|
648
|
+
$("#" + id).val(newname);
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
},
|
|
655
|
+
}
|
|
656
|
+
);
|
|
657
|
+
}
|
|
608
658
|
function test_formula(tablename, stored) {
|
|
609
659
|
var formula = $("input[name=expression]").val();
|
|
610
660
|
ajax_post(`/field/test-formula`, {
|
|
@@ -670,6 +720,51 @@ function room_older(viewname, room_id, btn) {
|
|
|
670
720
|
}
|
|
671
721
|
);
|
|
672
722
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
723
|
+
|
|
724
|
+
/*
|
|
725
|
+
https://github.com/jeffdavidgreen/bootstrap-html5-history-tabs/blob/master/bootstrap-history-tabs.js
|
|
726
|
+
Copyright (c) 2015 Jeff Green
|
|
727
|
+
*/
|
|
728
|
+
|
|
729
|
+
+(function ($) {
|
|
730
|
+
"use strict";
|
|
731
|
+
$.fn.historyTabs = function () {
|
|
732
|
+
var that = this;
|
|
733
|
+
window.addEventListener("popstate", function (event) {
|
|
734
|
+
if (event.state) {
|
|
735
|
+
$(that)
|
|
736
|
+
.filter('[href="' + event.state.url + '"]')
|
|
737
|
+
.tab("show");
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
return this.each(function (index, element) {
|
|
741
|
+
$(element).on("show.bs.tab", function () {
|
|
742
|
+
var stateObject = { url: $(this).attr("href") };
|
|
743
|
+
|
|
744
|
+
if (window.location.hash && stateObject.url !== window.location.hash) {
|
|
745
|
+
window.history.pushState(
|
|
746
|
+
stateObject,
|
|
747
|
+
document.title,
|
|
748
|
+
window.location.pathname +
|
|
749
|
+
window.location.search +
|
|
750
|
+
$(this).attr("href")
|
|
751
|
+
);
|
|
752
|
+
} else {
|
|
753
|
+
window.history.replaceState(
|
|
754
|
+
stateObject,
|
|
755
|
+
document.title,
|
|
756
|
+
window.location.pathname +
|
|
757
|
+
window.location.search +
|
|
758
|
+
$(this).attr("href")
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
if (!window.location.hash && $(element).is(".active")) {
|
|
763
|
+
// Shows the first element if there are no query parameters.
|
|
764
|
+
$(element).tab("show");
|
|
765
|
+
} else if ($(this).attr("href") === window.location.hash) {
|
|
766
|
+
$(element).tab("show");
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
};
|
|
770
|
+
})(jQuery);
|