From 1dad7044ffd19aedb4990e599c86c8cfe838b779 Mon Sep 17 00:00:00 2001 From: Fabio Tesser Date: Thu, 26 Sep 2024 21:38:46 +0200 Subject: [PATCH] [feat] Added tag-selected mode for View visibleWhen. --- web/libs/editor/src/mixins/Visibility.js | 4 ++++ web/libs/editor/src/tags/visual/View.jsx | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/web/libs/editor/src/mixins/Visibility.js b/web/libs/editor/src/mixins/Visibility.js index 802a4e561d0..191c70bc914 100644 --- a/web/libs/editor/src/mixins/Visibility.js +++ b/web/libs/editor/src/mixins/Visibility.js @@ -55,6 +55,10 @@ const VisibilityMixin = types "no-region-selected": () => !self.annotation.highlightedNode, "choice-unselected": (params) => !fns["choice-selected"](params), + "tag-selected": ({ tagName }) => { + const tag = self.annotation.names.get(tagName); + return tag.isSelected; + }, }; if (Object.keys(fns).includes(self.visiblewhen)) { diff --git a/web/libs/editor/src/tags/visual/View.jsx b/web/libs/editor/src/tags/visual/View.jsx index c5e035fb8f0..0cd9b2cbd5c 100644 --- a/web/libs/editor/src/tags/visual/View.jsx +++ b/web/libs/editor/src/tags/visual/View.jsx @@ -60,8 +60,8 @@ import { AnnotationMixin } from "../../mixins/AnnotationMixin"; * @param {string} [style] CSS style string * @param {string} [className] - Class name of the CSS style to apply. Use with the Style tag * @param {string} [idAttr] - Unique ID attribute to use in CSS - * @param {region-selected|choice-selected|no-region-selected|choice-unselected} [visibleWhen] Control visibility of the content. Can also be used with the `when*` parameters below to narrow visibility - * @param {string} [whenTagName] Use with `visibleWhen`. Narrow down visibility by tag name. For regions, use the name of the object tag, for choices, use the name of the `choices` tag + * @param {region-selected|choice-selected|no-region-selected|choice-unselected|tag-selected} [visibleWhen] Control visibility of the content. Can also be used with the `when*` parameters below to narrow visibility + * @param {string} [whenTagName] Use with `visibleWhen`. Narrow down visibility by tag name. For regions, use the name of the object tag, for choices, use the name of the `choices` tag, for tag use the name of the tag * @param {string} [whenLabelValue] Use with `visibleWhen="region-selected"`. Narrow down visibility by label value. Multiple values can be separated with commas * @param {string} [whenChoiceValue] Use with `visibleWhen` (`"choice-selected"` or `"choice-unselected"`) and `whenTagName`, both are required. Narrow down visibility by choice value. Multiple values can be separated with commas */ @@ -114,14 +114,17 @@ const Model = types.model({ "textarea", "pairwise", "style", + "label", "relations", "filter", + "timeseries", + "timeserieslabels", "pagedview", "paragraphs", "paragraphlabels", "video", "videorectangle", - "timelinelabels", + "ranker", ]), });