diff --git a/src/examples/nested_labels/config.xml b/src/examples/nested_labels/config.xml new file mode 100644 index 000000000..6b0d2f8d6 --- /dev/null +++ b/src/examples/nested_labels/config.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/examples/nested_labels/index.js b/src/examples/nested_labels/index.js new file mode 100644 index 000000000..4ed51548c --- /dev/null +++ b/src/examples/nested_labels/index.js @@ -0,0 +1,5 @@ +import config from './config.xml'; +import tasks from './tasks.json'; +import annotation from './annotations/nested-labels.json'; + +export const NestedLabels = { config, tasks, annotation }; diff --git a/src/tags/control/Label.js b/src/tags/control/Label.js index bebcd18be..e11d170c3 100644 --- a/src/tags/control/Label.js +++ b/src/tags/control/Label.js @@ -157,6 +157,30 @@ const Model = types.model({ // if that's the only selected label, the only labelset assigned to region, // and we are trying to unselect it, then don't allow that // (except for rare labelsets that allow empty labels) + + // Don't allow selecting a different top-level label when we've already labeled it: DI-1502 + if ( + labels.selectedLabels.length === 1 && + !self.selected && + labels.selectedLabels[0].value !== self.value && + !labels.selectedLabels[0].alias // Hack: we only gave sub-labels aliases + ) { + return false; + } + + // If this is only top level label and there are sub labels, don't allow deselect + if ( + labels.selectedLabels.length === 1 && + self.selected && + labels.selectedLabels[0].value === self.value && + !labels.selectedLabels[0].alias && // Hack: we only gave sub-labels aliases + region.labelings.length > 1 + ) { + console.log('can\'t deselect top level label w sub label!'); + + return false; + } + if ( labels.selectedLabels.length === 1 && self.selected &&