Skip to content
This repository was archived by the owner on Sep 26, 2019. It is now read-only.
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
Binary file added app/assets/images/checkmark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/app.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ App = React.createClass
error: "Having trouble logging you in"

setTutorialComplete: ->
previously_saved = @state.user?.tutorial_complete?
previously_saved = @state.user?.tutorial_complete

# Immediately ammend user object with tutorial_complete flag so that we can hide the Tutorial:
@setState user: $.extend(@state.user ? {}, tutorial_complete: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ module.exports = React.createClass
classes.push 'transcribable' if @props.isTranscribable
classes.push 'interim' if @props.interim
classes.push if @props.disabled then 'committed' else 'uncommitted'
classes.push "tanscribing" if @checkLocation()
classes.push "tanscribing" if @inTranscribeWorkflow()

x1 = @props.mark.x
width = @props.mark.width
Expand Down
21 changes: 16 additions & 5 deletions app/assets/javascripts/components/subject-viewer.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ module.exports = React.createClass
@loadImage @props.subject.location.standard
window.addEventListener "resize", this.updateDimensions

$(document).keydown (e) =>
# Handle <delete> keypress
if e.keyCode == 46
mark = @state.selectedMark
@destroyMark mark if mark?

# Handle <enter> keypress
else if e.keyCode == 13
@submitMark(@state.uncommittedMark) if @state.uncommittedMark?

scrollToSubject: ->
# scroll to mark when transcribing
if @props.workflow.name is 'transcribe'
Expand Down Expand Up @@ -108,10 +118,10 @@ module.exports = React.createClass
# VARIOUS EVENT HANDLERS

# Commit mark
submitMark: (mark) ->
submitMark: (mark, oncomplete) ->
return unless mark?
@props.onComplete? mark
@setUncommittedMark null # reset uncommitted mark
@setUncommittedMark null, oncomplete # reset uncommitted mark

# Handle initial mousedown:
handleInitStart: (e) ->
Expand Down Expand Up @@ -198,10 +208,11 @@ module.exports = React.createClass
mark.belongsToUser = true
@setUncommittedMark mark

setUncommittedMark: (mark) ->
setUncommittedMark: (mark, oncomplete) ->
@setState
uncommittedMark: mark,
selectedMark: mark #, => @forceUpdate() # not sure if this is needed?
selectedMark: mark, () =>
oncomplete() if oncomplete?

setView: (viewX, viewY, viewWidth, viewHeight) ->
@setState {viewX, viewY, viewWidth, viewHeight}
Expand Down Expand Up @@ -235,7 +246,7 @@ module.exports = React.createClass

# First, if we're blurring some other uncommitted mark, commit it:
if @state.uncommittedMark? && mark != @state.uncommittedMark
@submitMark sel
@submitMark @state.uncommittedMark, sel

else
sel()
Expand Down
5 changes: 4 additions & 1 deletion app/assets/javascripts/components/transcribe/index.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ module.exports = React.createClass # rename to Classifier
page: @props.query.page

render: ->
if @props.params.workflow_id? and @props.params.parent_subject_id?
if @props.query.from == 'verify'
transcribeMode = 'verify'
else if @props.params.workflow_id? and @props.params.parent_subject_id?
transcribeMode = 'page'
else if @props.params.subject_id
transcribeMode = 'single'
Expand All @@ -113,6 +115,7 @@ module.exports = React.createClass # rename to Classifier
else isLastSubject = null

currentAnnotation = @getCurrentClassification().annotation
currentAnnotation = @props.query.annotation if @props.query.annotation?
TranscribeComponent = @getCurrentTool() # @state.currentTool
onFirstAnnotation = currentAnnotation?.task is @getActiveWorkflow().first_task

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ CompositeTool = React.createClass
# If there are more inputs, move focus to next input
# Otherwise commit annotation (which is default behavior when there's only one input
handleCompletedField: ->
field_keys = (c.value for c of @props.task.tool_config.options)
field_keys = (c.value for c in @props.task.tool_config.options)
next_field_key = field_keys[ field_keys.indexOf(@state.active_field_key) + 1 ]

if next_field_key?
@setState active_field_key: next_field_key
, =>
@forceUpdate()
else
@commitAnnotation()
# Default to first field key (in case we're repeating this task)
@setState active_field_key: field_keys[0], () =>
@commitAnnotation()

# User moved focus to an input:
handleFieldFocus: (annotation_key) ->
Expand All @@ -79,6 +81,8 @@ CompositeTool = React.createClass
if @props.transcribeMode is 'page' or @props.transcribeMode is 'single'
if @props.isLastSubject and not @props.task.next_task?
@props.returnToMarking()
else if @props.transcribeMode == 'verify'
@transitionTo 'verify'

# this can go into a mixin? (common across all transcribe tools)
returnToMarking: ->
Expand Down Expand Up @@ -109,6 +113,8 @@ CompositeTool = React.createClass
else
if @props.isLastSubject and ( @props.transcribeMode is 'page' or @props.transcribeMode is 'single' )
'Return to Marking'
else if @props.transcribeMode is 'verify'
'Return to Verify'
else 'Next Entry'

buttons.push <SmallButton label={buttonLabel} key="done-button" onClick={@commitAnnotation} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
React = require 'react'
{Navigation} = require 'react-router'
DraggableModal = require 'components/draggable-modal'
SmallButton = require 'components/buttons/small-button'
HelpButton = require 'components/buttons/help-button'
Expand All @@ -7,6 +8,7 @@ IllegibleSubjectButton = require 'components/buttons/illegible-subject-button'

TextTool = React.createClass
displayName: 'TextTool'
mixins: [Navigation] # load subjects and set state variables: subjects, classification

getInitialState: ->
annotation: @props.annotation ? {}
Expand Down Expand Up @@ -119,6 +121,8 @@ TextTool = React.createClass
if @props.transcribeMode is 'page' or @props.transcribeMode is 'single'
if @props.isLastSubject and not @props.task.next_task?
@props.returnToMarking()
else if @props.transcribeMode == 'verify'
@transitionTo 'verify'

# Get key to use in annotations hash (i.e. typically 'value', unless included in composite tool)
fieldKey: ->
Expand Down Expand Up @@ -235,6 +239,8 @@ TextTool = React.createClass
else
if @props.isLastSubject and ( @props.transcribeMode is 'page' or @props.transcribeMode is 'single' )
'Return to Marking'
else if @props.transcribeMode is 'verify'
'Return to Verify'
else 'Next Entry'

buttons.push <SmallButton label={buttonLabel} key="done-button" onClick={@commitAnnotation} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ VerifyTool = React.createClass
y = data.y + yPad
return {x,y}

editAnnotation: (ann) ->
url = "/#/transcribe/#{@props.subject.parent_subject_id}?scrollX=#{window.scrollX}&scrollY=#{window.scrollY}&from=verify"
url += "&" + ("annotation[#{k}]=#{v}" for k,v of ann).join('&')
window.location.href = url

render: ->
# return null unless @props.viewerSize? && @props.subject?
# return null if ! @props.scale? || ! @props.scale.horizontal?
Expand Down Expand Up @@ -115,10 +120,13 @@ VerifyTool = React.createClass
# TODO: hack to approximate a friendly label in emigrant; should pull from original label:
label = label.replace(/em_/,'')
label = label.replace(/_/g, ' ')
<li key={k}><span className="label">{label}</span> {v}</li>
<li key={k}><span className="label">{label}</span> <span className="value">{v}</span></li>
}
</ul>
</a>
{ if @props.workflow.subjects_editable
<SmallButton label='Edit' className="edit-button" key="edit-button" onClick={@editAnnotation.bind @, data} />
}
</li>
}
</ul>
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/lib/mark-button-mixin.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ module.exports =
markStatus: markStatus
locked: ''

