aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/buttons/delete-button.component.ts
blob: aced0f881308b788bbe2d3448b8af4c81505e794 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Component, Input, OnInit } from '@angular/core'
import { I18n } from '@ngx-translate/i18n-polyfill'

@Component({
  selector: 'my-delete-button',
  styleUrls: [ './button.component.scss' ],
  templateUrl: './delete-button.component.html'
})

export class DeleteButtonComponent implements OnInit {
  @Input() label: string
  @Input() title: string

  constructor (private i18n: I18n) { }

  ngOnInit () {
    // <my-delete-button /> No label
    if (this.label === undefined && !this.title) {
      this.title = this.i18n('Delete')
    }

    // <my-delete-button label /> Use default label
    if (this.label === '') {
      this.label = this.i18n('Delete')

      if (!this.title) {
        this.title = this.label
      }
    }
  }
}