summaryrefslogtreecommitdiff
path: root/animism-align/frontend/views/align/components/annotations/annotation.index.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-07-06 17:57:25 +0200
committerJules Laplace <julescarbon@gmail.com>2020-07-06 17:57:25 +0200
commit6f5ff3cdfac3fc154281fdda7c1ec9ff7ebbd1fa (patch)
tree9a51dd4b32edf3b1bc8c24d95273575dab774d34 /animism-align/frontend/views/align/components/annotations/annotation.index.js
parent349ee65db67aa0d28d3861530e8e7e1b5cc27c48 (diff)
paragraph list view
Diffstat (limited to 'animism-align/frontend/views/align/components/annotations/annotation.index.js')
-rw-r--r--animism-align/frontend/views/align/components/annotations/annotation.index.js32
1 files changed, 30 insertions, 2 deletions
diff --git a/animism-align/frontend/views/align/components/annotations/annotation.index.js b/animism-align/frontend/views/align/components/annotations/annotation.index.js
index 8121d1d..d5c1eed 100644
--- a/animism-align/frontend/views/align/components/annotations/annotation.index.js
+++ b/animism-align/frontend/views/align/components/annotations/annotation.index.js
@@ -4,7 +4,7 @@ import { connect } from 'react-redux'
import actions from '../../../../actions'
-import { ZOOM_STEPS } from '../../constants'
+import { ZOOM_STEPS, INNER_HEIGHT } from '../../constants'
import { clamp } from '../../../../util'
import { positionToTime, timeToPosition } from '../../align.util'
@@ -30,7 +30,7 @@ class AnnotationIndex extends Component {
const { order, lookup } = index
let secondsPerPixel = ZOOM_STEPS[zoom] * 0.1 // 0.1 sec / step
- let widthTimeDuration = window.innerHeight * secondsPerPixel // secs per pixel
+ let widthTimeDuration = INNER_HEIGHT * secondsPerPixel // secs per pixel
let timeMin = start_ts - 30.0
let timeMax = Math.min(start_ts + widthTimeDuration, duration)
@@ -43,9 +43,37 @@ class AnnotationIndex extends Component {
}
handleClick(e, annotation) {
e.stopPropagation()
+ if (e.shiftKey) {
+ e.preventDefault()
+ this.handleParagraphSelection(annotation)
+ }
actions.audio.seek(annotation.start_ts)
actions.align.setSelectedAnnotation(annotation.id)
}
+ handleParagraphSelection(annotation) {
+ const { selected_paragraph_id } = this.props.timeline
+ console.log("___________________")
+ console.log(annotation)
+ console.log(selected_paragraph_id)
+ if (!selected_paragraph_id || selected_paragraph_id === -1) {
+ if (annotation.paragraph_id) {
+ actions.align.setSelectedParagraph(annotation.paragraph_id)
+ } else {
+ actions.paragraph.create({
+ type: 'paragraph',
+ start_ts: annotation.start_ts,
+ }) .then(data => {
+ console.log(data.res)
+ actions.align.setSelectedParagraph(data.res.id)
+ annotation.paragraph_id = data.res.id
+ actions.annotation.update(annotation)
+ })
+ }
+ } else if (selected_paragraph_id !== annotation.paragraph_id) {
+ annotation.paragraph_id = selected_paragraph_id
+ actions.annotation.update(annotation)
+ }
+ }
handleDoubleClick(e, annotation) {
e.stopPropagation()
actions.align.showEditAnnotationForm(annotation)