Skip to content
Open
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
187 changes: 2 additions & 185 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ <h1 class="title is-2 has-text-weight-light">
></a>
<a
class="button is-light is-small is-circle"
(click)="toggleDeleteModal(item)"
[ngClass]="{ 'is-invisible': isCurrentUser(item) }"
[attr.aria-disabled]="isCurrentUser(item) ? true : null"
[attr.tabindex]="isCurrentUser(item) ? -1 : 0"
(click)="!isCurrentUser(item) && toggleDeleteModal(item)"
><i class="icon icon-trash-2"></i
></a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { ManifestService } from '../../../shared/services/manifest.service'
import { CrudService } from '../../services/crud.service'
import { MetaService } from '../../../shared/services/meta.service'
import { CapitalizeFirstLetterPipe } from '../../../shared/pipes/capitalize-first-letter.pipe'
import { AuthService } from '../../../auth/auth.service'
import { Admin } from '../../../../typescript/interfaces/admin.interface'

@Component({
selector: 'app-list',
Expand All @@ -27,6 +29,7 @@ export class ListComponent implements OnInit {

entityManifest: EntityManifest
properties: PropertyManifest[]
currentUser: Admin | null = null

queryParams: Params
PropType = PropType
Expand All @@ -38,10 +41,14 @@ export class ListComponent implements OnInit {
private activatedRoute: ActivatedRoute,
private metaService: MetaService,
private flashMessageService: FlashMessageService,
private renderer: Renderer2
private renderer: Renderer2,
private authService: AuthService
) {}

ngOnInit(): void {
// Load current user
this.currentUser = this.authService.getCurrentUserValue()

combineLatest([
this.activatedRoute.queryParams,
this.activatedRoute.params
Expand Down Expand Up @@ -79,7 +86,7 @@ export class ListComponent implements OnInit {
.filter((r) => r.type !== 'many-to-many' || r.owningSide)
.map((relation: RelationshipManifest) => relation.name)
})
.catch(() => {
.catch((): null => {
this.loadingPaginator = false
return null
})
Expand Down Expand Up @@ -139,4 +146,25 @@ export class ListComponent implements OnInit {
this.renderer.addClass(document.querySelector('html'), 'is-clipped')
}
}

/**
* Check if the given item is the current logged-in admin user
* Only applies to admin entities, returns false for other entity types
*
* @param item The item to check
*
* @returns true if the item is the current admin user, false otherwise
*/
isCurrentUser(item: any): boolean {
if (!this.currentUser || !item || !this.entityManifest) {
return false
}

// Only check for admin self-deletion when viewing admins
if (this.entityManifest.slug !== 'admins') {
return false
}

return this.currentUser.email === item.email
}
}