Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

item: hide action button on item if the user is not in the same library #137

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,23 @@
{{ item.metadata.call_number }}
</div>
<div class="col-sm-4 text-right">
<button *ngIf="!item.permissions.cannot_update" type="button" class="btn btn-primary btn-sm"
[routerLink]="['/records', 'items', 'edit', item.metadata.pid]">
<i class="fa fa-pencil"></i> {{ 'Edit' | translate }}
</button>
<ng-container *ngIf="isAvailableActions; else noactions">
<button *ngIf="!item.permissions.cannot_update" type="button" class="btn btn-primary btn-sm"
[routerLink]="['/records', 'items', 'edit', item.metadata.pid]">
<i class="fa fa-pencil"></i> {{ 'Edit' | translate }}
</button>

<button *ngIf="!item.permissions.cannot_delete; else notDelete" type="button" class="btn btn-primary btn-sm ml-1"
(click)="delete(item.metadata.pid)">
<i class="fa fa-trash"></i> {{ 'Delete' | translate }}
</button>
<ng-template #notDelete>
<button type="button" class="btn btn-dark btn-sm ml-1" (click)="showDeleteMessage(item)">
<button *ngIf="!item.permissions.cannot_delete; else notDelete" type="button" class="btn btn-primary btn-sm ml-1"
(click)="delete(item.metadata.pid)">
<i class="fa fa-trash"></i> {{ 'Delete' | translate }}
</button>
<ng-template #notDelete>
<button type="button" class="btn btn-dark btn-sm ml-1" (click)="showDeleteMessage(item)">
<i class="fa fa-trash"></i> {{ 'Delete' | translate }}
</button>
</ng-template>
</ng-container>
<ng-template #noactions>
&nbsp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is necessary ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't put a space in the div tag, no space is effective.

</ng-template>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { RecordUiService } from '@rero/ng-core';
import { RecordPermissionMessageService } from 'projects/admin/src/app/service/record-permission-message.service';
import { UserService } from 'projects/admin/src/app/service/user.service';

@Component({
selector: 'admin-holding-item',
Expand All @@ -26,20 +27,30 @@ import { RecordPermissionMessageService } from 'projects/admin/src/app/service/r
})
export class HoldingItemComponent {

/** Holding record */
@Input() holding: any;

/** Item Record */
@Input() item: any;

/** Event for delete Item */
@Output() deleteItem = new EventEmitter();

/** Availables action */
get isAvailableActions() {
return this.userService.getCurrentUser().currentLibrary
= this.holding.metadata.library.pid;
}

/**
* Constructor
* @param recordUiService - RecordUiService
* @param recordPermissionMessage - RecordPermissionMessageService
*/
constructor(
private recordUiService: RecordUiService,
private recordPermissionMessage: RecordPermissionMessageService
private recordPermissionMessage: RecordPermissionMessageService,
private userService: UserService
) { }

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@
</ul>
</div>
<ng-container *ngIf="items && items.length > 0">
<admin-holding-item class="row mt-1" *ngFor="let item of items" [item]="item" (deleteItem)="deleteItem($event)">
<admin-holding-item
*ngFor="let item of items"
class="row mt-1"
[holding]="holding"
[item]="item"
(deleteItem)="deleteItem($event)">
</admin-holding-item>
</ng-container>
</div>
Expand Down