Browse Source

Refactoring

pull/5566/head
Thomas Kaul 4 weeks ago
parent
commit
0760abc428
  1. 5
      apps/api/src/app/access/access.controller.ts
  2. 6
      apps/client/src/app/components/access-table/access-table.component.html
  3. 6
      apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.component.ts
  4. 18
      apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.html
  5. 21
      apps/client/src/app/components/user-account-access/user-account-access.component.ts

5
apps/api/src/app/access/access.controller.ts

@ -41,10 +41,7 @@ export class AccessController {
include: {
granteeUser: true
},
orderBy: [
{ granteeUserId: 'desc' }, // NULL values first (public access), then user IDs
{ createdAt: 'asc' } // Within each group, order by creation time
],
orderBy: [{ granteeUserId: 'desc' }, { createdAt: 'asc' }],
where: { userId: this.request.user.id }
});

6
apps/client/src/app/components/access-table/access-table.component.html

@ -72,7 +72,6 @@
<span i18n>Edit</span>
</span>
</button>
<hr class="my-0" />
}
@if (element.type === 'PUBLIC') {
<button mat-menu-item (click)="onCopyUrlToClipboard(element.id)">
@ -82,6 +81,11 @@
</span>
</button>
}
@if (
user?.settings?.isExperimentalFeatures || element.type === 'PUBLIC'
) {
<hr class="my-0" />
}
<button mat-menu-item (click)="onDeleteAccess(element.id)">
<span class="align-items-center d-flex">
<ion-icon class="mr-2" name="remove-circle-outline" />

6
apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.component.ts

@ -107,10 +107,10 @@ export class GfCreateOrUpdateAccessDialogComponent
}
public async onSubmit() {
if (this.mode === 'update') {
await this.updateAccess();
} else {
if (this.mode === 'create') {
await this.createAccess();
} else {
await this.updateAccess();
}
}

18
apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.html

@ -5,10 +5,10 @@
(ngSubmit)="onSubmit()"
>
<h1 mat-dialog-title>
@if (mode === 'update') {
<span i18n>Edit access</span>
} @else {
@if (mode === 'create') {
<span i18n>Grant access</span>
} @else {
<span i18n>Edit access</span>
}
</h1>
<div class="flex-grow-1 py-3" mat-dialog-content>
@ -73,15 +73,15 @@
mat-flat-button
type="submit"
[disabled]="
mode === 'update'
? !accessForm.valid
: !(accessForm.dirty && accessForm.valid)
mode === 'create'
? !(accessForm.dirty && accessForm.valid)
: !accessForm.valid
"
>
@if (mode === 'update') {
<ng-container i18n>Update</ng-container>
} @else {
@if (mode === 'create') {
<ng-container i18n>Save</ng-container>
} @else {
<ng-container i18n>Update</ng-container>
}
</button>
</div>

21
apps/client/src/app/components/user-account-access/user-account-access.component.ts

@ -209,27 +209,24 @@ export class GfUserAccountAccessComponent implements OnDestroy, OnInit {
}
private openUpdateAccessDialog(accessId: string) {
// Find the access details in the already loaded data
const accessDetails = this.accessesGive.find(({ id }) => {
const access = this.accessesGive?.find(({ id }) => {
return id === accessId;
});
if (!accessDetails) {
this.notificationService.alert({
title: $localize`Oops! Could not find access details.`
});
if (!access) {
console.log('Could not find access.');
return;
}
const dialogRef = this.dialog.open(GfCreateOrUpdateAccessDialogComponent, {
data: {
access: {
alias: accessDetails.alias,
id: accessDetails.id,
grantee:
accessDetails.grantee === 'Public' ? null : accessDetails.grantee,
permissions: accessDetails.permissions,
type: accessDetails.type
alias: access.alias,
id: access.id,
grantee: access.grantee === 'Public' ? null : access.grantee,
permissions: access.permissions,
type: access.type
}
},
height: this.deviceType === 'mobile' ? '98vh' : undefined,

Loading…
Cancel
Save