checkLocation: ()->
inTranscribeWorkflow: ()->
pattern = new RegExp('^(#\/transcribe)')
pattern.test("#{window.location.hash}")

renderMarkButton: ->
return null if @checkLocation()
return null if @inTranscribeWorkflow()
<MarkButton
tool={this}
onDrag={@onClickMarkButton}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/lib/workflow-methods-mixin.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ module.exports =
task = @getTasks()[@state.taskKey]
# PB: Moving from hash of options to an array of options

if (options = (c for c in task.tool_config?.options when c.value is @getCurrentClassification().annotation?.value)) && options.length > 0 && (opt = options[0])? && opt.next_task?
if (options = (c for c in task.tool_config?.options when c.value is @getCurrentClassification()?.annotation?.value)) && options.length > 0 && (opt = options[0])? && opt.next_task?
nextKey = opt.next_task
else
nextKey = @getTasks()[@state.taskKey].next_task
Expand Down
51 changes: 41 additions & 10 deletions app/assets/stylesheets/verify-tool.styl
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,62 @@
label
margin 1em

ul
& > ul
padding-left 0
list-style none
text-align left

li
& > li

position relative
flexbox(flex)
flex-direction(row)
flex-wrap(nowrap)
padding-bottom 1em

button.edit-button
z-index 2
opacity 0.6
padding 0.2em 0.6em
margin-left 10px

flex(shrink: 0)

&:hover
opacity 1

a
color black
text-decoration none
// display block
flex(grow: 1, shrink: 1)
background-color white
border-radius 6px

opacity 0.7

ul.choice
margin 1em 0
z-index 1
// margin 1em 0
padding 0.5em

background-color white
border-radius 6px

opacity 0.7
list-style none

span
font-weight bold

&.value
font-family "courier new", "courier", monospace

&.label
padding-right 10px
font-weight normal

&:hover
opacity 1
&:hover
opacity 1
box-shadow 0 0 3px 3px rgba(0,0,0,.1)

ul
background-image url(/assets/checkmark.png)
background-repeat no-repeat
background-position 96% center

3 changes: 3 additions & 0 deletions app/models/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class Workflow
# this `false` to prevent a user's transcriptions from being verified by same
# user:
field :subjects_classifiable_by_creator, type: Boolean, default: true
# Controls whether the user-generated subject shown may be "edited" (cloned, really)
# Currently only implemented as an EDIT button in Verify (user can transcribe using a prev transcription as a basis)
field :subjects_editable, type: Boolean, default: true
field :active_subjects, type: Integer, default: 0
field :order, type: Integer, default: 0

Expand Down
2 changes: 1 addition & 1 deletion app/serializers/workflow_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class WorkflowSerializer < ActiveModel::MongoidSerializer
attributes :id, :name, :label, :tasks, :retire_limit, :subject_fetch_limit, :first_task, :active_subjects, :generates_subjects_for, :order
attributes :id, :name, :label, :tasks, :retire_limit, :subject_fetch_limit, :first_task, :active_subjects, :generates_subjects_for, :order, :subjects_editable

def id
object._id.to_s
Expand Down
1 change: 1 addition & 0 deletions project/emigrant/workflows/verify.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"generates_subjects_max": 20,
"generates_subjects_agreement": 0.75,
"subjects_classifiable_by_creator": false,
"subjects_editable": true,

"tasks": {

Expand Down