Commit fb5008c9 authored by Laurent's avatar Laurent

SIP Loan: scan item and request

parent da5b2edb
......@@ -13,7 +13,8 @@ import { Database,
OAuthTokenNotSet,
WrongLoginPassword,
Cookies,
Manager
Manager,
Iso8601Date
} from '../models/';
import { RadSideDrawer } from 'nativescript-ui-sidedrawer';
......@@ -146,6 +147,55 @@ export class LibraryController extends Controller {
}
public loanItemAction() {
this._closeDrawer();
(new BarcodeScanner())
.scan({
formats: "CODE_39",
cancelLabel: L('barcode_scanner_cancel'),
message: L('barcode_scanner_hint'),
showFlipCameraButton: false,
preferFrontCamera: false,
showTorchButton: true,
orientation: "portrait",
openSettingsIfPermissionWasPreviouslyDenied: true
})
.then(
(result) => {
setTimeout( () => { this._loanItem(result.text) }, 500);
});
}
protected _loanItem(barcode:string) {
this.dialogs
.prompt({
title: L('do_loan_barcode', barcode),
message: L('enter_password'),
okButtonText: L('do_loan'),
cancelButtonText: L('cancel'),
inputType: this.dialogs.inputType.password
})
.then( (result) => {
return this._manager.loan(Database.current(), this._account, result.text, barcode);
})
.then( (result) => {
if (result['success'])
return this.dialogs.alert({title: L('confirm'),
message: L('loan_title_date_due',
result['title'],
new Iso8601Date(result['date_due']).asLongDate()),
okButtonText: L('OK')});
return this.dialogs.confirm( { title: L('error'),
message: result['message'],
okButtonText: L('OK')});
});
}
public scanCardAction() {
(new BarcodeScanner()).scan({
formats: "CODE_39",
......
......@@ -60,4 +60,8 @@
<string name="no_holds">No holds. Pull to refresh.</string>
<string name="loans_and_holds">Loans / Holds</string>
<string name="library">Library</string>
<string name="do_loan">Loan item</string>
<string name="do_loan_barcode">Loan : %s</string>
<string name="enter_password">To finish the request, enter your password</string>
<string name="loan_title_date_due">%s, bring back for %s</string>
</resources>
......@@ -60,4 +60,8 @@
<string name="no_holds">No hay reserva. Dezliza para refrescar.</string>
<string name="loans_and_holds">Prestamos / Reservas</string>
<string name="library">Biblioteca</string>
<string name="do_loan">Pedir prestado</string>
<string name="do_loan_barcode">Prestamo : %s</string>
<string name="enter_password">Para finalizar la solicitud, ingrese su contraseña</string>
<string name="loan_title_date_due">%s, %s</string>
</resources>
......@@ -60,4 +60,8 @@
<string name="no_holds">Aucune réservation. Tirez pour rafraîchir.</string>
<string name="loans_and_holds">Prêts / Réservations</string>
<string name="library">Bibliothèque</string>
<string name="do_loan">Emprunter</string>
<string name="do_loan_barcode">Emprunt : %s</string>
<string name="enter_password">Pour finaliser la demande, veuillez saisir votre mot de passe</string>
<string name="loan_title_date_due">%s, para regresar a más tardar %s</string>
</resources>
......@@ -22,11 +22,16 @@ export class Manager {
let params = { url: this._url + '/api/' + service,
headers: { "Content-Type": "application/json" } };
if (content) params['content'] = content;
if (content) {
params['method'] = "POST";
params['content'] = JSON.stringify(content);
}
return this._http
.request(params)
.then( (response) => {
console.dir(response.content.toString());
let datas = response.content.toJSON();
return datas;
})
......
......@@ -9,11 +9,10 @@
<Label text="{{ '&#xf2c2; ' + L('show_card') }}" class="fa" />
</StackLayout>
<StackLayout tap="{{ }}" visibility="{{ sip_loan ? 'visible' : 'collapsed' }}" >
<Label text="{{ '&#xf2c2; ' + L('sip_loan') }}" class="fa" />
<StackLayout tap="{{ loanItemAction }}" visibility="{{ sip_loan ? 'visible' : 'collapsed' }}" >
<Label text="{{ '&#xf4bd; ' + L('loan_item') }}" class="fa" />
</StackLayout>
<StackLayout tap="{{ showNoveltiesAction }}" visibility="{{ show_novelties ? 'visible' : 'collapsed' }}" >
<Label text="{{ '&#xf06d; ' + L('novelties') }}" class="fa" />
</StackLayout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment