diff options
author | bobzel <zzzman@gmail.com> | 2024-09-19 17:50:48 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-09-19 17:50:48 -0400 |
commit | 3c8af89e3d5370b748fea27c411b3e62758b9a45 (patch) | |
tree | 38341e3d27cf52a0fcfdba467eaac4565c3c8c0e /src/client/views/global/globalScripts.ts | |
parent | 865b8b57f0fe352afdb980d1104da8d297a10559 (diff) |
changed backend for filtering buttons to store only one list - the list of icon buttons in Doc.MyFilterHotKeys.
Diffstat (limited to 'src/client/views/global/globalScripts.ts')
-rw-r--r-- | src/client/views/global/globalScripts.ts | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/client/views/global/globalScripts.ts b/src/client/views/global/globalScripts.ts index d2cee39e2..f7a9689c9 100644 --- a/src/client/views/global/globalScripts.ts +++ b/src/client/views/global/globalScripts.ts @@ -270,27 +270,29 @@ ScriptingGlobals.add(function showFreeform(attr: 'hcenter' | 'vcenter' | 'grid' }); /** - * Applies a filter to the selected document (or, if the settins button is pressed, opens the filter panel) + * Applies a filter to the selected document (or, if the settings button is pressed, opens the filter panel) */ // eslint-disable-next-line prefer-arrow-callback ScriptingGlobals.add(function handleTags(value: string, checkResult?: boolean) { const selected = DocumentView.SelectedDocs().lastElement(); + const isOptions = value === '-opts-'; - function isAttrFiltered(attr: string) { - return StrListCast(selected._childFilters).some(filter => filter.includes(attr)); - } + const isAttrFiltered = (attr: string) => + StrListCast(selected._childFilters) + .map(filter => filter.split(Doc.FilterSep)) + .some(([key, val]) => key === 'tags' && val === attr); if (checkResult) { - return value === 'opts' ? PropertiesView.Instance?.openFilters : isAttrFiltered(value); + return isOptions ? false : isAttrFiltered(value); } - if (value != 'opts') { - isAttrFiltered(value) ? Doc.setDocFilter(selected, value, true, 'remove') : Doc.setDocFilter(selected, value, true, 'match'); + if (!isOptions) { + isAttrFiltered(value) ? Doc.setDocFilter(selected, 'tags', value, 'remove') : Doc.setDocFilter(selected, 'tags', value, 'check'); } else { SnappingManager.PropertiesWidth < 5 && SnappingManager.SetPropertiesWidth(0); SnappingManager.SetPropertiesWidth(MainView.Instance.propertiesWidth() < 15 ? 250 : 0); PropertiesView.Instance?.CloseAll(); - PropertiesView.Instance.openFilters = true; + runInAction(() => (PropertiesView.Instance.openFilters = SnappingManager.PropertiesWidth > 5)); } return undefined; |