|
|
@ -7,6 +7,7 @@ import { |
|
|
getLowercase, |
|
|
getLowercase, |
|
|
isSystemTag |
|
|
isSystemTag |
|
|
} from '@ghostfolio/common/helper'; |
|
|
} from '@ghostfolio/common/helper'; |
|
|
|
|
|
import { TagWithAccountAndActivityCount } from '@ghostfolio/common/types'; |
|
|
import { translate } from '@ghostfolio/ui/i18n'; |
|
|
import { translate } from '@ghostfolio/ui/i18n'; |
|
|
import { NotificationService } from '@ghostfolio/ui/notifications'; |
|
|
import { NotificationService } from '@ghostfolio/ui/notifications'; |
|
|
import { DataService } from '@ghostfolio/ui/services'; |
|
|
import { DataService } from '@ghostfolio/ui/services'; |
|
|
@ -32,7 +33,6 @@ import { MatSort, MatSortModule } from '@angular/material/sort'; |
|
|
import { MatTableDataSource, MatTableModule } from '@angular/material/table'; |
|
|
import { MatTableDataSource, MatTableModule } from '@angular/material/table'; |
|
|
import { ActivatedRoute, Router, RouterModule } from '@angular/router'; |
|
|
import { ActivatedRoute, Router, RouterModule } from '@angular/router'; |
|
|
import { IonIcon } from '@ionic/angular/standalone'; |
|
|
import { IonIcon } from '@ionic/angular/standalone'; |
|
|
import { Tag } from '@prisma/client'; |
|
|
|
|
|
import { addIcons } from 'ionicons'; |
|
|
import { addIcons } from 'ionicons'; |
|
|
import { |
|
|
import { |
|
|
createOutline, |
|
|
createOutline, |
|
|
@ -63,17 +63,20 @@ import { CreateOrUpdateTagDialogParams } from './create-or-update-tag-dialog/int |
|
|
export class GfAdminTagComponent implements OnInit { |
|
|
export class GfAdminTagComponent implements OnInit { |
|
|
public readonly locale = input(getLocale()); |
|
|
public readonly locale = input(getLocale()); |
|
|
|
|
|
|
|
|
protected dataSource = new MatTableDataSource<Tag>(); |
|
|
protected dataSource = |
|
|
|
|
|
new MatTableDataSource<TagWithAccountAndActivityCount>(); |
|
|
|
|
|
|
|
|
protected readonly displayedColumns = [ |
|
|
protected readonly displayedColumns = [ |
|
|
'name', |
|
|
'name', |
|
|
'userId', |
|
|
'userId', |
|
|
'accounts', |
|
|
'accounts', |
|
|
'activities', |
|
|
'activities', |
|
|
|
|
|
'total', |
|
|
'actions' |
|
|
'actions' |
|
|
]; |
|
|
]; |
|
|
protected readonly isSystemTag = isSystemTag; |
|
|
protected readonly isSystemTag = isSystemTag; |
|
|
protected readonly pageSize = DEFAULT_PAGE_SIZE; |
|
|
protected readonly pageSize = DEFAULT_PAGE_SIZE; |
|
|
protected tags: Tag[]; |
|
|
protected tags: TagWithAccountAndActivityCount[]; |
|
|
protected readonly translate = translate; |
|
|
protected readonly translate = translate; |
|
|
|
|
|
|
|
|
private readonly deviceType = computed( |
|
|
private readonly deviceType = computed( |
|
|
@ -120,6 +123,13 @@ export class GfAdminTagComponent implements OnInit { |
|
|
this.fetchTags(); |
|
|
this.fetchTags(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected getTotalCount({ |
|
|
|
|
|
accountCount, |
|
|
|
|
|
activityCount |
|
|
|
|
|
}: TagWithAccountAndActivityCount) { |
|
|
|
|
|
return accountCount + activityCount; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
protected onDeleteTag(aId: string) { |
|
|
protected onDeleteTag(aId: string) { |
|
|
this.notificationService.confirm({ |
|
|
this.notificationService.confirm({ |
|
|
confirmFn: () => { |
|
|
confirmFn: () => { |
|
|
@ -130,7 +140,7 @@ export class GfAdminTagComponent implements OnInit { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected onUpdateTag({ id }: Tag) { |
|
|
protected onUpdateTag({ id }: TagWithAccountAndActivityCount) { |
|
|
this.router.navigate([], { |
|
|
this.router.navigate([], { |
|
|
queryParams: { editTagDialog: true, tagId: id } |
|
|
queryParams: { editTagDialog: true, tagId: id } |
|
|
}); |
|
|
}); |
|
|
@ -164,9 +174,13 @@ export class GfAdminTagComponent implements OnInit { |
|
|
this.dataSource.sort = this.sort(); |
|
|
this.dataSource.sort = this.sort(); |
|
|
|
|
|
|
|
|
this.dataSource.sortingDataAccessor = (tag, path) => { |
|
|
this.dataSource.sortingDataAccessor = (tag, path) => { |
|
|
return path === 'name' |
|
|
if (path === 'name') { |
|
|
? translate(tag.name).toLocaleLowerCase() |
|
|
return translate(tag.name).toLocaleLowerCase(); |
|
|
: (getLowercase(tag, path) as number | string); |
|
|
} else if (path === 'totalCount') { |
|
|
|
|
|
return this.getTotalCount(tag); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return getLowercase(tag, path) as number | string; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
this.dataService.updateInfo(); |
|
|
this.dataService.updateInfo(); |
|
|
|