Skip to content

Commit

Permalink
fix: permission handling in components
Browse files Browse the repository at this point in the history
  • Loading branch information
StephGit committed Sep 3, 2024
1 parent 696b890 commit 9605ba5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1>Property Types</h1>
<b>Property Types</b>
</div>
<div class="col-sm">
@if (canAdd) {
@if (canAdd()) {
<button type="button" class="btn btn-primary float-end" (click)="addModal()" [attr.data-cy]="'button-add'">
<app-icon icon="plus-circle"></app-icon>
Add property type
Expand All @@ -34,29 +34,31 @@ <h1>Property Types</h1>
@for (property of propertyTypes(); track property.id) {
<tr>
<td class="align-middle">{{ property.name }}</td>
<td class="align-middle">{{ property.encrypted ? 'Yes' : 'No' }}</td>
<td class="align-middle">{{ property.validationRegex }}</td>
<td class="align-middle">
<div>
@for (tag of property.propertyTags; track tag.name) {
<span class="badge bg-light text-dark rounded-pill">{{tag.name}}</span>
@if (canDisplay()) {
<td class="align-middle">{{ property.encrypted ? 'Yes' : 'No' }}</td>
<td class="align-middle">{{ property.validationRegex }}</td>
<td class="align-middle">
<div>
@for (tag of property.propertyTags; track tag.name) {
<span class="badge bg-light text-dark rounded-pill">{{tag.name}}</span>
}
</div>
</td>
<td class="text-center">
@if (canEditName()) {
<button class="btn btn-sm btn-primary me-0" (click)="editModal(property)" [attr.data-cy]="'edit-' + property.name">
<app-icon icon="pencil"></app-icon>
</button>
}
</div>
</td>
<td class="text-center">
@if (canEditName) {
<button class="btn btn-sm btn-primary me-0" (click)="editModal(property)" [attr.data-cy]="'edit-' + property.name">
<app-icon icon="pencil"></app-icon>
</button>
}
</td>
<td class="text-center">
@if (canDelete) {
<button class="btn btn-sm btn-danger me-0" (click)="deleteModal(property)" [attr.data-cy]="'delete-' + property.name">
<app-icon icon="trash"></app-icon>
</button>
}
</td>
</td>
<td class="text-center">
@if (canDelete()) {
<button class="btn btn-sm btn-danger me-0" (click)="deleteModal(property)" [attr.data-cy]="'delete-' + property.name">
<app-icon icon="trash"></app-icon>
</button>
}
</td>
}
</tr>
}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,18 @@ export class PropertyTypesComponent {

save(propertyType: PropertyType) {
this.isLoading = true;
this.propertyTypeService
.save(propertyType)
.pipe(takeUntil(this.destroy$))
.subscribe({
next: (r) => this.toastService.success(`${this.PROPERTY_TYPE} saved.`),
error: (e) => this.error.set(e),
complete: () => {
this.propertyTypeService.reload();
},
});
if (this.canSave() && this.canEditValidation && this.canEditName) {
this.propertyTypeService
.save(propertyType)
.pipe(takeUntil(this.destroy$))
.subscribe({
next: (r) => this.toastService.success(`${this.PROPERTY_TYPE} saved.`),
error: (e) => this.error.set(e),
complete: () => {
this.propertyTypeService.reload();
},
});
}
this.isLoading = false;
}

Expand Down

0 comments on commit 9605ba5

Please sign in to comment.