aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/buttons/edit-button.component.ts
blob: d8ae39b84c58c290a206aa7a97bb54bd9a60c6bb (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
32
import { Component, Input, OnInit } from '@angular/core'
import { I18n } from '@ngx-translate/i18n-polyfill'

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

export class EditButtonComponent implements OnInit {
  @Input() label: string
  @Input() title: string
  @Input() routerLink: string[] | string = []

  constructor (private i18n: I18n) { }

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

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

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