View | Details | Raw Unified | Return to bug 39567
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc (+7 lines)
Lines 26-31 Link Here
26
[% Asset.js("lib/jquery/plugins/jquery.validate.min.js") | $raw %]
26
[% Asset.js("lib/jquery/plugins/jquery.validate.min.js") | $raw %]
27
<!-- koha core js -->
27
<!-- koha core js -->
28
[% Asset.js("js/staff-global.js") | $raw %]
28
[% Asset.js("js/staff-global.js") | $raw %]
29
<script type="module">
30
    import { submit_form } from "/intranet-tmpl/prog/js/form-submit.js";
31
    $("body").on("click", ".submit-form-link", function (e) {
32
        e.preventDefault();
33
        submit_form(this);
34
    });
35
</script>
29
[% INCLUDE 'js-date-format.inc' %]
36
[% INCLUDE 'js-date-format.inc' %]
30
[% INCLUDE 'js-patron-get-age.inc' %]
37
[% INCLUDE 'js-patron-get-age.inc' %]
31
[% INCLUDE 'js-patron-format-address.inc' %]
38
[% INCLUDE 'js-patron-format-address.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/form-submit.js (-35 / +31 lines)
Lines 1-38 Link Here
1
$(document).ready(function () {
1
export function submit_form(form) {
2
    $("body").on("click", ".submit-form-link", function (e) {
2
    let form_data = $(form).data();
3
        e.preventDefault();
4
        let form_data = $(this).data();
5
3
6
        let confirm_msg = form_data.confirmationMsg;
4
    let confirm_msg = form_data.confirmationMsg;
7
        if (confirm_msg) {
5
    if (confirm_msg) {
8
            let confirmation = confirm(confirm_msg);
6
        let confirmation = confirm(confirm_msg);
9
            if (!confirmation) {
7
        if (!confirmation) {
10
                return false;
8
            return false;
11
            }
12
            delete form_data.confirmationMsg;
13
        }
9
        }
10
        delete form_data.confirmationMsg;
11
    }
14
12
15
        let the_form = $("<form/>");
13
    let the_form = $("<form/>");
16
        if (form_data.method === "post") {
14
    if (form_data.method === "post") {
17
            form_data.csrf_token = $('meta[name="csrf-token"]').attr("content");
15
        form_data.csrf_token = $('meta[name="csrf-token"]').attr("content");
18
        }
16
    }
19
        the_form.attr("method", form_data.method);
17
    the_form.attr("method", form_data.method);
20
        the_form.attr("action", form_data.action);
18
    the_form.attr("action", form_data.action);
21
        delete form_data.method;
19
    delete form_data.method;
22
        delete form_data.action;
20
    delete form_data.action;
23
        $.each(form_data, function (key, value) {
21
    $.each(form_data, function (key, value) {
24
            the_form.append(
22
        the_form.append(
25
                $("<input/>", {
23
            $("<input/>", {
26
                    type: "hidden",
24
                type: "hidden",
27
                    name: key,
25
                name: key,
28
                    value: value,
26
                value: value,
29
                })
27
            })
30
            );
28
        );
31
        });
32
        if (form_data.new_tab) {
33
            the_form.attr("target", "_blank");
34
        }
35
        $("body").append(the_form);
36
        the_form.submit();
37
    });
29
    });
38
});
30
    if (form_data.new_tab) {
31
        the_form.attr("target", "_blank");
32
    }
33
    $("body").append(the_form);
34
    the_form.submit();
35
}
39
- 

Return to bug 39567