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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/modals/problem_report.inc (+40 lines)
Line 0 Link Here
1
<!-- Add problem report modal -->
2
<div class="modal" id="reportProblemModal" tabindex="-1" role="dialog" aria-labelledby="reportProblemModalLabel" aria-hidden="true">
3
    <div class="modal-dialog modal-lg">
4
        <div class="modal-content">
5
            <div class="modal-header">
6
                <h1 class="modal-title" id="reportProblemModalLabel">Report a problem</h1>
7
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
8
            </div>
9
            <div class="modal-body">
10
                <fieldset id="problem_fieldset">
11
                    <div class="form-group">
12
                        <label for="problem_recipient">Recipient: </label>
13
                        [% IF library.inbound_email_address && library.inbound_email_address != Koha.Preference('KohaAdminEmailAddress') %]
14
                            <select name="recipient" id="recipient">
15
                                <option value="library">A librarian</option>
16
                                <option value="admin">System administrator</option>
17
                            </select>
18
                        [% ELSE %]
19
                            <span>System administrator</span>
20
                        [% END %]
21
                    </div>
22
                    <div class="form-group">
23
                        <label for="problem_subject">Subject: </label>
24
                        <input type="text" name="problem_subject" id="problem_subject" required="required"/>
25
                    </div>
26
                    <div class="form-group">
27
                        <label for="problem_body">Please describe the problem: </label>
28
                        <textarea class="form-control" name="problem_body" id="problem_body" aria-describedby="helpBlock" required="required" rows="15"></textarea>
29
                    </div>
30
                </fieldset>
31
            </div>
32
            <div class="modal-footer">
33
                <input type="hidden" name="page_url" id="page_url" value="">
34
                <input type="hidden" name="reporter_id" id="problem_reporter" value="[% logged_in_user.borrowernumber | html %]">
35
                <button type="submit" class="addConfirm btn btn-primary">Submit <i id="problem-submit-spinner" class="fa fa-spinner fa-pulse fa-fw" style="display:none"></i></button>
36
                <button type="button" class="btn btn-default" data-bs-dismiss="modal">Cancel</button>
37
            </div>
38
        </div>
39
    </div>
40
</div>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc (+11 lines)
Lines 34-39 Link Here
34
34
35
                    <div class="navbar-nav flex-grow-1">
35
                    <div class="navbar-nav flex-grow-1">
36
                        [% IF Koha.Preference('OPACReportProblem') && Koha.Preference('KohaAdminEmailAddress') %]
36
                        [% IF Koha.Preference('OPACReportProblem') && Koha.Preference('KohaAdminEmailAddress') %]
37
                            <a id="report_a_problem" class="nav-link" href="#" data-bs-toggle="modal" data-bs-target="#reportProblemModal">
38
                                <i class="fa fa-warning fa-fw fa-icon-footer" aria-hidden="true"></i>
39
                                <span class="report_a_problem_text" >Report a problem</span>
40
                            </a>
37
                            <a id="report_a_problem" class="nav-link" href="/cgi-bin/koha/opac-reportproblem.pl">
41
                            <a id="report_a_problem" class="nav-link" href="/cgi-bin/koha/opac-reportproblem.pl">
38
                                <i class="fa fa-warning fa-fw fa-icon-footer" aria-hidden="true"></i>
42
                                <i class="fa fa-warning fa-fw fa-icon-footer" aria-hidden="true"></i>
39
                                <span class="report_a_problem_text">Report a problem</span>
43
                                <span class="report_a_problem_text">Report a problem</span>
Lines 66-71 Link Here
66
    [% INCLUDE 'modals/checkout.inc' %]
70
    [% INCLUDE 'modals/checkout.inc' %]
67
[% END %]
71
[% END %]
68
72
73
[% IF ( Koha.Preference('OPACReportProblem') && Koha.Preference('KohaAdminEmailAddress') ) %]
74
    [% INCLUDE 'modals/problem_report.inc' %]
