Make filters implicit; Update symbols

This commit is contained in:
Serial 2022-04-29 19:57:16 -04:00
parent 06cc1abbb1
commit 9173780568
2 changed files with 21 additions and 25 deletions

View File

@ -109,6 +109,10 @@ Otherwise, have a great day =^.^=
right: 0;
left: auto;
}
#version-filter-count {
display: none;
}
}
.label {
@ -297,7 +301,7 @@ Otherwise, have a great day =^.^=
#version-filter li label {
padding-right: 0;
width: 80%;
width: 40%;
}
.version-filter-input {
@ -425,7 +429,7 @@ Otherwise, have a great day =^.^=
<div id="version-filter">
<div class="btn-group" filter-dropdown>
<button type="button" class="btn btn-default dropdown-toggle">
Version <span class="caret"></span>
Version <span id="version-filter-count" class="badge">{{versionFilterCount(version_filters)}}</span> <span class="caret"></span>
</button>
<ul id="version-filter-selector" class="dropdown-menu">
<li class="checkbox">
@ -436,11 +440,8 @@ Otherwise, have a great day =^.^=
</li>
<li role="separator" class="divider"></li>
<li class="checkbox" ng-repeat="(filter, vars) in version_filters">
<label>
<input type="checkbox" ng-model="version_filters[filter].enabled" />
{{filter}}
</label>
<input type="text" class="version-filter-input form-control filter-input" maxlength="6" placeholder="1.62.0" ng-model="version_filters[filter].version_str" ng-model-options="{debounce: 50}"/>
<label ng-attr-for="filter-{filter}">{{filter}}</label>
<input type="text" ng-attr-id="filter-{filter}" class="version-filter-input form-control filter-input" maxlength="6" placeholder="1.62.0" ng-model="version_filters[filter].version_str" ng-model-options="{debounce: 50}"/>
</li>
</ul>
</div>

View File

@ -137,13 +137,13 @@
$scope.themes = THEMES_DEFAULT;
const DEFAULT_VERSION_FILTERS = {
">=": { enabled: false, version_str: "" },
"<=": { enabled: false, version_str: "" },
"==": { enabled: false, version_str: "" },
"": { enabled: false, version_str: "" },
"": { enabled: false, version_str: "" },
"=": { enabled: false, version_str: "" },
};
// Weird workaround to get a copy of the object
$scope.version_filters = JSON.parse(JSON.stringify(DEFAULT_VERSION_FILTERS));
$scope.version_regex = new RegExp('\\d\.\\d{2}\.\\d');
$scope.version_regex = new RegExp('1\.\\d{2}\.\\d');
$scope.selectTheme = function (theme) {
setTheme(theme, true);
@ -175,16 +175,8 @@
$scope.version_filters = JSON.parse(JSON.stringify(DEFAULT_VERSION_FILTERS));
}
$scope.versionSymbol = function() {
const version_filters = $scope.version_filters;
let filter = ">=";
for (const key in version_filters) {
if (version_filters[key]) {
filter = key;
}
}
return filter;
$scope.versionFilterCount = function(obj) {
return Object.values(obj).filter(x => x.enabled).length;
}
$scope.byVersion = function(lint) {
@ -214,10 +206,13 @@
let version_str = filters[filter].version_str;
// Skip the work for version strings with invalid lengths or characters
if (!filters[filter].enabled || !validate_version_str(version_str)) {
if (!validate_version_str(version_str)) {
filters[filter].enabled = false;
continue;
}
filters[filter].enabled = true;
let result = cmp_version(lint_version, version_str, filter);
if (result && filter === "==") {
return true;
@ -226,10 +221,10 @@
}
let cmp_filter;
if (filter === ">=") {
cmp_filter = "<=";
if (filter === "") {
cmp_filter = "";
} else {
cmp_filter = ">=";
cmp_filter = "";
}
let cmp_version_str = filters[cmp_filter].version_str;