Skip to content

Commit e4ce248

Browse files
committed
Complete filter functionality. Formatted upper filters to take more visual column space. Force filter wrapping with flex for small screens.
1 parent 0b43e03 commit e4ce248

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

util/gh-pages/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
@media (min-width: 405px) {
104104
#upper-filters {
105105
display: flex;
106+
flex-wrap: wrap;
106107
}
107108
}
108109

@@ -404,7 +405,7 @@ <h1>Clippy Lints</h1>
404405

405406
<div class="panel panel-default" ng-show="data">
406407
<div class="panel-body row">
407-
<div id="upper-filters" class="col-12 col-md-4">
408+
<div id="upper-filters" class="col-12 col-md-6">
408409
<div class="btn-group" filter-dropdown>
409410
<button type="button" class="btn btn-default dropdown-toggle">
410411
Lint levels <span class="badge">{{selectedValuesCount(levels)}}</span> <span class="caret"></span>
@@ -523,7 +524,7 @@ <h1>Clippy Lints</h1>
523524
</ul>
524525
</div>
525526
</div>
526-
<div class="col-12 col-md-7 search-control">
527+
<div class="col-12 col-md-6 search-control">
527528
<div class="input-group">
528529
<label class="input-group-addon" id="filter-label" for="search-input">Filter:</label>
529530
<input type="text" class="form-control filter-input" placeholder="Keywords or search string" id="search-input"
@@ -539,7 +540,7 @@ <h1>Clippy Lints</h1>
539540
</div>
540541
</div>
541542
<!-- The order of the filters should be from most likely to remove a lint to least likely to improve performance. -->
542-
<article class="panel panel-default" id="{{lint.id}}" ng-repeat="lint in data | filter:bySearch | filter:byGroups | filter:byLevels | filter:byVersion">
543+
<article class="panel panel-default" id="{{lint.id}}" ng-repeat="lint in data | filter:bySearch | filter:byGroups | filter:byLevels | filter:byVersion | filter:byApplicabilities">
543544
<header class="panel-heading" ng-click="open[lint.id] = !open[lint.id]">
544545
<h2 class="panel-title">
545546
<div class="panel-title-name">

util/gh-pages/script.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,17 @@
156156
Object.entries(versionFilterKeyMap).map(([key, value]) => [value, key])
157157
);
158158

159-
const APPLICABILITIES_DEFAULT = {
160-
unspecified: true,
161-
unresolved: true,
162-
machineApplicable: true,
163-
maybeIncorrect: true,
164-
hasPlaceholders: true
159+
const APPLICABILITIES_FILTER_DEFAULT = {
160+
Unspecified: true,
161+
Unresolved: true,
162+
MachineApplicable: true,
163+
MaybeIncorrect: true,
164+
HasPlaceholders: true
165165
};
166166

167-
$scope.applicabilities = APPLICABILITIES_DEFAULT;
167+
$scope.applicabilities = {
168+
...APPLICABILITIES_FILTER_DEFAULT
169+
}
168170

169171
// loadFromURLParameters retrieves filter settings from the URL parameters and assigns them
170172
// to corresponding $scope variables.
@@ -192,6 +194,7 @@
192194

193195
handleParameter('levels', $scope.levels, LEVEL_FILTERS_DEFAULT);
194196
handleParameter('groups', $scope.groups, GROUPS_FILTER_DEFAULT);
197+
handleParameter('applicabilities', $scope.applicabilities, APPLICABILITIES_FILTER_DEFAULT);
195198

196199
// Handle 'versions' parameter separately because it needs additional processing
197200
if (urlParameters.versions) {
@@ -259,6 +262,7 @@
259262
updateURLParameter($scope.levels, 'levels', LEVEL_FILTERS_DEFAULT);
260263
updateURLParameter($scope.groups, 'groups', GROUPS_FILTER_DEFAULT);
261264
updateVersionURLParameter($scope.versionFilters);
265+
updateURLParameter($scope.applicabilities, 'applicabilities', APPLICABILITIES_FILTER_DEFAULT);
262266
}
263267

264268
// Add $watches to automatically update URL parameters when the data changes
@@ -280,6 +284,13 @@
280284
}
281285
}, true);
282286

287+
$scope.$watch('applicabilities', function (newVal, oldVal) {
288+
console.log("Test");
289+
if (newVal !== oldVal) {
290+
updateURLParameter(newVal, 'applicabilities', APPLICABILITIES_FILTER_DEFAULT)
291+
}
292+
}, true);
293+
283294
// Watch for changes in the URL path and update the search and lint display
284295
$scope.$watch(function () { return $location.path(); }, function (newPath) {
285296
const searchParameter = newPath.substring(1);
@@ -337,6 +348,15 @@
337348
}
338349
};
339350

351+
$scope.toggleApplicabilities = function (value) {
352+
const applicabilities = $scope.applicabilities;
353+
for (const key in applicabilities) {
354+
if (applicabilities.hasOwnProperty(key)) {
355+
applicabilities[key] = value;
356+
}
357+
}
358+
}
359+
340360
$scope.resetGroupsToDefault = function () {
341361
$scope.groups = {
342362
...GROUPS_FILTER_DEFAULT
@@ -440,6 +460,10 @@
440460
return true;
441461
}
442462

463+
$scope.byApplicabilities = function (lint) {
464+
return $scope.applicabilities[lint.applicability.applicability];
465+
};
466+
443467
// Show details for one lint
444468
$scope.openLint = function (lint) {
445469
$scope.open[lint.id] = true;

0 commit comments

Comments
 (0)