From 99c754c4a542ae79b19cf5b7799afe586d64625b Mon Sep 17 00:00:00 2001 From: r66ad Date: Thu, 9 May 2019 07:51:14 +0200 Subject: [PATCH] Templating: Support selecting all filtered values of multi-value variable (#16873) * Closes #15821 * sorry, now prettier * select and deselect on filtered values works with Selected option now. Should the clearSelections function rather be renamed to selectOrClearValues? Selected should have another name too. --- public/app/core/directives/value_select_dropdown.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/public/app/core/directives/value_select_dropdown.ts b/public/app/core/directives/value_select_dropdown.ts index 90a4ad64477..48861d9f4a0 100644 --- a/public/app/core/directives/value_select_dropdown.ts +++ b/public/app/core/directives/value_select_dropdown.ts @@ -77,10 +77,17 @@ export class ValueSelectDropdownCtrl { } clearSelections() { - _.each(this.options, option => { - option.selected = false; - }); + this.selectedValues = _.filter(this.options, { selected: true }); + if (this.selectedValues.length > 1) { + _.each(this.options, option => { + option.selected = false; + }); + } else { + _.each(this.search.options, option => { + option.selected = true; + }); + } this.selectionsChanged(false); }