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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/modals/problem_report.inc (+42 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
                <h3 class="modal-title" id="reportProblemModalLabel">Report a problem</h3>
7
                <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close">
8
                    <span aria-hidden="true">&times;</span>
9
                </button>
10
            </div>
11
            <div class="modal-body">
12
                <fieldset id="problem_fieldset">
13
                    <div class="form-group">
14
                        <label for="problem_recipient">Recipient: </label>
15
                        [% IF library.inbound_email_address && library.inbound_email_address != Koha.Preference('KohaAdminEmailAddress') %]
16
                            <select name="recipient" id="recipient">
17
                                <option value="library">A librarian</option>
18
                                <option value="admin">System administrator</option>
19
                            </select>
20
                        [% ELSE %]
21
                            <span>System administrator</span>
22
                        [% END %]
23
                    </div>
24
                    <div class="form-group">
25
                        <label for="problem_subject">Subject: </label>
26
                        <input type="text" name="problem_subject" id="problem_subject" required="required"/>
27
                    </div>
28
                    <div class="form-group">
29
                        <label for="problem_body">Please describe the problem: </label>
30
                        <textarea class="form-control" name="problem_body" id="problem_body" aria-describedby="helpBlock" required="required" rows="15"></textarea>
31
                    </div>
32
                </fieldset>
33
            </div>
34
            <div class="modal-footer">
35
                <input type="hidden" name="page_url" id="page_url" value="">
36
                <input type="hidden" name="reporter_id" id="problem_reporter" value="[% logged_in_user.borrowernumber | html %]">
37
                <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>
38
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
39
            </div>
40
        </div>
41
    </div>
42
</div>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc (+8 lines)
Lines 30-35 Link Here
30
                                [% IF Koha.Preference('OPACReportProblem') && Koha.Preference('KohaAdminEmailAddress') %]
30
                                [% IF Koha.Preference('OPACReportProblem') && Koha.Preference('KohaAdminEmailAddress') %]
31
                                    <div class="col">
31
                                    <div class="col">
32
                                        <div id="report_a_problem" class="noprint">
32
                                        <div id="report_a_problem" class="noprint">
33
                                            <a class="report_a_problem koha-url" href="#" data-toggle="modal" data-target="#reportProblemModal">Report a problem</a>
33
                                            <a class="koha-url" href="/cgi-bin/koha/opac-reportproblem.pl">Report a problem</a>
34
                                            <a class="koha-url" href="/cgi-bin/koha/opac-reportproblem.pl">Report a problem</a>
34
                                        </div>
35
                                        </div>
35
                                    </div>
36
                                    </div>
Lines 125-130 Link Here
125
    [% INCLUDE 'modals/checkout.inc' %]
126
    [% INCLUDE 'modals/checkout.inc' %]
126
[% END %]
127
[% END %]
127
128
129
[% IF ( Koha.Preference('OPACReportProblem') && Koha.Preference('KohaAdminEmailAddress') ) %]
130
    [% INCLUDE 'modals/problem_report.inc' %]
131
[% END %]
132
128
<!-- CookieConsentedJS code that may run -->
133
<!-- CookieConsentedJS code that may run -->
129
[% IF Koha.Preference( 'CookieConsent' ) && JSConsents.all('opacConsent').size %]
134
[% IF Koha.Preference( 'CookieConsent' ) && JSConsents.all('opacConsent').size %]
130
    [% consents = JSConsents.all('opacConsent') %]
135
    [% consents = JSConsents.all('opacConsent') %]
Lines 261-266 $(document).ready(function() { Link Here
261
[% IF Koha.Preference( 'CookieConsent' ) %]
266
[% IF Koha.Preference( 'CookieConsent' ) %]
262
    [% Asset.js("js/cookieconsent.js") | $raw %]
267
    [% Asset.js("js/cookieconsent.js") | $raw %]
263
[% END %]
268
[% END %]
269
[% IF ( Koha.Preference('OPACReportProblem') && Koha.Preference('KohaAdminEmailAddress') ) %]
270
    [% Asset.js("js/modals/problem_report.js") | $raw %]
271
[% END %]
264
[% KohaPlugins.get_plugins_opac_js | $raw %]
272
[% KohaPlugins.get_plugins_opac_js | $raw %]
265
</body>
273
</body>
266
</html>
274
</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