Skip to content
Snippets Groups Projects
Commit e7b645bd authored by Anthony's avatar Anthony
Browse files

Merge branch 'annotaton-panel-title' into 'mui5-tetras-main-stable'

integration of title into annotation

See merge request !12
parents daaf1d4c ea2acecf
No related branches found
No related tags found
2 merge requests!12integration of title into annotation,!10Draft: MigratingAnnotationCreation to MUI5.
Pipeline #1692 failed
...@@ -7,5 +7,3 @@ ...@@ -7,5 +7,3 @@
npm-debug.log* npm-debug.log*
.idea .idea
.package-lock.json .package-lock.json
```
/package-lock.json
mirador @ fd236dcb
Subproject commit 9f36a451d213fffb794e41198bc312e2b9cfa80e Subproject commit fd236dcb8581ca647b90793e29578fbdd2709bc0
...@@ -33,7 +33,7 @@ import CursorIcon from './icons/Cursor'; ...@@ -33,7 +33,7 @@ import CursorIcon from './icons/Cursor';
import HMSInput from './HMSInput'; import HMSInput from './HMSInput';
import ImageFormField from './ImageFormField'; import ImageFormField from './ImageFormField';
import { secondsToHMS } from './utils'; import { secondsToHMS } from './utils';
import RangeSlider from './slider'; import TextField from '@mui/material/TextField';
/** Extract time information from annotation target */ /** Extract time information from annotation target */
function timeFromAnnoTarget(annotarget) { function timeFromAnnoTarget(annotarget) {
...@@ -107,7 +107,6 @@ class AnnotationCreation extends Component { ...@@ -107,7 +107,6 @@ class AnnotationCreation extends Component {
} }
} }
const toolState = { const toolState = {
activeTool: 'cursor', activeTool: 'cursor',
closedMode: 'closed', closedMode: 'closed',
...@@ -143,6 +142,7 @@ class AnnotationCreation extends Component { ...@@ -143,6 +142,7 @@ class AnnotationCreation extends Component {
...annoState, ...annoState,
valuetextTime: '', valuetextTime: '',
mediaVideo: null, mediaVideo: null,
title: '',
}; };
this.submitForm = this.submitForm.bind(this); this.submitForm = this.submitForm.bind(this);
...@@ -166,12 +166,14 @@ class AnnotationCreation extends Component { ...@@ -166,12 +166,14 @@ class AnnotationCreation extends Component {
this.handleImgChange = this.handleImgChange.bind(this); this.handleImgChange = this.handleImgChange.bind(this);
this.handleChangeTime = this.handleChangeTime.bind(this); this.handleChangeTime = this.handleChangeTime.bind(this);
this.valuetextTime = this.valuetextTime.bind(this); this.valuetextTime = this.valuetextTime.bind(this);
this.updateTitle = this.updateTitle.bind(this);
} }
componentDidMount() { componentDidMount() {
const mediaVideo = VideosReferences.get(this.props.windowId); const mediaVideo = VideosReferences.get(this.props.windowId);
this.setState({ mediaVideo }); // Update mediaVideo in state this.setState({ mediaVideo }); // Update mediaVideo in state
} }
/** */ /** */
handleImgChange(newUrl, imgRef) { handleImgChange(newUrl, imgRef) {
const { image } = this.state; const { image } = this.state;
...@@ -227,7 +229,10 @@ class AnnotationCreation extends Component { ...@@ -227,7 +229,10 @@ class AnnotationCreation extends Component {
this.setState({ tend: value }); this.setState({ tend: value });
} }
/** seekTo/goto annotation start time */ updateTitle(e){
const thisTitle = e.target.value;
this.setState({title : thisTitle});
}
/** seekTo/goto annotation end time */ /** seekTo/goto annotation end time */
seekToTend() { seekToTend() {
...@@ -308,6 +313,7 @@ class AnnotationCreation extends Component { ...@@ -308,6 +313,7 @@ class AnnotationCreation extends Component {
config, config,
} = this.props; } = this.props;
const { const {
title,
textBody, textBody,
image, image,
tags, tags,
...@@ -324,6 +330,7 @@ class AnnotationCreation extends Component { ...@@ -324,6 +330,7 @@ class AnnotationCreation extends Component {
const storageAdapter = config.annotation.adapter(canvas.id); const storageAdapter = config.annotation.adapter(canvas.id);
const anno = new WebAnnotation({ const anno = new WebAnnotation({
title,
body, body,
canvasId: canvas.id, canvasId: canvas.id,
fragsel: { fragsel: {
...@@ -351,6 +358,7 @@ class AnnotationCreation extends Component { ...@@ -351,6 +358,7 @@ class AnnotationCreation extends Component {
}); });
this.setState({ this.setState({
title: '',
image: { id: null }, image: { id: null },
svg: null, svg: null,
tend: 0, tend: 0,
...@@ -380,6 +388,7 @@ class AnnotationCreation extends Component { ...@@ -380,6 +388,7 @@ class AnnotationCreation extends Component {
this.setState({ textBody }); this.setState({ textBody });
} }
/** */ /** */
updateGeometry({ updateGeometry({
svg, svg,
...@@ -419,6 +428,7 @@ class AnnotationCreation extends Component { ...@@ -419,6 +428,7 @@ class AnnotationCreation extends Component {
image, image,
valueTime, valueTime,
mediaVideo, mediaVideo,
title
} = this.state; } = this.state;
// TODO : Vérifier ce code, c'est étrange de comprarer un typeof à une chaine de caractère. // TODO : Vérifier ce code, c'est étrange de comprarer un typeof à une chaine de caractère.
...@@ -430,9 +440,10 @@ class AnnotationCreation extends Component { ...@@ -430,9 +440,10 @@ class AnnotationCreation extends Component {
const isVideoDataLoaded = mediaVideo && mediaVideo.video && !isNaN(mediaVideo.video.duration) && mediaVideo.video.duration > 0; const isVideoDataLoaded = mediaVideo && mediaVideo.video && !isNaN(mediaVideo.video.duration) && mediaVideo.video.duration > 0;
return ( return (
<CompanionWindow <CompanionWindow
title={annotation ? 'Edit annotation' : 'New annotation'} title={title ? title : 'New Annotation'}
windowId={windowId} windowId={windowId}
id={id} id={id}
> >
...@@ -453,18 +464,22 @@ class AnnotationCreation extends Component { ...@@ -453,18 +464,22 @@ class AnnotationCreation extends Component {
> >
<div> <div>
<Grid item xs={12}> <Grid item xs={12}>
<Typography variant="overline"> <TextField
Text Content id="outlined-basic"
</Typography> label="Title"
variant="outlined"
onChange={this.updateTitle}
/>
</Grid> </Grid>
<Grid item xs={12}> </div>
<Grid>
<Typography>TODO:METTRE CE CHAMPS TEXTE EN ONGLET</Typography>
<TextEditor <TextEditor
key={textEditorStateBustingKey} key={textEditorStateBustingKey}
annoHtml={textBody} annoHtml={textBody}
updateAnnotationBody={this.updateTextBody} updateAnnotationBody={this.updateTextBody}
/> />
</Grid> </Grid>
</div>
<div> <div>
{mediaIsVideo && ( {mediaIsVideo && (
...@@ -472,10 +487,6 @@ class AnnotationCreation extends Component { ...@@ -472,10 +487,6 @@ class AnnotationCreation extends Component {
<Grid <Grid
item item
xs={12} xs={12}
sx={{
display: 'flex',
flexWrap: 'wrap',
}}
> >
<Typography id="range-slider" variant="overline"> <Typography id="range-slider" variant="overline">
Display period Display period
...@@ -502,12 +513,11 @@ class AnnotationCreation extends Component { ...@@ -502,12 +513,11 @@ class AnnotationCreation extends Component {
<Typography>Loading video data...</Typography> <Typography>Loading video data...</Typography>
)} )}
</Grid> </Grid>
<div style={{ <div style={{
alignContent: 'center', alignContent: 'center',
display: 'flex', display: 'flex',
flexDirection: 'wrap', flexDirection: 'column',
gap: '5px', gap: '5px',
padding: '5px', padding: '5px',
}} }}
......
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
export default class WebAnnotation { export default class WebAnnotation {
/** */ /** */
constructor({ constructor({
canvasId, id, fragsel, image, body, tags, svg, manifestId, canvasId, id, fragsel, image, body, tags, svg, manifestId, title
}) { }) {
this.title = title;
this.id = id; this.id = id;
this.canvasId = canvasId; this.canvasId = canvasId;
this.fragsel = fragsel; this.fragsel = fragsel;
...@@ -17,6 +18,7 @@ export default class WebAnnotation { ...@@ -17,6 +18,7 @@ export default class WebAnnotation {
/** */ /** */
toJson() { toJson() {
return { return {
title: this.title,
body: this.createBody(), body: this.createBody(),
id: this.id, id: this.id,
motivation: 'commenting', motivation: 'commenting',
...@@ -45,6 +47,13 @@ export default class WebAnnotation { ...@@ -45,6 +47,13 @@ export default class WebAnnotation {
bodies.push(imgBody); bodies.push(imgBody);
} }
if(this.title){
const title={
type: 'AnnotationTitle',
value: this.title,
}
}
if (this.tags) { if (this.tags) {
bodies = bodies.concat(this.tags.map((tag) => ({ bodies = bodies.concat(this.tags.map((tag) => ({
purpose: 'tagging', purpose: 'tagging',
...@@ -80,8 +89,7 @@ export default class WebAnnotation { ...@@ -80,8 +89,7 @@ export default class WebAnnotation {
.map((kv) => `${kv[0]}=${kv[1]}`) .map((kv) => `${kv[0]}=${kv[1]}`)
.join('&'), .join('&'),
}); });
} }target.selector = selectors.length === 1 ? selectors[0] : selectors;
target.selector = selectors.length === 1 ? selectors[0] : selectors;
return target; return target;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment