-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
permissions: refactoring permissions usage
Updates way how permissions are used. Instead to use permissions returned by a search query, use permissions provided by the backend permission API (`/api/permissions/<type>/<pid>`). After these changes, we could refactor the backend SearchSerializer to remove permissions and speed up search query results. This commit also updates button and functionalities according to the UX chart. * Closes rero/rero-ils#819 * Closes rero/rero-ils#932 Co-authored-by : Renaud Michotte <[email protected]>
- Loading branch information
Showing
20 changed files
with
349 additions
and
451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...etail-view/acquisition-order-detail-view/order-lines/order-line/order-line.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!-- | ||
RERO ILS UI | ||
Copyright (C) 2019 RERO | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, version 3 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
<ng-container *ngIf="orderLine && permissions else loading"> | ||
<div class="row p-2 mb-1 border rounded align-middle"> | ||
<!-- DOCUMENT --> | ||
<ng-container *ngIf="orderLine.metadata.document.pid | getRecord: 'documents' | async as document"> | ||
<div class="col-sm-3"> | ||
<a [routerLink]="['/records', 'documents', 'detail', document.metadata.pid]" | ||
*ngIf="document.metadata.title | mainTitle as title"> | ||
{{ title | truncateText }} | ||
</a> | ||
</div> | ||
</ng-container> | ||
<!-- AMOUNT --> | ||
<div class="col-sm-2"> | ||
{{ orderLine.metadata.amount | currency:order.metadata.currency:'symbol' }} | ||
</div> | ||
<!-- QUANTITY --> | ||
<div class="col-sm-1"> | ||
{{ orderLine.metadata.quantity }} | ||
</div> | ||
<!-- DISCOUNT_AMOUNT --> | ||
<div class="col-sm-2"> | ||
{{ orderLine.metadata.discount_amount | currency:order.metadata.currency:'symbol' }} | ||
</div> | ||
<!-- TOTAL_AMOUNT --> | ||
<div class="col-sm-2"> | ||
{{ orderLine.metadata.total_amount | currency:order.metadata.currency:'symbol' }} | ||
</div> | ||
<!-- ACTIONS --> | ||
<div class="col-sm-2 p-0 text-right"> | ||
<button type="button" class="btn btn-sm btn-outline-primary mr-1" | ||
[routerLink]="['/records', 'acq_order_lines', 'detail', orderLine.metadata.pid]"> | ||
<i class="fa fa-eye"></i> | ||
</button> | ||
<button *ngIf="permissions.update.can" type="button" class="btn btn-outline-primary btn-sm mr-1" | ||
[routerLink]="['/records', 'acq_order_lines', 'edit', orderLine.metadata.pid]"> | ||
<i class="fa fa-pencil"></i> | ||
</button> | ||
|
||
<button *ngIf="this.permissions.delete.can; else deleteInfo" | ||
type="button" class="btn btn-outline-danger btn-sm" | ||
title="{{ 'Delete' | translate}}" | ||
(click)="delete(orderLine.metadata.pid)"> | ||
<i class="fa fa-trash" ></i> | ||
</button> | ||
<ng-template #deleteInfo> | ||
<button type="button" class="btn btn-sm btn-outline-danger disabled" | ||
title="{{ 'Delete' | translate}}" | ||
[popover]="tolTemplate" triggers="mouseenter:mouseleave"> | ||
<i class="fa fa-trash"></i> | ||
</button> | ||
<ng-template #tolTemplate><div [innerHtml]="deleteInfoMessage | nl2br"></div></ng-template> | ||
</ng-template> | ||
</div> | ||
</div> | ||
</ng-container> | ||
<ng-template #loading> | ||
<i class="fa fa-spin fa-spinner"></i> | ||
</ng-template> |
72 changes: 72 additions & 0 deletions
72
.../detail-view/acquisition-order-detail-view/order-lines/order-line/order-line.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* RERO ILS UI | ||
* Copyright (C) 2019 RERO | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | ||
import { RecordPermissionService } from 'projects/admin/src/app/service/record-permission.service'; | ||
|
||
@Component({ | ||
selector: 'admin-order-line', | ||
templateUrl: './order-line.component.html', | ||
styles: [] | ||
}) | ||
export class OrderLineComponent implements OnInit { | ||
|
||
/** order line */ | ||
@Input() orderLine: any; | ||
|
||
/** parent order */ | ||
@Input() order: any; | ||
|
||
/** order line permission */ | ||
permissions: any; | ||
|
||
/** Event for delete order line */ | ||
@Output() deleteOrderLine = new EventEmitter(); | ||
|
||
/** | ||
* Constructor | ||
* @param _recordPermissionService - RecordPermissionService | ||
*/ | ||
constructor( | ||
private _recordPermissionService: RecordPermissionService | ||
) { } | ||
|
||
/** | ||
* On init hook | ||
*/ | ||
ngOnInit() { | ||
this._recordPermissionService.getPermission('acq_order_lines', this.orderLine.metadata.pid).subscribe( | ||
(permissions) => this.permissions = permissions | ||
); | ||
} | ||
|
||
/** | ||
* Delete order line | ||
* @param orderLinePid - AcqOrderLine pid | ||
*/ | ||
delete(orderLinePid: string) { | ||
this.deleteOrderLine.emit(orderLinePid); | ||
} | ||
|
||
/** | ||
* Return a message containing the reasons wht the item cannot be requested | ||
* @return the message to display into the tooltip box | ||
*/ | ||
get deleteInfoMessage(): string { | ||
return this._recordPermissionService.generateDeleteMessage(this.permissions.delete.reasons); | ||
} | ||
|
||
} |
Oops, something went wrong.