Bug 36084: svc - overdrive
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
6323e08ed7
commit
82359cf085
3 changed files with 16 additions and 15 deletions
|
@ -7,7 +7,7 @@
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<form action="#" method="post" id="overdrive-login-form">
|
<form action="#" id="overdrive-login-form">
|
||||||
[% INCLUDE 'csrf-token.inc' %]
|
[% INCLUDE 'csrf-token.inc' %]
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<fieldset class="brief">
|
<fieldset class="brief">
|
||||||
|
|
|
@ -193,6 +193,7 @@ KOHA.OverDriveCirculation = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function svc_ajax ( method, params, success_callback ) {
|
function svc_ajax ( method, params, success_callback ) {
|
||||||
|
params.csrf_token = $('meta[name="csrf-token"]').attr('content');
|
||||||
return $.ajax({
|
return $.ajax({
|
||||||
method: method,
|
method: method,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
|
@ -218,7 +219,7 @@ KOHA.OverDriveCirculation = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function login(p) {
|
function login(p) {
|
||||||
svc_ajax('get', { action: "login", password: p }, function(data) {
|
svc_ajax('post', { action: "cud-login", password: p }, function(data) {
|
||||||
details = null;
|
details = null;
|
||||||
if( data.login_success ){
|
if( data.login_success ){
|
||||||
$(login_div).detach();
|
$(login_div).detach();
|
||||||
|
@ -232,7 +233,7 @@ KOHA.OverDriveCirculation = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function logout (callback) {
|
function logout (callback) {
|
||||||
svc_ajax('post', { action: "logout" }, function(data) {
|
svc_ajax('post', { action: "cud-logout" }, function(data) {
|
||||||
details = null;
|
details = null;
|
||||||
callback(data);
|
callback(data);
|
||||||
});
|
});
|
||||||
|
@ -300,7 +301,7 @@ KOHA.OverDriveCirculation = new function() {
|
||||||
|
|
||||||
$(el).append( ajax_button( __("Check in"), function() {
|
$(el).append( ajax_button( __("Check in"), function() {
|
||||||
if( confirm( __("Are you sure you want to return this item?") ) ) {
|
if( confirm( __("Are you sure you want to return this item?") ) ) {
|
||||||
item_action({action: "return", id: id}, el, copies_available + 1);
|
item_action({action: "cud-return", id: id}, el, copies_available + 1);
|
||||||
}
|
}
|
||||||
}, "checkin") );
|
}, "checkin") );
|
||||||
|
|
||||||
|
@ -318,7 +319,7 @@ KOHA.OverDriveCirculation = new function() {
|
||||||
if(copies_available && checkout_popup) {
|
if(copies_available && checkout_popup) {
|
||||||
$(el).append( ajax_button( __("Check out") , function() {
|
$(el).append( ajax_button( __("Check out") , function() {
|
||||||
if( confirm( __("Are you sure you want to check out this item?") ) ) {
|
if( confirm( __("Are you sure you want to check out this item?") ) ) {
|
||||||
svc_ajax('post', {action: "checkout", id: id}, function(data) {
|
svc_ajax('post', {action: "cud-checkout", id: id}, function(data) {
|
||||||
if (data.checkouts) {
|
if (data.checkouts) {
|
||||||
details.checkouts = data.checkouts;
|
details.checkouts = data.checkouts;
|
||||||
}
|
}
|
||||||
|
@ -347,14 +348,14 @@ KOHA.OverDriveCirculation = new function() {
|
||||||
}
|
}
|
||||||
else if (!item) {
|
else if (!item) {
|
||||||
$(el).append( ajax_button( __("Place hold"), function() {
|
$(el).append( ajax_button( __("Place hold"), function() {
|
||||||
item_action({action: "place-hold", id: id}, el, copies_available);
|
item_action({action: "cud-place-hold", id: id}, el, copies_available);
|
||||||
}, "placehold") );
|
}, "placehold") );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
$(el).append( ajax_button( __("Cancel hold"), function() {
|
$(el).append( ajax_button( __("Cancel hold"), function() {
|
||||||
if( confirm( __("Are you sure you want to cancel this hold?") ) ) {
|
if( confirm( __("Are you sure you want to cancel this hold?") ) ) {
|
||||||
item_action({action: "remove-hold", id: id}, el, copies_available);
|
item_action({action: "cud-remove-hold", id: id}, el, copies_available);
|
||||||
}
|
}
|
||||||
}, "cancelhold") );
|
}, "cancelhold") );
|
||||||
}
|
}
|
||||||
|
@ -399,7 +400,7 @@ KOHA.OverDriveCirculation = new function() {
|
||||||
checkout_popup.find(".overdrive-checkout-submit").click(function(e) {
|
checkout_popup.find(".overdrive-checkout-submit").click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var format = checkout_format_list.find("input[type='radio'][name='checkout-format']:checked").val();
|
var format = checkout_format_list.find("input[type='radio'][name='checkout-format']:checked").val();
|
||||||
item_action({action: "checkout-format", id: id, format: format}, el, copies_available);
|
item_action({action: "cud-checkout-format", id: id, format: format}, el, copies_available);
|
||||||
$(this).unbind( e );
|
$(this).unbind( e );
|
||||||
checkout_popup.modal("hide");
|
checkout_popup.modal("hide");
|
||||||
});
|
});
|
||||||
|
|
|
@ -44,7 +44,7 @@ my %data = (
|
||||||
local $@;
|
local $@;
|
||||||
eval {
|
eval {
|
||||||
{
|
{
|
||||||
$action eq 'login' && do {
|
$action eq 'cud-login' && do {
|
||||||
my $password = $cgi->param("password") // q{} ;
|
my $password = $cgi->param("password") // q{} ;
|
||||||
my $patron = Koha::Patrons->find({ userid => $user });
|
my $patron = Koha::Patrons->find({ userid => $user });
|
||||||
my $branch_info = $patron ? Koha::Library::OverDriveInfos->find( $patron->branchcode ) : undef;
|
my $branch_info = $patron ? Koha::Library::OverDriveInfos->find( $patron->branchcode ) : undef;
|
||||||
|
@ -64,7 +64,7 @@ eval {
|
||||||
if ($od->is_logged_in) {
|
if ($od->is_logged_in) {
|
||||||
$data{is_logged_in} = JSON::true;
|
$data{is_logged_in} = JSON::true;
|
||||||
|
|
||||||
$action eq 'logout' && do {
|
$action eq 'cud-logout' && do {
|
||||||
$od->forget();
|
$od->forget();
|
||||||
$data{login_url} = $od->auth_url($page_url);
|
$data{login_url} = $od->auth_url($page_url);
|
||||||
$data{is_logged_in} = JSON::false;
|
$data{is_logged_in} = JSON::false;
|
||||||
|
@ -78,7 +78,7 @@ eval {
|
||||||
last;
|
last;
|
||||||
};
|
};
|
||||||
|
|
||||||
$action eq 'checkout' && do {
|
$action eq 'cud-checkout' && do {
|
||||||
my $id = $cgi->param('id')
|
my $id = $cgi->param('id')
|
||||||
or response_bad_request("No 'id' specified");
|
or response_bad_request("No 'id' specified");
|
||||||
my $format = $cgi->param('format');
|
my $format = $cgi->param('format');
|
||||||
|
@ -88,7 +88,7 @@ eval {
|
||||||
last;
|
last;
|
||||||
};
|
};
|
||||||
|
|
||||||
$action eq 'checkout-format' && do {
|
$action eq 'cud-checkout-format' && do {
|
||||||
my $id = $cgi->param('id')
|
my $id = $cgi->param('id')
|
||||||
or response_bad_request("No 'id' specified");
|
or response_bad_request("No 'id' specified");
|
||||||
my $format = $cgi->param('format')
|
my $format = $cgi->param('format')
|
||||||
|
@ -105,7 +105,7 @@ eval {
|
||||||
last;
|
last;
|
||||||
};
|
};
|
||||||
|
|
||||||
$action eq 'return' && do {
|
$action eq 'cud-return' && do {
|
||||||
my $id = $cgi->param('id')
|
my $id = $cgi->param('id')
|
||||||
or response_bad_request("No 'id' specified");
|
or response_bad_request("No 'id' specified");
|
||||||
local $@;
|
local $@;
|
||||||
|
@ -115,7 +115,7 @@ eval {
|
||||||
last;
|
last;
|
||||||
};
|
};
|
||||||
|
|
||||||
$action eq 'place-hold' && do {
|
$action eq 'cud-place-hold' && do {
|
||||||
my $id = $cgi->param('id')
|
my $id = $cgi->param('id')
|
||||||
or response_bad_request("No 'id' specified");
|
or response_bad_request("No 'id' specified");
|
||||||
$data{action} = $od->place_hold($id);
|
$data{action} = $od->place_hold($id);
|
||||||
|
@ -123,7 +123,7 @@ eval {
|
||||||
last;
|
last;
|
||||||
};
|
};
|
||||||
|
|
||||||
$action eq 'remove-hold' && do {
|
$action eq 'cud-remove-hold' && do {
|
||||||
my $id = $cgi->param('id')
|
my $id = $cgi->param('id')
|
||||||
or response_bad_request("No 'id' specified");
|
or response_bad_request("No 'id' specified");
|
||||||
local $@;
|
local $@;
|
||||||
|
|
Loading…
Reference in a new issue