Projekt

Obecné

Profil

« Předchozí | Další » 

Revize acb8a961

Přidáno uživatelem Dominik Poch před více než 2 roky(ů)

Added comments

Zobrazit rozdíly:

webapp/components/annotation/AnnotationItem.tsx
1 1
import { Col, Container, Row, Stack } from 'react-bootstrap';
2 2
import { Occurrence, Tag } from '../types/tag';
3 3
import { ChangeEvent, useContext, useState } from 'react';
4

  
5 4
import 'antd/dist/antd.css';
6 5
import { Button, Input } from 'antd';
7 6
import {
......
12 11
} from '@ant-design/icons';
13 12
import { AnnotationContext } from '../../contexts/AnnotationContext';
14 13

  
14
/**
15
 * Creates a single item in an annotation panel.
16
 * @param props Properties should contain a tag that will be shown in this annotation.
17
 * @returns The item that represents an annotation.
18
 */
15 19
export function AnnotationItem(props: { tag: Tag }) {
20
    /**
21
     * Should properties of this annotation be visible?
22
     */
16 23
    const [visibleProperties, setVisibleProperties] = useState(false);
24

  
25
    /**
26
     * Context that manages annotations.
27
     */
17 28
    const {
18 29
        addOccurrence,
19 30
        deleteOccurrence,
......
22 33
        changeLength,
23 34
    } = useContext(AnnotationContext);
24 35

  
36
    /**
37
     * Adds new occurrence of this annotation to the context.
38
     */
25 39
    const onAddOccurrence = () => {
26 40
        addOccurrence(props.tag);
27 41
    };
28 42

  
43
    /**
44
     * Removes an occurrence of this annotation from the context.
45
     * @param occurrence The occurrence that should be removed.
46
     */
29 47
    const onDeleteOccurrence = (occurrence: Occurrence) => (e: any) => {
30 48
        deleteOccurrence(occurrence);
31 49
    };
32 50

  
51
    /**
52
     * Changes visibility of this annotation in the context.
53
     */
33 54
    const onChangeVisibility = () => {
34 55
        changeVisibility(props.tag);
35 56
    };
36 57

  
58
    /**
59
     * Changes a position of an occurrence of this annotation in the context.
60
     * @param occurrence The occurrence that should be changed.
61
     */
37 62
    const onChangePosition =
38 63
        (occurrence: Occurrence) => (e: ChangeEvent<HTMLInputElement>) => {
39 64
            changePosition(occurrence, Number(e.currentTarget.value));
40 65
        };
41 66

  
67
    /**
68
     * Changes a length of an occurrence of this annotation in the context.
69
     * @param occurrence The occurrence that should be changed.
70
     */
42 71
    const onChangeLength =
43 72
        (occurrence: Occurrence) => (e: ChangeEvent<HTMLInputElement>) => {
44 73
            changeLength(occurrence, Number(e.currentTarget.value));
45 74
        };
46 75

  
76
    /**
77
     * Changes visibility of properties of this annotation.
78
     */
47 79
    const changePropertiesVisibility = () => {
48 80
        setVisibleProperties(!visibleProperties);
49 81
    };

Také k dispozici: Unified diff