import {Component, OnInit} from "@angular/core";
import { FieldType, FieldTypeConfig } from "@ngx-formly/core";

@Component({
  selector: 'app-form-signature-link-type',
  template: `
    <label *ngIf="props.label && props['hideLabel'] !== true" [attr.for]="id"
         class="form-label">{{ props.label }}
        <span *ngIf="props.required && props['hideRequiredMarker'] !== true" aria-hidden="true">*</span>
    </label>
    <div class="input-group mb-12">
      <input class="form-control" type="text" readonly disabled="" value="{{ this.signature_url }}"/>
      <button type="button" class="btn btn-light" [cdkCopyToClipboard]="this.signature_url"><i-bs name="text-paragraph"/></button>
    </div>
  `,
})
export class SignatureLinkTypeComponent extends FieldType<FieldTypeConfig> implements OnInit{
  base_path = "/contracts/signature/"
  signature_url = ""

  ngOnInit() {
    this.signature_url = location.origin + this.base_path + this.formControl.value
  }
}
