Migrate frontend prefix to -pngx

This commit is contained in:
shamoon
2023-09-14 14:03:28 -07:00
parent 6c4040d9fd
commit 6cbf30991d
111 changed files with 373 additions and 371 deletions

View File

@@ -7,7 +7,7 @@ import { PermissionsService } from '../services/permissions.service'
template: `
<div>
<button
*appIfObjectPermissions="{
*pngxIfObjectPermissions="{
object: { id: 2, owner: user1 },
action: 'view'
}"

View File

@@ -14,12 +14,12 @@ import {
} from '../services/permissions.service'
@Directive({
selector: '[appIfObjectPermissions]',
selector: '[pngxIfObjectPermissions]',
})
export class IfObjectPermissionsDirective implements OnInit, OnChanges {
// The role the user must have
@Input()
appIfObjectPermissions: {
pngxIfObjectPermissions: {
object: ObjectWithPermissions
action: PermissionAction
}
@@ -39,10 +39,10 @@ export class IfObjectPermissionsDirective implements OnInit, OnChanges {
public ngOnInit(): void {
if (
!this.appIfObjectPermissions?.object ||
!this.pngxIfObjectPermissions?.object ||
this.permissionsService.currentUserHasObjectPermissions(
this.appIfObjectPermissions.action,
this.appIfObjectPermissions.object
this.pngxIfObjectPermissions.action,
this.pngxIfObjectPermissions.object
)
) {
if (!this.createdView)

View File

@@ -6,7 +6,7 @@ import { PermissionsService } from '../services/permissions.service'
@Component({
template: `
<div>
<button *appIfOwner="{ id: 2, owner: user1 }">Some Text</button>
<button *pngxIfOwner="{ id: 2, owner: user1 }">Some Text</button>
</div>
`,
})

View File

@@ -11,12 +11,12 @@ import { ObjectWithPermissions } from '../data/object-with-permissions'
import { PermissionsService } from '../services/permissions.service'
@Directive({
selector: '[appIfOwner]',
selector: '[pngxIfOwner]',
})
export class IfOwnerDirective implements OnInit, OnChanges {
// The role the user must have
@Input()
appIfOwner: ObjectWithPermissions
pngxIfOwner: ObjectWithPermissions
createdView: EmbeddedViewRef<any>
@@ -32,7 +32,7 @@ export class IfOwnerDirective implements OnInit, OnChanges {
) {}
public ngOnInit(): void {
if (this.permissionsService.currentUserOwnsObject(this.appIfOwner)) {
if (this.permissionsService.currentUserOwnsObject(this.pngxIfOwner)) {
if (!this.createdView)
this.createdView = this.viewContainerRef.createEmbeddedView(
this.templateRef

View File

@@ -6,7 +6,7 @@ import { PermissionsService } from '../services/permissions.service'
@Component({
template: `
<div>
<button *appIfPermissions="{ action: 'add', type: '%s_user' }">
<button *pngxIfPermissions="{ action: 'add', type: '%s_user' }">
Some Text
</button>
</div>

View File

@@ -12,11 +12,11 @@ import {
} from '../services/permissions.service'
@Directive({
selector: '[appIfPermissions]',
selector: '[pngxIfPermissions]',
})
export class IfPermissionsDirective implements OnInit {
@Input()
appIfPermissions:
pngxIfPermissions:
| Array<{ action: PermissionAction; type: PermissionType }>
| { action: PermissionAction; type: PermissionType }
@@ -34,7 +34,7 @@ export class IfPermissionsDirective implements OnInit {
public ngOnInit(): void {
if (
[]
.concat(this.appIfPermissions)
.concat(this.pngxIfPermissions)
.every((perm: { action: PermissionAction; type: PermissionType }) =>
this.permissionsService.currentUserCan(perm.action, perm.type)
)

View File

@@ -8,10 +8,10 @@ import { By } from '@angular/platform-browser'
<table class="table">
<thead>
<th></th>
<th class="d-none d-lg-table-cell" appSortable="archive_serial_number">
<th class="d-none d-lg-table-cell" pngxSortable="archive_serial_number">
ASN
</th>
<th class="d-none d-md-table-cell" appSortable="correspondent__name">
<th class="d-none d-md-table-cell" pngxSortable="correspondent__name">
Correspondent
</th>
</thead>

View File

@@ -13,13 +13,13 @@ export interface SortEvent {
}
@Directive({
selector: 'th[appSortable]',
selector: 'th[pngxSortable]',
})
export class SortableDirective {
constructor() {}
@Input()
appSortable: string = ''
pngxSortable: string = ''
@Input()
currentSortReverse: boolean = false
@@ -31,18 +31,20 @@ export class SortableDirective {
@HostBinding('class.asc') get asc() {
return (
this.currentSortField === this.appSortable && !this.currentSortReverse
this.currentSortField === this.pngxSortable && !this.currentSortReverse
)
}
@HostBinding('class.des') get des() {
return this.currentSortField === this.appSortable && this.currentSortReverse
return (
this.currentSortField === this.pngxSortable && this.currentSortReverse
)
}
@HostListener('click') rotate() {
if (this.currentSortField != this.appSortable) {
this.sort.emit({ column: this.appSortable, reverse: false })
if (this.currentSortField != this.pngxSortable) {
this.sort.emit({ column: this.pngxSortable, reverse: false })
} else if (
this.currentSortField == this.appSortable &&
this.currentSortField == this.pngxSortable &&
!this.currentSortReverse
) {
this.sort.emit({ column: this.currentSortField, reverse: true })