@saltcorn/reservable 0.2.0 → 0.2.1
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/index.js +23 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -396,6 +396,8 @@ const run = async (
|
|
|
396
396
|
entity_wanted,
|
|
397
397
|
reservable_entity_key,
|
|
398
398
|
available,
|
|
399
|
+
state,
|
|
400
|
+
table,
|
|
399
401
|
})
|
|
400
402
|
)
|
|
401
403
|
)
|
|
@@ -425,6 +427,8 @@ const reserve_btn = ({
|
|
|
425
427
|
reservable_entity_key,
|
|
426
428
|
entity_wanted,
|
|
427
429
|
available,
|
|
430
|
+
state,
|
|
431
|
+
table,
|
|
428
432
|
}) =>
|
|
429
433
|
available
|
|
430
434
|
? form(
|
|
@@ -438,6 +442,15 @@ const reserve_btn = ({
|
|
|
438
442
|
name: reservable_entity_key,
|
|
439
443
|
value: entity_wanted,
|
|
440
444
|
}),
|
|
445
|
+
table.fields
|
|
446
|
+
.filter((f) => f.name !== reservable_entity_key && state[f.name])
|
|
447
|
+
.map((f) =>
|
|
448
|
+
input({
|
|
449
|
+
type: "hidden",
|
|
450
|
+
name: f.name,
|
|
451
|
+
value: state[f.name],
|
|
452
|
+
})
|
|
453
|
+
),
|
|
441
454
|
input({ type: "hidden", name: "step", value: "getReservationForm" }),
|
|
442
455
|
|
|
443
456
|
button(
|
|
@@ -470,7 +483,11 @@ const getReservationForm = async ({ table, viewname, config, body, req }) => {
|
|
|
470
483
|
const form = await getForm(table, viewname, columns, layout, null, req);
|
|
471
484
|
form.hidden(start_field, duration_field, "step");
|
|
472
485
|
if (reservable_entity_key) form.hidden(reservable_entity_key);
|
|
473
|
-
|
|
486
|
+
table.fields
|
|
487
|
+
.filter((f) => f.name !== reservable_entity_key && body[f.name])
|
|
488
|
+
.forEach((f) => {
|
|
489
|
+
form.hidden(f.name);
|
|
490
|
+
});
|
|
474
491
|
return form;
|
|
475
492
|
};
|
|
476
493
|
const makeReservation = async ({ table, viewname, config, body, req, res }) => {
|
|
@@ -540,7 +557,11 @@ const runPost = async (
|
|
|
540
557
|
[config.reservable_entity_key]: +body[config.reservable_entity_key],
|
|
541
558
|
step: "makeReservation",
|
|
542
559
|
};
|
|
543
|
-
|
|
560
|
+
table.fields
|
|
561
|
+
.filter((f) => f.name !== config.reservable_entity_key && body[f.name])
|
|
562
|
+
.forEach((f) => {
|
|
563
|
+
form.values[f.name] = body[f.name];
|
|
564
|
+
});
|
|
544
565
|
res.sendWrap(viewname, renderForm(form, req.csrfToken()));
|
|
545
566
|
} else if (body.step === "makeReservation") {
|
|
546
567
|
return await makeReservation({
|