From 857961f0ee39f90dc3267cebd2b5e3f718115d06 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Tue, 11 Aug 2020 16:52:20 +0200 Subject: adapt my-select-checkbox placeholder to its context --- .../shared-forms/select/select-checkbox.component.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'client/src/app/shared/shared-forms/select/select-checkbox.component.ts') diff --git a/client/src/app/shared/shared-forms/select/select-checkbox.component.ts b/client/src/app/shared/shared-forms/select/select-checkbox.component.ts index 93653fef1..fd683ae5d 100644 --- a/client/src/app/shared/shared-forms/select/select-checkbox.component.ts +++ b/client/src/app/shared/shared-forms/select/select-checkbox.component.ts @@ -1,6 +1,7 @@ -import { Component, Input, forwardRef } from '@angular/core' +import { Component, Input, forwardRef, OnInit } from '@angular/core' import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms' import { SelectOptionsItem } from './select-options.component' +import { I18n } from '@ngx-translate/i18n-polyfill' export type ItemSelectCheckboxValue = { id?: string | number, group?: string } | string @@ -16,12 +17,21 @@ export type ItemSelectCheckboxValue = { id?: string | number, group?: string } | } ] }) -export class SelectCheckboxComponent implements ControlValueAccessor { +export class SelectCheckboxComponent implements OnInit, ControlValueAccessor { @Input() availableItems: SelectOptionsItem[] = [] @Input() selectedItems: ItemSelectCheckboxValue[] = [] @Input() selectableGroup: boolean @Input() selectableGroupAsModel: boolean @Input() maxSelectedItems: number + @Input() placeholder: string + + constructor ( + private i18n: I18n + ) {} + + ngOnInit () { + if (!this.placeholder) this.placeholder = this.i18n('Add a new option') + } propagateChange = (_: any) => { /* empty */ } -- cgit v1.2.3