75
[% END %]
76
69
<!-- CookieConsentedJS code that may run -->
77
<!-- CookieConsentedJS code that may run -->
70
[% IF Koha.Preference( 'CookieConsent' ) && JSConsents.all('opacConsent').size %]
78
[% IF Koha.Preference( 'CookieConsent' ) && JSConsents.all('opacConsent').size %]
71
    [% consents = JSConsents.all('opacConsent') %]
79
    [% consents = JSConsents.all('opacConsent') %]
Lines 202-207 $(document).ready(function() { Link Here
202
[% IF Koha.Preference( 'CookieConsent' ) %]
210
[% IF Koha.Preference( 'CookieConsent' ) %]
203
    [% Asset.js("js/cookieconsent.js") | $raw %]
211
    [% Asset.js("js/cookieconsent.js") | $raw %]
204
[% END %]
212
[% END %]
213
[% IF ( Koha.Preference('OPACReportProblem') && Koha.Preference('KohaAdminEmailAddress') ) %]
214
    [% Asset.js("js/modals/problem_report.js") | $raw %]
215
[% END %]
205
[% KohaPlugins.get_plugins_opac_js | $raw %]
216
[% KohaPlugins.get_plugins_opac_js | $raw %]
206
</body>
217
</body>
207
</html>
218
</html>
(-)a/koha-tmpl/opac-tmpl/bootstrap/js/modals/problem_report.js (-1 / +66 lines)
Line 0 Link Here
0
- 
1
$(document).ready(function() {
2
3
    // Detect that we were redirected here after login and re-open modal
4
    let urlParams = new URLSearchParams(window.location.search);
5
    if (urlParams.has('modal')) {
6
        let modal = urlParams.get('modal');
7
        history.replaceState && history.replaceState(
8
            null, '', location.pathname + location.search.replace(/[\?&]modal=[^&]+/, '').replace(/^&/, '?')
9
        );
10
        if (modal == 'problem') {
11
            $("#reportProblemModal").modal('show');
12
        }
13
    }
14
15
    $('#reportProblemModal').on('show.bs.modal', function(e) {
16
        // Redirect to login modal if not logged in
17
        if (logged_in_user_id === "") {
18
            $('#modalAuth').append('<input type="hidden" name="return" value="' + window.location.pathname + window.location.search + '&modal=problem" />');
19
            $('#loginModal').modal('show');
20
            return false;
21
        }
22
23
        $('.addConfirm').prop('disabled', false);
24
    });
25
26
    $('#reportProblemModal').on('click', '.addConfirm', function(e) {
27
        let problem_title = $('#problem_subject').val();
28
        let problem_body = $('#problem_body').val();
29
        let reporter_id = $('#problem_reporter').val();
30
31
        params = {
32
            source: 'opac_problem',
33
            title: problem_title,
34
            body: problem_body,
35
            biblio_id: null,
36
            reporter_id: reporter_id,
37
            extended_attributes: [
38
                { 
39
                    field_id: 1,
40
                    value: window.location.pathname + window.location.search
41
                }
42
            ]
43
        };
44
45
        $('#problem-submit-spinner').show();
46
        $('.addConfirm').prop('disabled', true);
47
        $.ajax({
48
            url: '/api/v1/public/tickets',
49
            type: 'POST',
50
            data: JSON.stringify(params),
51
            success: function(data) {
52
                $('#problem-submit-spinner').hide();
53
                $('#reportProblemModal').modal('hide');
54
                $('#problem_body').val('');
55
                $('#problem_title').val('');
56
                $('h1:first').before('<div class="alert alert-success">' + __("Your problem was sucessfully submitted.") + '</div>');
57
            },
58
            error: function(data) {
59
                $('#problem-submit-spinner').hide();
60
                $('#reportProblemModal').modal('hide');
61
                $('h1:first').before('<div class="alert alert-error">' + __("There was an error when submitting your problem, please contact a librarian.") + '</div>');
62
            },
63
            contentType: "json"
64
        });
65
    });
66
});

Return to bug 34324