Bug 21232: Add a client-side check on biblionumber when creating a subscription
This patch adds an AJAX call to the REST API (/api/v1/biblios/) to retrieve and display the biblio's title. On clicking the "next" button a check is done to make sure the title exists, which means the biblionumber we manually entered is valid (can we assume a title is mandatory?) Test plan: - Create or edit a new subscription - Enter an invalid biblionumber in the input => A friendly note is telling you that the biblio does not exist - Try to switch to the next screen => You get an alert - Enter a valid biblionumber in the input => The title is displayed => Try to switch to the next screen => It works! Signed-off-by: hc <hc@interleaf.ie> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
8112e2a636
commit
92c6d3511e
2 changed files with 29 additions and 2 deletions
|
@ -61,6 +61,7 @@ fieldset.rows table { clear: none; margin: 0; }
|
|||
<label for="biblionumber" class="required">Record:</label>
|
||||
<input type="text" name="biblionumber" id="biblionumber" value="[% bibnum | html %]" size="8" />
|
||||
(<input type="text" name="title" value="[% bibliotitle | html %]" disabled="disabled" readonly="readonly" />) <span class="required" title="Subscriptions must be associated with a bibliographic record">Required</span>
|
||||
<span id="error_bib_not_exist"></span>
|
||||
<div class="hint">Subscriptions must be associated with a bibliographic record</div>
|
||||
<div class="inputnote"> <a href="#" id="record_search"><i class="fa fa-search"></i> Search for record</a>
|
||||
[% IF ( CAN_user_editcatalogue ) %]
|
||||
|
|
|
@ -52,12 +52,17 @@ function Check_page1() {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if ($("#biblionumber").val().length == 0) {
|
||||
|
||||
var biblionumber = $("#biblionumber").val()
|
||||
if ( biblionumber.length == 0 ) {
|
||||
alert( MSG_LINK_BIBLIO );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
var bib_exists = $("input[name='title']").val().length;
|
||||
|
||||
if (!bib_exists) alert(_("Bibliographic record does not exist!"));
|
||||
return bib_exists;
|
||||
}
|
||||
|
||||
function Check_page2(){
|
||||
|
@ -694,4 +699,25 @@ $(document).ready(function() {
|
|||
e.preventDefault();
|
||||
hidePredcitionPatternTest();
|
||||
});
|
||||
|
||||
$("#biblionumber").on("change", function(){
|
||||
var biblionumber = $(this).val();
|
||||
$.ajax({
|
||||
url: "/api/v1/biblios/" + biblionumber,
|
||||
type: "GET",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
contentType: "application/json",
|
||||
success: function (biblio) {
|
||||
$("input[name='title']").val(biblio['title']);
|
||||
$("#error_bib_not_exist").html("");
|
||||
},
|
||||
error: function (x) {
|
||||
$("input[name='title']").val('');
|
||||
$("#error_bib_not_exist").html("This bibliographic record does not exist");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue