From 183cc9abd0cb2874d55f37b96ca55642bf737caf Mon Sep 17 00:00:00 2001 From: Ivan Efimov Date: Mon, 3 Jan 2022 19:33:18 -0600 Subject: [PATCH] Presets: minor fixes for style and automatic save presets source when click active --- src/css/dark-theme.css | 1 + src/css/main.css | 1 + .../PresetsRepoIndexed/PresetsRepoIndexed.js | 6 +++--- src/tabs/presets/SourcesDialog/SourcePanel.js | 1 + src/tabs/presets/presets.css | 5 +++++ src/tabs/presets/presets.html | 2 +- src/tabs/presets/presets.js | 20 ++++++++++++++++--- 7 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/css/dark-theme.css b/src/css/dark-theme.css index 4eecd53f..452f0df9 100644 --- a/src/css/dark-theme.css +++ b/src/css/dark-theme.css @@ -18,6 +18,7 @@ --pushedButton-fontColor: #ffffff; --hoverButton-background: #ffcc3e; --superSubtleAccent: #595959; + --accentBorder: #bf8606; } .background_paper { diff --git a/src/css/main.css b/src/css/main.css index f9be1f08..f8fa0aec 100644 --- a/src/css/main.css +++ b/src/css/main.css @@ -20,6 +20,7 @@ --pushedButton-fontColor: #000000; --hoverButton-background: #ffcc3e; --superSubtleAccent: #CCCCCC; + --accentBorder: #ffbb00; } * { diff --git a/src/tabs/presets/PresetsRepoIndexed/PresetsRepoIndexed.js b/src/tabs/presets/PresetsRepoIndexed/PresetsRepoIndexed.js index cfd181aa..75fecd04 100644 --- a/src/tabs/presets/PresetsRepoIndexed/PresetsRepoIndexed.js +++ b/src/tabs/presets/PresetsRepoIndexed/PresetsRepoIndexed.js @@ -103,7 +103,7 @@ class PresetsRepoIndexed { _parceInclude(strings, includeRowIndexes, promises) { for (let i = 0; i < strings.length; i++) { - const match = PresetsRepoIndexed._sRegExpInclude.exec(strings[i].toLowerCase()); + const match = PresetsRepoIndexed._sRegExpInclude.exec(strings[i]); if (match !== null) { includeRowIndexes.push(i); @@ -143,7 +143,7 @@ class PresetsRepoIndexed { _isIncludeFound(strings) { for (const str of strings) { - const match = PresetsRepoIndexed._sRegExpInclude.exec(str.toLowerCase()); + const match = PresetsRepoIndexed._sRegExpInclude.exec(str); if (match !== null) { return true; @@ -220,4 +220,4 @@ PresetsRepoIndexed._sCliCommentDirective = "#"; PresetsRepoIndexed._sCliAttributeDirective = "#$"; // Reg exp extracts file/path.txt from # include: file/path.txt -PresetsRepoIndexed._sRegExpInclude = /^#\$[ ]+?include:[ ]+?(?\S+$)/; +PresetsRepoIndexed._sRegExpInclude = /^#\$[ ]+?INCLUDE:[ ]+?(?\S+$)/; diff --git a/src/tabs/presets/SourcesDialog/SourcePanel.js b/src/tabs/presets/SourcesDialog/SourcePanel.js index 06ce52bc..3533b8c9 100644 --- a/src/tabs/presets/SourcesDialog/SourcePanel.js +++ b/src/tabs/presets/SourcesDialog/SourcePanel.js @@ -161,6 +161,7 @@ class SourcePanel { } _onActivateButtonClick() { + this._onSaveButtonClick(); this.setActive(true); this._onActivateCallback?.(this); } diff --git a/src/tabs/presets/presets.css b/src/tabs/presets/presets.css index d1071b76..1ceacb8c 100644 --- a/src/tabs/presets/presets.css +++ b/src/tabs/presets/presets.css @@ -125,6 +125,11 @@ color: var(--defaultText); } +.presets_filter_select_nonempty { + border-color: var(--accentBorder) !important; + border-width: 2px !important; +} + .presets_search_settings { position: sticky; top: 0px; diff --git a/src/tabs/presets/presets.html b/src/tabs/presets/presets.html index 6746f82c..d0115417 100644 --- a/src/tabs/presets/presets.html +++ b/src/tabs/presets/presets.html @@ -71,7 +71,7 @@
-
Too many found
+
diff --git a/src/tabs/presets/presets.js b/src/tabs/presets/presets.js index 6962187c..d9ad3a3e 100644 --- a/src/tabs/presets/presets.js +++ b/src/tabs/presets/presets.js @@ -244,7 +244,7 @@ TABS.presets.onHtmlLoad = function(callback) { this.readDom(); this.setupMenuButtons(); this.setupBackupWarning(); - this._inputTextFilter.attr("placeholder", "example: \"karate racing\", or \"5'' freestyle\""); + this._inputTextFilter.attr("placeholder", "example: \"karate race\", or \"5'' freestyle\""); this.presetsDetailedDialog = new PresetsDetailedDialog($("#presets_detailed_dialog"), this.pickedPresetList, () => this.onPresetPickedCallback()); this.presetsSourcesDialog = new PresetsSourcesDialog($("#presets_sources_dialog")); @@ -320,7 +320,7 @@ TABS.presets.prepareFilterFields = function() { }; TABS.presets.preselectFilterFields = function() { - this._selectCategory.multipleSelect('setSelects', ["TUNE"]); + this._selectCategory.multipleSelect('setSelects', ["TUNE", "RC_SMOOTHING", "RC_LINK", "RATES"]); const currentVersion = FC.CONFIG.flightControllerVersion; const selectedVersions = []; @@ -359,13 +359,27 @@ TABS.presets.updateSearchResults = function() { searchString: this._inputTextFilter.val().trim(), }; + this.updateSelectStyle(); searchParams.authors = searchParams.authors.map(str => str.toLowerCase()); - const fitPresets = this.getFitPresets(searchParams); this.displayPresets(fitPresets); } }; +TABS.presets.updateSelectStyle = function() { + this.updateSingleSelectStyle(this._selectCategory); + this.updateSingleSelectStyle(this._selectKeyword); + this.updateSingleSelectStyle(this._selectAuthor); + this.updateSingleSelectStyle(this._selectFirmwareVersion); + this.updateSingleSelectStyle(this._selectStatus); +}; + +TABS.presets.updateSingleSelectStyle = function(select) { + const selectedOptions = select.multipleSelect("getSelects", "text"); + const isSomethingSelected = (0 !== selectedOptions.length); + select.parent().find($(".ms-choice")).toggleClass("presets_filter_select_nonempty", isSomethingSelected); +}; + TABS.presets.displayPresets = function(fitPresets) { this._presetPanels.forEach(presetPanel => { presetPanel.remove();