Skip to content

Commit

Permalink
request: fix request made by a librarian
Browse files Browse the repository at this point in the history
* Changes messages.
* Improves button appearance.
* Disables 'delete' button when a request is done.

Co-Authored-by: Alicia Zangger <alicia.zangger@rero.ch>
Co-Authored-by: Sébastien Délèze <sebastien.deleze@rero.ch>
  • Loading branch information
2 people authored and AoNoOokami committed Mar 17, 2020
1 parent 2aca32c commit dd85314
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@
</div>
<div class="col-sm-4 text-right">
<ng-container *ngIf="isAvailableActions; else noactions">
<button type="button" class="btn btn-link p-0 mr-2" (click)="addRequest(item.metadata.pid)">
<i class="fa fa-shopping-basket" aria-hidden="true" title="{{ 'Request' | translate }}"></i>
<button type="button" class="btn btn-sm btn-outline-primary" (click)="addRequest(item.metadata.pid)" >
<i class="fa fa-shopping-basket" aria-hidden="true"></i><span translate> Request</span>
</button>
<button *ngIf="permissions.update.can" type="button" class="btn btn-link p-0 mr-2"
<button *ngIf="permissions.update.can" type="button" class="btn btn-sm btn-outline-primary ml-1"
[routerLink]="['/records', 'items', 'edit', item.metadata.pid]">
<i class="fa fa-pencil" title="{{ 'Edit' | translate }}"></i>
<i class="fa fa-pencil"></i><span translate> Edit</span>
</button>
<button *ngIf="permissions.delete.can; else notDelete" type="button" class="btn btn-primary btn-sm ml-1"
<button *ngIf="permissions.delete.can; else notDelete" type="button" class="btn btn-outline-danger btn-sm ml-1"
(click)="delete(item.metadata.pid)">
<i class="fa fa-trash" title="{{ 'Delete' | translate }}"></i>
<i class="fa fa-trash" ></i><span translate> Delete</span>
</button>
<ng-template #notDelete>
<button type="button" class="btn btn-link text-muted btn-sm p-0" (click)="showDeleteMessage()">
<i class="fa fa-trash" title="{{ 'Delete' | translate }}"></i>
<button type="button" class="btn btn-sm btn-danger ml-1" (click)="showDeleteMessage()" disabled>
<i class="fa fa-trash" ></i><span translate> Delete</span>
</button>
</ng-template>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { RecordUiService } from '@rero/ng-core';
import { BsModalService } from 'ngx-bootstrap';
import { first } from 'rxjs/operators';
import { RecordPermission, RecordPermissionService } from '../../../../service/record-permission.service';
import { UserService } from '../../../../service/user.service';
import { ItemRequestComponent } from '../item-request/item-request.component';
Expand Down Expand Up @@ -63,18 +64,27 @@ export class HoldingItemComponent implements OnInit {
* Init
*/
ngOnInit() {
this.getPermissions();
}

/** Get permissions */
getPermissions() {
this._recordPermissionService.getPermission('items', this.item.metadata.pid)
.subscribe(permissions => this.permissions = permissions);
}

/**
* Add request on item
* Add request on item and refresh permissions
* @param itemPid - string
*/
addRequest(itemPid: string) {
this._modalService.show(ItemRequestComponent, {

const modalRef = this._modalService.show(ItemRequestComponent, {
initialState: { itemPid }
});
modalRef.content.onSubmit.pipe(first()).subscribe(value => {
this.getPermissions();
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, EventEmitter } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { FormlyFieldConfig } from '@ngx-formly/core';
import { TranslateService } from '@ngx-translate/core';
Expand Down Expand Up @@ -55,6 +55,9 @@ export class ItemRequestComponent implements OnInit {
/** Dynamic message for can_request validator */
canRequestMessage: string;

/** On submit event */
onSubmit: EventEmitter<any> = new EventEmitter();

/**
* Constructor
* @param _modalService - BsModalService
Expand Down Expand Up @@ -100,9 +103,10 @@ export class ItemRequestComponent implements OnInit {
};
this._http.post('/api/item/request', body).subscribe(
() => {
this.onSubmit.next();
this.closeModal();
this._toastr.success(
this._translateService.instant('Your new request has been registered.'),
this._translateService.instant('Request registered.'),
this._translateService.instant('Item Request')
);
},
Expand Down
6 changes: 3 additions & 3 deletions projects/admin/src/app/translate/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"Circulation categories": "Ausleihkategorien",
"Circulation info": "Ausleihinfos",
"Circulation policies": "Ausleihpolitiken",
"Circulation policies do not allow request on this item.": "Circulation policies do not allow request on this item.",
"Circulation settings": "Ausleiheinstellungen",
"City": "Stadt",
"Close": "Geschlossen",
Expand Down Expand Up @@ -224,6 +223,8 @@
"Request": "Bestellung",
"Request date": "Datum der Bestellung",
"Request is possible.": "Request is possible.",
"Request not allowed by the circulation policy.": "Request not allowed by the circulation policy.",
"Request registered.": "Request registered.",
"Requested": "Bestellt",
"Requested by": "Bestellt von",
"Requests": "Bestellungen",
Expand Down Expand Up @@ -274,7 +275,6 @@
"You cannot delete the record for the following reason:": "Aus folgendem Grund können Sie den Datensatz nicht löschen:",
"You cannot delete the record for the following reasons:": "Aus folgenden Gründen können Sie den Datensatz nicht löschen:",
"You do not have sufficient permissions to view this page": "Sie haben keine ausreichenden Berechtigungen, um diese Seite anzuzeigen.",
"Your new request has been registered.": "Your new request has been registered.",
"acq_accounts": "Konten",
"acq_order_lines": "Bestellzeilen",
"acq_orders": "Bestellungen",
Expand Down Expand Up @@ -429,4 +429,4 @@
"year": "Jahr",
"{{ type }} creation failed !": "{{ type }} creation failed !",
"{{ type }} registered": "{{ type }} registered"
}
}
6 changes: 3 additions & 3 deletions projects/admin/src/app/translate/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"Circulation categories": "Circulation categories",
"Circulation info": "Circulation info",
"Circulation policies": "Circulation policies",
"Circulation policies do not allow request on this item.": "Circulation policies do not allow request on this item.",
"Circulation settings": "Circulation settings",
"City": "City",
"Close": "Close",
Expand Down Expand Up @@ -224,6 +223,8 @@
"Request": "Request",
"Request date": "Request date",
"Request is possible.": "Request is possible.",
"Request not allowed by the circulation policy.": "Request not allowed by the circulation policy.",
"Request registered.": "Request registered.",
"Requested": "Requested",
"Requested by": "Requested by",
"Requests": "Requests",
Expand Down Expand Up @@ -274,7 +275,6 @@
"You cannot delete the record for the following reason:": "You cannot delete the record for the following reason:",
"You cannot delete the record for the following reasons:": "You cannot delete the record for the following reasons:",
"You do not have sufficient permissions to view this page": "You do not have sufficient permissions to view this page",
"Your new request has been registered.": "Your new request has been registered.",
"acq_accounts": "accounts",
"acq_order_lines": "order lines",
"acq_orders": "orders",
Expand Down Expand Up @@ -429,4 +429,4 @@
"year": "year",
"{{ type }} creation failed !": "{{ type }} creation failed !",
"{{ type }} registered": "{{ type }} registered"
}
}
6 changes: 3 additions & 3 deletions projects/admin/src/app/translate/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"Circulation categories": "Circulation categories",
"Circulation info": "Circulation info",
"Circulation policies": "Circulation policies",
"Circulation policies do not allow request on this item.": "Circulation policies do not allow request on this item.",
"Circulation settings": "Circulation settings",
"City": "City",
"Close": "Close",
Expand Down Expand Up @@ -224,6 +223,8 @@
"Request": "Request",
"Request date": "Request date",
"Request is possible.": "Request is possible.",
"Request not allowed by the circulation policy.": "Request not allowed by the circulation policy.",
"Request registered.": "Request registered.",
"Requested": "Requested",
"Requested by": "Requested by",
"Requests": "Requests",
Expand Down Expand Up @@ -274,7 +275,6 @@
"You cannot delete the record for the following reason:": "You cannot delete the record for the following reason:",
"You cannot delete the record for the following reasons:": "You cannot delete the record for the following reasons:",
"You do not have sufficient permissions to view this page": "You do not have sufficient permissions to view this page",
"Your new request has been registered.": "Your new request has been registered.",
"acq_accounts": "acq_accounts",
"acq_order_lines": "acq_order_lines",
"acq_orders": "acq_orders",
Expand Down Expand Up @@ -429,4 +429,4 @@
"year": "year",
"{{ type }} creation failed !": "{{ type }} creation failed !",
"{{ type }} registered": "{{ type }} registered"
}
}
6 changes: 3 additions & 3 deletions projects/admin/src/app/translate/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"Circulation categories": "Categoría de préstamo",
"Circulation info": "Información de préstamo",
"Circulation policies": "Políticas de circulación",
"Circulation policies do not allow request on this item.": "Circulation policies do not allow request on this item.",
"Circulation settings": "Parámetros de circulación",
"City": "Ciudad",
"Close": "Cerrar",
Expand Down Expand Up @@ -224,6 +223,8 @@
"Request": "Reservar",
"Request date": "Fecha de reservación",
"Request is possible.": "Request is possible.",
"Request not allowed by the circulation policy.": "Request not allowed by the circulation policy.",
"Request registered.": "Request registered.",
"Requested": "Reservado",
"Requested by": "Reservado por",
"Requests": "Reservaciones",
Expand Down Expand Up @@ -274,7 +275,6 @@
"You cannot delete the record for the following reason:": "No puede suprimir el recurso para la razón siguiente:",
"You cannot delete the record for the following reasons:": "No puede suprimir el recurso para las razones siguientes:",
"You do not have sufficient permissions to view this page": "No tiene suficientes permisos para ver esta página",
"Your new request has been registered.": "Your new request has been registered.",
"acq_accounts": "cuentas",
"acq_order_lines": "líneas de pedido",
"acq_orders": "pedidos",
Expand Down Expand Up @@ -429,4 +429,4 @@
"year": "año",
"{{ type }} creation failed !": "{{ type }} creation failed !",
"{{ type }} registered": "{{ type }} registered"
}
}
6 changes: 3 additions & 3 deletions projects/admin/src/app/translate/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"Circulation categories": "Catégories de circulation",
"Circulation info": "Infos de prêt",
"Circulation policies": "Politiques de prêt",
"Circulation policies do not allow request on this item.": "Circulation policies do not allow request on this item.",
"Circulation settings": "Circulation settings",
"City": "Ville",
"Close": "Fermé",
Expand Down Expand Up @@ -224,6 +223,8 @@
"Request": "Demande",
"Request date": "Date de la demande",
"Request is possible.": "Request is possible.",
"Request not allowed by the circulation policy.": "Request not allowed by the circulation policy.",
"Request registered.": "Request registered.",
"Requested": "Demandé",
"Requested by": "Demandé par",
"Requests": "Demandes",
Expand Down Expand Up @@ -274,7 +275,6 @@
"You cannot delete the record for the following reason:": "Vous ne pouvez pas supprimer l'enregistrement pour la raison suivante : ",
"You cannot delete the record for the following reasons:": "Vous ne pouvez pas supprimer l'enregistrement pour les raisons suivantes : ",
"You do not have sufficient permissions to view this page": "Vous n'avez pas suffisamment de permissions pour voir cette page",
"Your new request has been registered.": "Your new request has been registered.",
"acq_accounts": "comptes",
"acq_order_lines": "lignes de commande",
"acq_orders": "commandes",
Expand Down Expand Up @@ -429,4 +429,4 @@
"year": "année",
"{{ type }} creation failed !": "{{ type }} creation failed !",
"{{ type }} registered": "{{ type }} registered"
}
}
6 changes: 3 additions & 3 deletions projects/admin/src/app/translate/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"Circulation categories": "Categorie di prestito",
"Circulation info": "Circulation info",
"Circulation policies": "Politiche di prestito",
"Circulation policies do not allow request on this item.": "Circulation policies do not allow request on this item.",
"Circulation settings": "Impostazioni per il prestito",
"City": "Città",
"Close": "Chiuso",
Expand Down Expand Up @@ -224,6 +223,8 @@
"Request": "Request",
"Request date": "Data della richiesta",
"Request is possible.": "Request is possible.",
"Request not allowed by the circulation policy.": "Request not allowed by the circulation policy.",
"Request registered.": "Request registered.",
"Requested": "Requested",
"Requested by": "Richiesto da",
"Requests": "Richieste",
Expand Down Expand Up @@ -274,7 +275,6 @@
"You cannot delete the record for the following reason:": "Non è possibile eliminare il record per il seguente motivo:",
"You cannot delete the record for the following reasons:": "Non è possibile eliminare il record per il seguente motivo:",
"You do not have sufficient permissions to view this page": "You do not have sufficient permissions to view this page",
"Your new request has been registered.": "Your new request has been registered.",
"acq_accounts": "acq_accounts",
"acq_order_lines": "acq_order_lines",
"acq_orders": "acq_orders",
Expand Down Expand Up @@ -429,4 +429,4 @@
"year": "anno",
"{{ type }} creation failed !": "{{ type }} creation failed !",
"{{ type }} registered": "{{ type }} registered"
}
}
2 changes: 1 addition & 1 deletion projects/admin/src/manual_translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ _('tableOfContents');
_('fullText');
_('video');
// Item Request messages
_('Circulation policies do not allow request on this item.');
_('Request not allowed by the circulation policy.');
_('Item is already checked-out or requested by patron.');
_('Item not found.');
_('Item status does not allow requests.');
Expand Down

0 comments on commit dd85314

Please sign in to comment.