From 3251e4e2ee20c2df6565f1130a440cc31d9f2976 Mon Sep 17 00:00:00 2001 From: Sourav <“ekta_y@tekditechnologies.com”> Date: Wed, 20 Jun 2018 18:18:42 +0530 Subject: [PATCH] Issue #386 fix: Adding attribute if there is 0 selection in multiselect --- demo/src/app/pages/modules/select/select.page.ts | 8 ++++++++ src/modules/select/components/multi-select.ts | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/demo/src/app/pages/modules/select/select.page.ts b/demo/src/app/pages/modules/select/select.page.ts index 84db911aa..8d6bffff0 100644 --- a/demo/src/app/pages/modules/select/select.page.ts +++ b/demo/src/app/pages/modules/select/select.page.ts @@ -26,6 +26,7 @@ const exampleStandardTemplate = ` [isSearchable]="searchable" [isDisabled]="disabled" [hasLabels]="!hideLabels" + [showCountText]="'Select'" #multiSelect> @@ -333,6 +334,13 @@ export class SelectPage { description: "Sets whether the multi select uses labels.", defaultValue: "true" }, + { + name: "showCountText", + type: "string", + description: "Display text when no value is selected. " + + "Eg:- If we pass a value 'Select', it will display Select selections instead of " + + "0 selections" + }, { name: "maxSelected", type: "number", diff --git a/src/modules/select/components/multi-select.ts b/src/modules/select/components/multi-select.ts index 770cb5563..7f1e2703b 100644 --- a/src/modules/select/components/multi-select.ts +++ b/src/modules/select/components/multi-select.ts @@ -97,6 +97,17 @@ export class SuiMultiSelect extends SuiSelectBase implements ICustom this._hasLabels = hasLabels; } + private _showCountText:string; + + @Input() + public get showCountText():string { + return this._showCountText; + } + + public set showCountText(showCountText:string) { + this._showCountText = showCountText; + } + private _placeholder:string; @Input() @@ -128,7 +139,8 @@ export class SuiMultiSelect extends SuiSelectBase implements ICustom public get selectedMessage():string { return this._localizationService.interpolate( this.localeValues.multi.selectedMessage, - [["count", this.selectedOptions.length.toString()]]); + [["count", this.selectedOptions.length.toString() === "0" && this._showCountText ? + this._showCountText : this.selectedOptions.length.toString()]]); } @HostBinding("class.multiple")