Skip to content

Commit

Permalink
fix(classifier): reset hidden marks when the subject changes (#6098)
Browse files Browse the repository at this point in the history
* fix(classifier): reset hidden marks when the subject changes

Reset the Hide Previous Marks toggle when the a drawing task is reset. This should fix a bug where `task.hidingIndex` is remembered across subjects, which means that a volunteer won't see the first few marks that they draw on a new subject.

* Add an exception for SHOWN_MARKS.USER

* remove Object.assign

---------

Co-authored-by: Delilah C <23665803+goplayoutside3@users.noreply.github.com>
  • Loading branch information
eatyourgreens and goplayoutside3 committed May 23, 2024
1 parent 59d5240 commit d18c20b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const Drawing = types.model('Drawing', {
type: types.literal('drawing')
})
.preProcessSnapshot(snapshot => {
const newSnapshot = Object.assign({}, snapshot)
const newSnapshot = { ...snapshot }
/*
Create keys of the form 'T0.0' for each of this task's tools
*/
Expand Down Expand Up @@ -98,6 +98,10 @@ export const Drawing = types.model('Drawing', {
self.tools.forEach(tool => tool.reset())
self.activeToolIndex = 0
self.subTaskVisibility = false
if (self.shownMarks === SHOWN_MARKS.NONE) {
self.hidingIndex = 0
self.shownMarks = SHOWN_MARKS.ALL
}
},

setToolTaskStrings(stringsSnapshot) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { applySnapshot, getSnapshot, types } from 'mobx-state-tree'
import DrawingTask from '@plugins/tasks/drawing'
import SHOWN_MARKS from '@helpers/shownMarks'
import sinon from 'sinon'
import { expect } from 'chai'

describe('Model > DrawingTask', function () {
const details = [
Expand Down Expand Up @@ -410,6 +411,7 @@ describe('Model > DrawingTask', function () {
pointTool = task.tools[0]
lineTool = task.tools[1]
task.setActiveTool(0)
task.togglePreviousMarks()
task.reset()
marks = task.marks
})
Expand All @@ -426,6 +428,11 @@ describe('Model > DrawingTask', function () {
it('should reset the active tool', function () {
expect(task.activeToolIndex).to.equal(0)
})

it('should reset the hide marks toggle', function () {
expect(task.shownMarks).to.equal(SHOWN_MARKS.ALL)
expect(task.hidingIndex).to.eql(0)
})
})

describe('validation', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { types } from 'mobx-state-tree'
import TranscriptionTask from '@plugins/tasks/experimental/transcription'
import SHOWN_MARKS from '@helpers/shownMarks'
import { expect } from 'chai'

const details = [
{
Expand Down Expand Up @@ -177,6 +178,7 @@ describe('Model > TranscriptionTask', function () {
task = TranscriptionTask.TaskModel.create(transcriptionTaskSnapshot)
const annotation = task.defaultAnnotation()
transcriptionLineTool = task.tools[0]
task.togglePreviousMarks(SHOWN_MARKS.USER)
task.reset()
marks = task.marks
})
Expand All @@ -193,5 +195,9 @@ describe('Model > TranscriptionTask', function () {
it('should reset the active tool', function () {
expect(task.activeToolIndex).to.equal(0)
})
it('should not change the SHOWN_MARKS.USER state', function () {
expect(task.shownMarks).to.equal(SHOWN_MARKS.USER)
expect(task.hidingIndex).to.equal(0)
})
})
})

0 comments on commit d18c20b

Please sign in to comment.