aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/global/globalScripts.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/global/globalScripts.ts')
-rw-r--r--src/client/views/global/globalScripts.ts18
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;