forked from HumanSignal/label-studio-frontend
-
Notifications
You must be signed in to change notification settings - Fork 1
Fixing up logic around selecting/deselecting nested labels #13
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9a1da38
Fixing up logic around selecting/deselecting nested labels
lizfaubell 3ce26f0
Removing nested labels data details; can add locally if needed
lizfaubell a0281e5
Removing test file
lizfaubell 333be4a
Removing example tasks
lizfaubell b9a1fe1
Update src/tags/control/Label.js
lizfaubell 76eca8b
Lint fix
lizfaubell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<View> | ||
<Choices name="has_math_choice" toName="interaction" choice="single" showInLine="true"> | ||
<Choice value="This thread has math"/> | ||
<Choice value="This thread does not have math"/> | ||
</Choices> | ||
|
||
<View style="top: 0; position: sticky; z-index: 5; background: white" visibleWhen="choice-selected" whenTagName="has_math_choice" whenChoiceValue="This thread has math"> | ||
<Labels name="interaction_correctness" toName="interaction"> | ||
<Label value="Correct" hotkey="c" hint="This statement is accurate and pedagogically sound" granularity="div" background="green"/> | ||
<Label value="Incorrect: Khanmigo" hotkey="k" granularity="div" background="red"/> | ||
<Label value="Incorrect: Student" hotkey="s" granularity="div" background="orange"/> | ||
</Labels> | ||
</View> | ||
|
||
<View style="position: sticky; top: 32px; z-index: 5; background: white" visibleWhen="region-selected" whenTagName="interaction_correctness" whenLabelValue="Incorrect: Khanmigo"> | ||
<Labels name="khanmigo_incorrect_type" toName="interaction"> | ||
<Label alias="type-incorrect" value="Wrong calculation" hotkey="w" hint="Khanmigo calculates incorrectly, e.g. 2+2=5" granularity="div" background="pink"/> | ||
<Label alias="type-process" value="Wrong process" hotkey="p" hint="Khanmigo suggests a bad method, e.g. 'to find 2+2 you must divide'" granularity="div" background="purple"/> | ||
<Label alias="type-other" value="Other" hotkey="o" hint="Use this label for any noteworthy issue that is not addressed by other labels; elaborate in Labeler Notes" granularity="div" background="blue"/> | ||
</Labels> | ||
</View> | ||
|
||
<TableText name="interaction" value="$json_thread" granularity="word"/> | ||
</View> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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!") | ||
lizfaubell marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
return false; | ||
} | ||
|
||
if ( | ||
labels.selectedLabels.length === 1 && | ||
self.selected && | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [eslint] <eqeqeq> reported by reviewdog 🐶
Expected '===' and instead saw '=='.