Bugzilla – Attachment 173586 Details for
Bug 34324
Merge OPACProblemReport and CatalogConcern functions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34324: Add 'Report a problem' modal
Bug-34324-Add-Report-a-problem-modal.patch (text/plain), 8.31 KB, created by
Martin Renvoize (ashimema)
on 2024-10-28 17:44:57 UTC
(
hide
)
Description:
Bug 34324: Add 'Report a problem' modal
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-10-28 17:44:57 UTC
Size:
8.31 KB
patch
obsolete
>From e26d9e960ac8f11f6643647c4f69fdcfad62bfbc Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 21 Dec 2023 12:44:24 +0000 >Subject: [PATCH] Bug 34324: Add 'Report a problem' modal > >This patch adds a modal for reporting opac problems. This will allow us >to remove the controller and template code for the feature. >--- > .../en/includes/modals/problem_report.inc | 40 +++++++++++ > .../bootstrap/en/includes/opac-bottom.inc | 11 ++++ > .../bootstrap/js/modals/problem_report.js | 66 +++++++++++++++++++ > 3 files changed, 117 insertions(+) > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/modals/problem_report.inc > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/js/modals/problem_report.js > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/modals/problem_report.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/modals/problem_report.inc >new file mode 100644 >index 00000000000..ff807a32d4a >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/modals/problem_report.inc >@@ -0,0 +1,40 @@ >+<!-- Add problem report modal --> >+<div class="modal" id="reportProblemModal" tabindex="-1" role="dialog" aria-labelledby="reportProblemModalLabel" aria-hidden="true"> >+ <div class="modal-dialog modal-lg"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <h1 class="modal-title" id="reportProblemModalLabel">Report a problem</h1> >+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> >+ </div> >+ <div class="modal-body"> >+ <fieldset id="problem_fieldset"> >+ <div class="form-group"> >+ <label for="problem_recipient">Recipient: </label> >+ [% IF library.inbound_email_address && library.inbound_email_address != Koha.Preference('KohaAdminEmailAddress') %] >+ <select name="recipient" id="recipient"> >+ <option value="library">A librarian</option> >+ <option value="admin">System administrator</option> >+ </select> >+ [% ELSE %] >+ <span>System administrator</span> >+ [% END %] >+ </div> >+ <div class="form-group"> >+ <label for="problem_subject">Subject: </label> >+ <input type="text" name="problem_subject" id="problem_subject" required="required"/> >+ </div> >+ <div class="form-group"> >+ <label for="problem_body">Please describe the problem: </label> >+ <textarea class="form-control" name="problem_body" id="problem_body" aria-describedby="helpBlock" required="required" rows="15"></textarea> >+ </div> >+ </fieldset> >+ </div> >+ <div class="modal-footer"> >+ <input type="hidden" name="page_url" id="page_url" value=""> >+ <input type="hidden" name="reporter_id" id="problem_reporter" value="[% logged_in_user.borrowernumber | html %]"> >+ <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> >+ <button type="button" class="btn btn-default" data-bs-dismiss="modal">Cancel</button> >+ </div> >+ </div> >+ </div> >+</div> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >index 50d78ea97be..3b4e28fd70f 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >@@ -34,6 +34,10 @@ > > <div class="navbar-nav flex-grow-1"> > [% IF Koha.Preference('OPACReportProblem') && Koha.Preference('KohaAdminEmailAddress') %] >+ <a id="report_a_problem" class="nav-link" href="#" data-bs-toggle="modal" data-bs-target="#reportProblemModal"> >+ <i class="fa fa-warning fa-fw fa-icon-footer" aria-hidden="true"></i> >+ <span class="report_a_problem_text" >Report a problem</span> >+ </a> > <a id="report_a_problem" class="nav-link" href="/cgi-bin/koha/opac-reportproblem.pl"> > <i class="fa fa-warning fa-fw fa-icon-footer" aria-hidden="true"></i> > <span class="report_a_problem_text">Report a problem</span> >@@ -66,6 +70,10 @@ > [% INCLUDE 'modals/checkout.inc' %] > [% END %] > >+[% IF ( Koha.Preference('OPACReportProblem') && Koha.Preference('KohaAdminEmailAddress') ) %] >+ [% INCLUDE 'modals/problem_report.inc' %] >+[% END %] >+ > <!-- CookieConsentedJS code that may run --> > [% IF Koha.Preference( 'CookieConsent' ) && JSConsents.all('opacConsent').size %] > [% consents = JSConsents.all('opacConsent') %] >@@ -202,6 +210,9 @@ $(document).ready(function() { > [% IF Koha.Preference( 'CookieConsent' ) %] > [% Asset.js("js/cookieconsent.js") | $raw %] > [% END %] >+[% IF ( Koha.Preference('OPACReportProblem') && Koha.Preference('KohaAdminEmailAddress') ) %] >+ [% Asset.js("js/modals/problem_report.js") | $raw %] >+[% END %] > [% KohaPlugins.get_plugins_opac_js | $raw %] > </body> > </html> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/modals/problem_report.js b/koha-tmpl/opac-tmpl/bootstrap/js/modals/problem_report.js >new file mode 100644 >index 00000000000..29aa6b8bf43 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/modals/problem_report.js >@@ -0,0 +1,66 @@ >+$(document).ready(function() { >+ >+ // Detect that we were redirected here after login and re-open modal >+ let urlParams = new URLSearchParams(window.location.search); >+ if (urlParams.has('modal')) { >+ let modal = urlParams.get('modal'); >+ history.replaceState && history.replaceState( >+ null, '', location.pathname + location.search.replace(/[\?&]modal=[^&]+/, '').replace(/^&/, '?') >+ ); >+ if (modal == 'problem') { >+ $("#reportProblemModal").modal('show'); >+ } >+ } >+ >+ $('#reportProblemModal').on('show.bs.modal', function(e) { >+ // Redirect to login modal if not logged in >+ if (logged_in_user_id === "") { >+ $('#modalAuth').append('<input type="hidden" name="return" value="' + window.location.pathname + window.location.search + '&modal=problem" />'); >+ $('#loginModal').modal('show'); >+ return false; >+ } >+ >+ $('.addConfirm').prop('disabled', false); >+ }); >+ >+ $('#reportProblemModal').on('click', '.addConfirm', function(e) { >+ let problem_title = $('#problem_subject').val(); >+ let problem_body = $('#problem_body').val(); >+ let reporter_id = $('#problem_reporter').val(); >+ >+ params = { >+ source: 'opac_problem', >+ title: problem_title, >+ body: problem_body, >+ biblio_id: null, >+ reporter_id: reporter_id, >+ extended_attributes: [ >+ { >+ field_id: 1, >+ value: window.location.pathname + window.location.search >+ } >+ ] >+ }; >+ >+ $('#problem-submit-spinner').show(); >+ $('.addConfirm').prop('disabled', true); >+ $.ajax({ >+ url: '/api/v1/public/tickets', >+ type: 'POST', >+ data: JSON.stringify(params), >+ success: function(data) { >+ $('#problem-submit-spinner').hide(); >+ $('#reportProblemModal').modal('hide'); >+ $('#problem_body').val(''); >+ $('#problem_title').val(''); >+ $('h1:first').before('<div class="alert alert-success">' + __("Your problem was sucessfully submitted.") + '</div>'); >+ }, >+ error: function(data) { >+ $('#problem-submit-spinner').hide(); >+ $('#reportProblemModal').modal('hide'); >+ $('h1:first').before('<div class="alert alert-error">' + __("There was an error when submitting your problem, please contact a librarian.") + '</div>'); >+ }, >+ contentType: "json" >+ }); >+ }); >+}); >-- >2.47.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34324
:
160199
|
160200
|
160201
|
160202
|
160203
|
160204
|
160205
|
160206
|
173580
|
173581
|
173582
|
173583
|
173584
|
173585
|
173586
|
173587
|
173671
|
173672
|
173673
|
173674
|
173675
|
173676
|
173677
|
173678
|
173679
|
173680