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 lines)
Line 0 Link Here
1
export function submit_form(form) {
2
    let form_data = $(form).data();
3
4
    let confirm_msg = form_data.confirmationMsg;
5
    if (confirm_msg) {
6
        let confirmation = confirm(confirm_msg);
7
        if (!confirmation) {
8
            return false;
9
        }
10
        delete form_data.confirmationMsg;
11
    }
12
13
    let the_form = $("<form/>");
14
    if (form_data.method === "post") {
15
        form_data.csrf_token = $('meta[name="csrf-token"]').attr("content");
16
    }
17
    the_form.attr("method", form_data.method);
18
    the_form.attr("action", form_data.action);
19
    delete form_data.method;
20
    delete form_data.action;
21
    $.each(form_data, function (key, value) {
22
        the_form.append(
23
            $("<input/>", {
24
                type: "hidden",
25
                name: key,
26
                value: value,
27
            })
28
        );
29
    });
30
    if (form_data.new_tab) {
31
        the_form.attr("target", "_blank");
32
    }
33
    $("body").append(the_form);
34
    the_form.submit();
35
}
(-)a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js (-39 lines)
Lines 99-142 $(document).ready(function () { Link Here
99
        }
99
        }
100
    );
100
    );
101
101
102
    // form-submit js
103
    $("body").on("click", ".submit-form-link", function (e) {
104
        e.preventDefault();
105
        let form_data = $(this).data();
106
107
        let confirm_msg = form_data.confirmationMsg;
108
        if (confirm_msg) {
109
            let confirmation = confirm(confirm_msg);
110
            if (!confirmation) {
111
                return false;
112
            }
113
            delete form_data.confirmationMsg;
114
        }
115
116
        let the_form = $("<form/>");
117
        if (form_data.method === "post") {
118
            form_data.csrf_token = $('meta[name="csrf-token"]').attr("content");
119
        }
120
        the_form.attr("method", form_data.method);
121
        the_form.attr("action", form_data.action);
122
        delete form_data.method;
123
        delete form_data.action;
124
        $.each(form_data, function (key, value) {
125
            the_form.append(
126
                $("<input/>", {
127
                    type: "hidden",
128
                    name: key,
129
                    value: value,
130
                })
131
            );
132
        });
133
        if (form_data.new_tab) {
134
            the_form.attr("target", "_blank");
135
        }
136
        $("body").append(the_form);
137
        the_form.submit();
138
    });
139
140
    $(".close, .close_window").on("click", function (e) {
102
    $(".close, .close_window").on("click", function (e) {
141
        e.preventDefault();
103
        e.preventDefault();
142
        window.close();
104
        window.close();
143
- 

Return to bug 39567