Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #SB-4214 fix: When no boards/mediums etc. are selected, show Select Board, Select Medium etc. #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions demo/src/app/pages/modules/select/select.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const exampleStandardTemplate = `
[isSearchable]="searchable"
[isDisabled]="disabled"
[hasLabels]="!hideLabels"
[showCountText]="'Select'"
#multiSelect>
<sui-select-option *ngFor="let option of multiSelect.filteredOptions"
[value]="option">
Expand Down Expand Up @@ -351,6 +352,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",
Expand Down
14 changes: 13 additions & 1 deletion src/modules/select/components/multi-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ export class SuiMultiSelect<T, U> extends SuiSelectBase<T, U> 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()
Expand Down Expand Up @@ -128,7 +139,8 @@ export class SuiMultiSelect<T, U> extends SuiSelectBase<T, U> implements ICustom
public get selectedMessage():string {
const message = 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()]]);
if (!this._placeholder) {
return message;
} else {
Expand Down