Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
kulgg committed Jul 29, 2024
1 parent ccde07c commit f5b4e32
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@
</button>
</ng-container>

<a
<button
*ngIf="isOnRequestDataOffer"
mat-raised-button
color="primary"
[href]="this.onRequestContactLink">
(click)="onContactClick()">
Contact
</a>
</button>

<!-- Contact Agreement Buttons -->
<button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {DOCUMENT} from '@angular/common';
import {Component, Inject, OnDestroy} from '@angular/core';
import {
MAT_DIALOG_DATA,
Expand Down Expand Up @@ -74,17 +75,6 @@ export class AssetDetailDialogComponent implements OnDestroy {
);
}

get onRequestContactLink(): string {
if (!this.asset.onRequestContactEmail) {
throw new Error('On request asset must have contact email');
}
return this.mailtoLinkBuilder.buildMailtoUrl(
this.asset.onRequestContactEmail,
this.asset.onRequestContactEmailSubject ??
"I'm interested in your data offer",
);
}

constructor(
private edcApiService: EdcApiService,
private notificationService: NotificationService,
Expand All @@ -94,6 +84,7 @@ export class AssetDetailDialogComponent implements OnDestroy {
private _data: AssetDetailDialogData | Observable<AssetDetailDialogData>,
public contractNegotiationService: ContractNegotiationService,
private mailtoLinkBuilder: MailtoLinkBuilder,
@Inject(DOCUMENT) private document: Document,
) {
if (isObservable(this._data)) {
this._data
Expand All @@ -110,6 +101,19 @@ export class AssetDetailDialogComponent implements OnDestroy {
this.propGroups = this.data.propertyGridGroups;
}

onContactClick() {
if (!this.asset.onRequestContactEmail) {
throw new Error('On request asset must have contact email');
}

const url = this.mailtoLinkBuilder.buildMailtoUrl(
this.asset.onRequestContactEmail,
this.asset.onRequestContactEmailSubject ??
"I'm interested in your data offer",
);
this.document.location.href = url;
}

onEditClick() {
if (this.data.onAssetEditClick) {
this.data.onAssetEditClick(this.data.asset, (data) => this.setData(data));
Expand Down

0 comments on commit f5b4e32

Please sign in to comment.