diff --git a/package.json b/package.json index 3e071c9..78479e7 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mprisma/components", - "version": "16.2.0", + "version": "16.2.1", "repository": { "type": "git", "url": "https://github.com/gabriel-gn/prisma-components.git" diff --git a/src/components/inputs/multi-select/multi-select.component.ts b/src/components/inputs/multi-select/multi-select.component.ts index 676b152..e6ec0bd 100644 --- a/src/components/inputs/multi-select/multi-select.component.ts +++ b/src/components/inputs/multi-select/multi-select.component.ts @@ -116,6 +116,10 @@ export class MultiSelectComponent implements OnInit, AfterViewInit, ControlValue * Caso contrĂ¡rio, ao clicar sobre um item, remove ele da lista de selecionados */ @Input() showRemoveButton: boolean = false; + /** + * Caso a flag seja "true", filtra resultados selecionados apenas pela label. + */ + @Input() uniqueByLabel: boolean = false; public _observableInputLoading: boolean = false; public readonly myControl: UntypedFormControl; @@ -221,6 +225,12 @@ export class MultiSelectComponent implements OnInit, AfterViewInit, ControlValue } public isOptionSelected(option: (MultiSelectOption|any)): boolean { + if (this.uniqueByLabel) { + if (isMultiSelectOption(option)) { + return !!this.selectedOptions.find(sOptions => sOptions.label === option.label); + } + } + if (isMultiSelectOption(option)) { return !!this.selectedOptions.find(sOptions => _.isEqual(sOptions, option)); } else {