-
Notifications
You must be signed in to change notification settings - Fork 12
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
resource: check permissions on detail view #37
Conversation
Warning, when this PR will be merged, canUpdate and canAdd checks have to return an observable in rero-ils-ui instead of a value directly. |
projects/ng-core-tester/src/app/record/document/detail/detail.component.html
Outdated
Show resolved
Hide resolved
<a href="javascript:void(0);" class="btn btn-sm btn-secondary" routerLink="../../edit/{{ record.metadata.pid }}"> | ||
<div class="col-3 text-right" *ngIf="record"> | ||
<a href class="btn btn-sm btn-primary" | ||
routerLink="../../edit/{{ record.metadata.pid }}" *ngIf="canUpdateResult"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
canUpdateResult.can
? or better canUpdateResult && canUpdateResult.can
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
canUpdateResult is not an object, but directly resolved as a boolean. It's different in regard to canDeleteResult because the latter returns an object with the boolean and eventually a message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I saw your comment later on, which is relevent. Il will create an interface ActionStatus which returns always an object for all actions
</div> | ||
</div> | ||
<hr class="my-4"> | ||
<a href="#" (click)="goBack($event)">« {{ 'Back' | translate }}</a> | ||
<a href="#" (click)="goBack($event)">« {{ 'Back' | translate }}</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of href
you can use routerLink=""
or type="button"
or use button
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I converted link to button when there's no link to follow, but an action on click
/** | ||
* Record can be updated ? | ||
*/ | ||
canUpdateResult = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we uniformize by returning a ActionStatus
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
* @param message - message to display into modal | ||
*/ | ||
public showDeleteMessage(event: Event, message: string) { | ||
event.preventDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it really required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's required when a link is clicked. I converted links to buttons.
|
||
@Component({ | ||
template: ` | ||
<h1>Record of type "{{ type }}" #{{ record.metadata.pid }}</h1> | ||
{{ record|json }} | ||
<div *ngIf="record"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ng-container
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -79,6 +79,7 @@ export class MainFieldsManagerComponent implements OnInit { | |||
// disable FormControls for hidden fields | |||
for (const fieldSet of Object.values(this.layoutRefField)) { | |||
if (this.isHidden(fieldSet)) { | |||
/* tslint:disable:no-string-literal */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this and use: fieldSet.items
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ignoreBackdropClick: true, | ||
initialState: { | ||
title: this.translate.instant('Confirmation'), | ||
body: this.translate.instant('Do you really want to delete this record ?'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
record ?
=> record?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
/** | ||
* Delete a record by its PID. | ||
* @param pid - string, PID to delete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@param type
is missing, you can also add @returns
see: https://jsdoc.app/tags-returns.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, but the @returns must be set to all functions/methods in project
* Checks permissions for deleting or updating a resource on detail view. * Returns an observable for getting the record instead of the record data directly. * Converts returns of functions canAdd and canEdit into observable. * Creates a service for managing records in user interface. * Fixes issue #2 Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch> Co-Authored-by: Sébastien Délèze <sebastien.deleze@rero.ch>
Co-Authored-by: Bertrand Zuchuat bertrand.zuchuat@rero.ch
Co-Authored-by: Sébastien Délèze sebastien.deleze@rero.ch