Browse Source
This patch brings the CatalogConcerns feature to the staff client allowing non-cataloguers to report issues with catalog records from the record details page. Test plan 1) Enable the new `CatalogConcerns` system preference 2) Confirm that without the `edit_catalogue` permission your user can submit a catalog concern via `New -> New catalog concern` from the toolbar on a records detail display. 3) Confirm that the right user was recorded as the reporter on the catalog concern management page (You must have logged in again as a user with the `edit_catalogue` permission to see this page. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Helen Oliver <HOliver@tavi-port.ac.uk> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>master
18 changed files with 206 additions and 9 deletions
@ -0,0 +1,50 @@ |
|||
[% USE raw %] |
|||
[% USE AdditionalContents %] |
|||
[% SET CatalogConcernHelp = AdditionalContents.get( location => "CatalogConcernHelp", lang => lang, library => logged_in_user.branchcode ) %] |
|||
[% SET CatalogConcernTemplate = AdditionalContents.get( location => "CatalogConcernTemplate", lang => lang, library => logged_in_user.branchcode ) %] |
|||
<!-- Add concern modal --> |
|||
<div class="modal" id="addConcernModal" tabindex="-1" role="dialog" aria-labelledby="addConcernModalLabel" aria-hidden="true"> |
|||
<div class="modal-dialog modal-lg" role="document"> |
|||
<div class="modal-content modal-lg"> |
|||
<div class="modal-header"> |
|||
<button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"> |
|||
<span aria-hidden="true">×</span> |
|||
</button> |
|||
<h4 class="modal-title" id="addConcernModalLabel">Add concern</h4> |
|||
</div> |
|||
<div class="modal-body"> |
|||
<fieldset id="concern_fieldset"> |
|||
<ol> |
|||
<li class="form-group row"> |
|||
<label for="concern_title" class="col-sm-1 col-form-label">Title: </label> |
|||
<div class="col-sm-11"> |
|||
<input type="text" name="concern_title" id="concern_title" class="form-control" required="required"/> |
|||
</div> |
|||
</li> |
|||
<li class="form-group"> |
|||
<label class="required" for="concern_body">Please describe your concern: </label> |
|||
<textarea class="form-control" id="concern_body" name="concern_body" required="required" rows="15"></textarea> |
|||
[%- IF CatalogConcernHelp && CatalogConcernHelp.content && CatalogConcernHelp.content.count > 0 -%] |
|||
[%- FOREACH help IN CatalogConcernHelp.content -%] |
|||
<p id="helpBlock" class="help-block">[%- help.content | $raw -%]</p> |
|||
[%- END -%] |
|||
[%- END -%] |
|||
<div class="hidden" id="concern_template"> |
|||
[%- IF CatalogConcernTemplate && CatalogConcernTemplate.content && CatalogConcernTemplate.content.count > 0 -%] |
|||
[%- FOREACH template IN CatalogConcernTemplate.content -%] |
|||
[%- template.content | $raw -%] |
|||
[%- END -%] |
|||
[%- END -%] |
|||
</div> |
|||
</li> |
|||
</ol> |
|||
</fieldset> |
|||
</div> <!-- /.modal-body --> |
|||
<div class="modal-footer"> |
|||
<input type="hidden" id="concern_biblio" name="biblio_id" value="[% biblionumber | html %]"> |
|||
<button type="submit" class="btn btn-primary" id="addConfirm">Submit <i id="concern-submit-spinner" class="fa fa-spinner fa-pulse fa-fw" style="display:none"></i></button> |
|||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> |
|||
</div> <!-- /.modal-footer --> |
|||
</div> <!-- /.modal-content --> |
|||
</div> <!-- /.modal-dialog --> |
|||
</div> <!-- /#addConcernModal --> |
@ -0,0 +1,51 @@ |
|||
$(document).ready(function() { |
|||
|
|||
// Pre-populate empty message with template
|
|||
$('#addConcernModal').on('show.bs.modal', function (e) { |
|||
$('#addConfirm').prop('disabled', false); |
|||
let concern_body = $('#concern_body'); |
|||
if ( concern_body.val() === "" ) { |
|||
let template = $('#concern_template').text(); |
|||
concern_body.val(template); |
|||
} |
|||
}); |
|||
|
|||
$('#addConcernModal').on('click', '#addConfirm', function(e) { |
|||
let concern_title = $('#concern_title').val(); |
|||
let concern_body = $('#concern_body').val(); |
|||
let biblio_id = $('#concern_biblio').val(); |
|||
let reporter_id = $('#concern_reporter').val(); |
|||
|
|||
let params = { |
|||
title: concern_title, |
|||
body: concern_body, |
|||
biblio_id: biblio_id, |
|||
reporter_id: logged_in_user_borrowernumber, |
|||
}; |
|||
|
|||
$('#concern-submit-spinner').show(); |
|||
$('#addConfirm').prop('disabled', true); |
|||
|
|||
$.ajax({ |
|||
url: '/api/v1/tickets', |
|||
type: 'POST', |
|||
data: JSON.stringify(params), |
|||
success: function(data) { |
|||
$('#concern-submit-spinner').hide(); |
|||
$('#addConcernModal').modal('hide'); |
|||
$('#concern_body').val(''); |
|||
$('#concern_title').val(''); |
|||
$('#toolbar').before('<div class="alert alert-success">Your concern was sucessfully submitted.</div>'); |
|||
if ($.fn.dataTable.isDataTable("#table_concerns")) { |
|||
$("#table_concerns").DataTable().ajax.reload(); |
|||
} |
|||
}, |
|||
error: function(data) { |
|||
$('#concern-submit-spinner').hide(); |
|||
$('#addConcernModal').modal('hide'); |
|||
$('#toolbar').before('<div class="alert alert-error">There was an error when submitting your concern, please contact a librarian.</div>'); |
|||
}, |
|||
contentType: "json" |
|||
}); |
|||
}); |
|||
}); |
Loading…
Reference in new issue