Browse Source

Allow deletion of Asset Tags

pull/5027/head
Dan 8 months ago
parent
commit
77061c284c
  1. 3
      apps/api/src/app/admin/admin.controller.ts
  2. 4
      apps/api/src/app/admin/update-asset-profile.dto.ts
  3. 7
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
  4. 2
      apps/client/src/app/services/admin.service.ts

3
apps/api/src/app/admin/admin.controller.ts

@ -371,7 +371,8 @@ export class AdminController {
tags: { tags: {
connect: assetProfileData.tags?.map(({ id }) => { connect: assetProfileData.tags?.map(({ id }) => {
return { id }; return { id };
}) }),
disconnect: assetProfileData.tagsDisconnected?.map(({ id }) => ({ id }))
} }
}); });
} }

4
apps/api/src/app/admin/update-asset-profile.dto.ts

@ -39,6 +39,10 @@ export class UpdateAssetProfileDto {
@IsOptional() @IsOptional()
tags?: Tag[]; tags?: Tag[];
@IsArray()
@IsOptional()
tagsDisconnected?: Tag[];
@IsObject() @IsObject()
@IsOptional() @IsOptional()
scraperConfiguration?: Prisma.InputJsonObject; scraperConfiguration?: Prisma.InputJsonObject;

7
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts

@ -71,6 +71,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
}), }),
name: ['', Validators.required], name: ['', Validators.required],
tags: new FormControl<Tag[]>(undefined), tags: new FormControl<Tag[]>(undefined),
tagsDisconnected: new FormControl<Tag[]>(undefined),
scraperConfiguration: '', scraperConfiguration: '',
sectors: '', sectors: '',
symbolMapping: '', symbolMapping: '',
@ -172,6 +173,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
assetSubClass: this.assetProfile.assetSubClass ?? null, assetSubClass: this.assetProfile.assetSubClass ?? null,
comment: this.assetProfile?.comment ?? '', comment: this.assetProfile?.comment ?? '',
tags: this.assetProfile?.tags ?? [], tags: this.assetProfile?.tags ?? [],
tagsDisconnected: [],
countries: JSON.stringify( countries: JSON.stringify(
this.assetProfile?.countries?.map(({ code, weight }) => { this.assetProfile?.countries?.map(({ code, weight }) => {
return { code, weight }; return { code, weight };
@ -328,6 +330,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
assetSubClass: this.assetProfileForm.get('assetSubClass').value, assetSubClass: this.assetProfileForm.get('assetSubClass').value,
comment: this.assetProfileForm.get('comment').value || null, comment: this.assetProfileForm.get('comment').value || null,
tags: this.assetProfileForm.get('tags').value, tags: this.assetProfileForm.get('tags').value,
tagsDisconnected: this.assetProfileForm.get('tagsDisconnected').value,
currency: this.assetProfileForm.get('currency').value, currency: this.assetProfileForm.get('currency').value,
name: this.assetProfileForm.get('name').value, name: this.assetProfileForm.get('name').value,
url: this.assetProfileForm.get('url').value url: this.assetProfileForm.get('url').value
@ -404,6 +407,10 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
return id !== aTag.id; return id !== aTag.id;
}) })
); );
this.assetProfileForm.controls['tagsDisconnected'].setValue([
...(this.assetProfileForm.controls['tagsDisconnected'].value ?? []),
aTag
]);
this.assetProfileForm.markAsDirty(); this.assetProfileForm.markAsDirty();
} }

2
apps/client/src/app/services/admin.service.ts

@ -245,6 +245,7 @@ export class AdminService {
symbol, symbol,
symbolMapping, symbolMapping,
tags, tags,
tagsDisconnected,
url url
}: AssetProfileIdentifier & UpdateAssetProfileDto) { }: AssetProfileIdentifier & UpdateAssetProfileDto) {
return this.http.patch<EnhancedSymbolProfile>( return this.http.patch<EnhancedSymbolProfile>(
@ -260,6 +261,7 @@ export class AdminService {
sectors, sectors,
symbolMapping, symbolMapping,
tags, tags,
tagsDisconnected,
url url
} }
); );

Loading…
Cancel
Save