AW-5495
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<span class="item-link" (click)="copylink(copiedtt)" triggers="manual" ngbTooltip="Link copied" #copiedtt="ngbTooltip" ><i ngbTooltip='Copy link' class="fa-solid fa-link"></i> <span *ngIf="showText" i18n>Copy link</span></span>
|
@@ -0,0 +1,44 @@
|
||||
import { Component, Input, OnDestroy} from '@angular/core';
|
||||
import { IItemLinkType} from '../../models/itemlink.type'
|
||||
import { IUrlType } from '../../models/url.type';
|
||||
import { ItemService } from '../../common-service.module';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { ClipboardService } from 'ngx-clipboard'
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'fm-item-link',
|
||||
templateUrl: './item-link.component.html'
|
||||
})
|
||||
export class ItemLinkComponent implements OnDestroy {
|
||||
|
||||
@Input() itemCode:string;
|
||||
@Input() pathSuffix:string;
|
||||
@Input() query:string;
|
||||
@Input() validMinutes:number;
|
||||
@Input() showText:boolean;
|
||||
|
||||
private sub : Subscription = null;
|
||||
|
||||
constructor(private itemService:ItemService,private clipboardService$: ClipboardService) { }
|
||||
|
||||
copylink(tooltip) {
|
||||
if(this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
let link: IItemLinkType = {itemcode:this.itemCode,pathsuffix:this.pathSuffix,query:this.query,validminutes:this.validMinutes}
|
||||
this.sub = this.itemService.getItemLink(link).subscribe((url:IUrlType) => {
|
||||
this.clipboardService$.copy(url.url);
|
||||
tooltip.open();
|
||||
setTimeout(() => {
|
||||
tooltip.close();
|
||||
}, 2000);
|
||||
})
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if(this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user