Miha Stajdohar avatar Miha Stajdohar committed f8b5e9c

Filter combo custom fields on benchmark selection.

Comments (0)

Files changed (1)

benchmarks/static/benchmarks/js/controllers.js

     }
 
     function set_attributes() {
+        var ax = $scope.attribute_x,
+            ay = $scope.attribute_y;
+
         $scope.attributes_x = [
             {label: 'Date', attribute: 'date'},
             {label: 'Title', attribute: 'title'}
                 $scope.attributes_y.push({label: key, attribute: key});
             }
         }
+
+        // set attributes that were selected in y combo
+        if (ay !== undefined) {
+            var old_attributes_y = {},
+                new_attributes_y = [];
+
+            // build a set of attributes that were selected in y combo
+            for (var i = 0, l = ay.length; i < l; i++) {
+                old_attributes_y[ay[i].attribute] = true;
+            }
+
+            for (var i = 0, l = $scope.attributes_y.length; i < l; i++) {
+                if ($scope.attributes_y[i].attribute in old_attributes_y) {
+                    new_attributes_y.push($scope.attributes_y[i]);
+                }
+            }
+
+            $scope.attribute_y = new_attributes_y;
+        }
+
+        // set attribute that was selected in x combo
+        if (ax !== undefined && ax !== null) {
+            for (var i = 0, l = $scope.attributes_x.length; i < l; i++) {
+                if ($scope.attributes_x[i].attribute === ax.attribute) {
+                    $scope.attribute_x = $scope.attributes_x[i];
+                    break;
+                }
+            }
+        }
     }
 
     set_defaults();
                 for (var i = 0, l = orderedData.length; i < l; i++) {
                     checked += ($scope.checkboxes.items[orderedData[i].id]) || 0;
                     unchecked += (!$scope.checkboxes.items[orderedData[i].id]) || 0;
-                    /* DOES NOT WORK YET!
-                     if ($scope.checkboxes.items[orderedData[i].id]) {
-                     for (var j = 0, l2 = orderedData[i].fields.length; j < l2; j++) {
-                     if (!(orderedData[i].fields[j].name in field_names)) {
-                     field_names[orderedData[i].fields[j].name] = orderedData[i].fields[j].type;
-                     }
-                     }
-                     }
-                     */
+
+                    if ($scope.checkboxes.items[orderedData[i].id]) {
+                        for (var j = 0, l2 = orderedData[i].fields.length; j < l2; j++) {
+                            if (!(orderedData[i].fields[j].name in field_names)) {
+                                field_names[orderedData[i].fields[j].name] = orderedData[i].fields[j].type;
+                            }
+                        }
+                    }
                 }
                 if ((unchecked == 0) || (checked == 0)) {
                     $scope.checkboxes.checked = (checked == total);
                 }
-                if (true) {
-                    field_names = all_fields;
-                }
+
+                /*if (true) {
+                 field_names = all_fields;
+                 }*/
+
                 $scope.checkboxes.num_checked = checked;
                 set_attributes();
                 // grayed checkbox
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.