Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

fix: HumanSignal/label-studio#4386: Added tag-selected mode for visibleWhen #1614

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 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
4 changes: 2 additions & 2 deletions src/tags/visual/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import { AnnotationMixin } from '../../mixins/AnnotationMixin';
* @param {block|inline} display
* @param {string} [style] CSS style string
* @param {string} [className] - Class name of the CSS style to apply. Use with the Style tag
* @param {region-selected|choice-selected|no-region-selected|choice-unselected} [visibleWhen] Control visibility of the content. Can also be used with `when*` attributes below to narrow down 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 `when*` attributes below to narrow down 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
* @param {string} [whenChoiceValue] Use with visibleWhen ("choice-selected" or "choice-unselected") and whenTagName, both are required. Narrow down visibility by choice value
*/
Expand Down