ソースを参照

Multi selecting starting to work

Torkel Ödegaard 10 年 前
コミット
6e0947c0d9

+ 0 - 1
src/app/controllers/search.js

@@ -136,7 +136,6 @@ function (angular, _, config) {
 
   });
 
-
   module.directive('tagColorFromName', function() {
 
     function djb2(str) {

+ 8 - 8
src/app/directives/templateParamSelector.js

@@ -123,7 +123,9 @@ function (angular, app, _, $) {
           };
 
           scope.optionSelected = function(option) {
-            if (!variable.multi) {
+            option.selected = !option.selected;
+
+            if (!variable.multi || option.text === 'All') {
               _.each(scope.options, function(other) {
                 if (option !== other) {
                   other.selected = false;
@@ -133,19 +135,16 @@ function (angular, app, _, $) {
 
             var selected = _.filter(scope.options, {selected: true});
 
+            // enfore the first selected if no option is selected
             if (selected.length === 0) {
-              // encode the first selected if no option is selected
               scope.options[0].selected = true;
-              $timeout(function() {
-                scope.optionSelected(scope.options[0]);
-              });
-              return;
+              selected = [scope.options[0]];
             }
 
             if (selected.length > 1) {
               if (selected[0].text === 'All') {
+                selected[0].selected = false;
                 selected = selected.slice(1, selected.length);
-                debugger;
               }
             }
 
@@ -160,6 +159,7 @@ function (angular, app, _, $) {
             }
 
             scope.updateLinkText();
+            scope.onUpdated();
           };
 
           scope.hide = function() {
@@ -187,7 +187,7 @@ function (angular, app, _, $) {
             scope.linkText += variable.current.text;
           };
 
-          scope.$watchGroup(['variable.hideLabel', 'variable.name', 'variable.label'], function() {
+          scope.$watchGroup(['variable.hideLabel', 'variable.name', 'variable.label', 'variable.current.text'], function() {
             scope.updateLinkText();
           });
         },

+ 6 - 5
src/app/features/dashboard/partials/variableValueSelect.html

@@ -12,12 +12,13 @@
 	</div>
 
 	<div class="variable-options-container" ng-if="!query.tagcloud">
-		<div class="variable-option pointer" bindonce ng-repeat="option in options"
-				ng-class="{'selected': selected}" ng-href="{{row.url}}">
-				<i class="variable-option-check"></i>
-				<label for="var.option.{{$id}}" label">{{option.text}}</label>
+		<a class="variable-option pointer" bindonce ng-repeat="option in options"
+				ng-class="{'selected': option.selected}" ng-click="optionSelected(option)">
+				<i class="fa fa-fw fa-square-o"></i>
+				<i class="fa fa-fw fa-check-square-o"></i>
+				<span >{{option.text}}</label>
 			</div>
-		</div>
+		</a>
 	</div>
 </div>
 

+ 16 - 0
src/css/less/submenu.less

@@ -43,5 +43,21 @@
 
   .variable-option {
     display: block;
+    .fa {
+      font-size: 130%;
+      position: relative;
+      top: 2px;
+      padding-right: 6px;
+    }
+    .fa-check-square-o { display: none; }
+
+    &.selected {
+      .fa-square-o {
+        display: none;
+      }
+      .fa-check-square-o {
+        display: inline-block;
+      }
+    }
   }
 }