Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Issue-4386: Added tag-selected mode for View visibleWhen #6443

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions web/libs/editor/src/mixins/Visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
9 changes: 6 additions & 3 deletions web/libs/editor/src/tags/visual/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -114,14 +114,17 @@ const Model = types.model({
"textarea",
"pairwise",
"style",
"label",
"relations",
"filter",
"timeseries",
"timeserieslabels",
"pagedview",
"paragraphs",
"paragraphlabels",
"video",
"videorectangle",
"timelinelabels",
"ranker",
]),
});

Expand Down
Loading