瀏覽代碼

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.
r66ad 6 年之前
父節點
當前提交
99c754c4a5
共有 1 個文件被更改,包括 10 次插入3 次删除
  1. 10 3
      public/app/core/directives/value_select_dropdown.ts

+ 10 - 3
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);
   }