Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 61acc160

Přidáno uživatelem Dominik Poch před asi 2 roky(ů)

Added note of a document

Zobrazit rozdíly:

webapp/components/annotation/DocumentAnnotationView.tsx
2 2
 * Creates an annotation view of a document.
3 3
 * @returns The annotation view.
4 4
 */
5
import { useContext } from 'react';
5
import { ChangeEvent, useContext } from 'react';
6 6
import { AnnotationContext } from '../../contexts/AnnotationContext';
7
import { Button } from 'antd';
7
import { Button, Input, Space } from 'antd';
8 8

  
9 9
export function DocumentAnnotationView() {
10
    const { annotation } = useContext(AnnotationContext);
10
    const { annotation, changeDocumentNote } = useContext(AnnotationContext);
11 11

  
12 12
    if (!annotation) {
13 13
        return <p>Probíhá načítání anotace ...</p>;
14 14
    }
15 15

  
16
    const onChangeNote = (e: ChangeEvent<HTMLTextAreaElement>) => {
17
        changeDocumentNote(e.currentTarget.value);
18
    };
19

  
16 20
    return (
17 21
        <div>
22
            <div className="mb-3">
23
                <h5>Poznámka</h5>
24
                <Input.TextArea
25
                    defaultValue={annotation.note ?? ''}
26
                    onBlur={onChangeNote}
27
                />
28
            </div>
29
            <h5>Obsah</h5>
18 30
            <div
19 31
                dangerouslySetInnerHTML={{ __html: annotation.documentToRender ?? '' }}
20 32
            />
webapp/contexts/AnnotationContext.tsx
58 58
     */
59 59
    changeLength: (occurrence: TagInstanceInfo, newValue: number) => void;
60 60

  
61
    changeDocumentNote: (newValue: string) => void;
62

  
61 63
    /**
62 64
     * Changes a note of an occurrence of an annotation.
63 65
     * @param occurrence Occurrence whose note should be changed.
......
139 141
        return;
140 142
    },
141 143

  
144
    changeDocumentNote: (newValue: string) => {
145
        return;
146
    },
147

  
142 148
    /**
143 149
     * Changes a note of an occurrence of an annotation.
144 150
     * @param occurrence Occurrence whose note should be changed.
......
272 278
        //TODO: Implement method (should use objects from server API)
273 279
    };
274 280

  
281
    const changeDocumentNote = async (newValue: string) => {
282
        const posRes = await annotationController.annotationAnnotationIdNotePost(
283
            props.annotationId,
284
            { note: newValue }
285
        );
286

  
287
        if (annotation) {
288
            annotation.note = newValue;
289
        }
290
    };
291

  
275 292
    /**
276 293
     * Changes a note of an occurrence of an annotation.
277 294
     * @param occurrence Occurrence whose note should be changed.
......
366 383
                deleteOccurrence,
367 384
                changeLength,
368 385
                changePosition,
386
                changeDocumentNote,
369 387
                changeNote,
370 388
                changeSentiment,
371 389
                refreshAnnotation,

Také k dispozici: Unified diff