Projekt

Obecné

Profil

Stáhnout (1.63 KB) Statistiky
| Větev: | Tag: | Revize:
1 5593c10b Dominik Poch
import { SubTagInfo, TagInfo } from '../../api';
2 ed01528f Dominik Poch
import { Container, Row } from 'react-bootstrap';
3 a44aa67e Jaroslav Hrubý
import { Button, Tooltip } from 'antd';
4
import React, { useContext } from 'react';
5 5593c10b Dominik Poch
import { TagCategoryContext } from '../../contexts/TagCategoryContext';
6 dee53692 Jaroslav Hrubý
import { AnnotationContext } from '../../contexts/AnnotationContext';
7 a44aa67e Jaroslav Hrubý
import { QuestionCircleOutlined } from '@ant-design/icons';
8 ed01528f Dominik Poch
9
/**
10
 * Creates a single tag item in a tag panel.
11
 * @param props Properties should contain the tag.
12
 * @returns The item that represents the tag.
13
 */
14 5593c10b Dominik Poch
export function SubTagItem(props: { tag: TagInfo; subTag: SubTagInfo }) {
15 0441c314 Dominik Poch
    /**
16
     * Tag context.
17
     */
18 5593c10b Dominik Poch
    const { selectTag } = useContext(TagCategoryContext);
19
20 dee53692 Jaroslav Hrubý
    /**
21
     * Annotation context
22
     */
23
    const { submitting } = useContext(AnnotationContext);
24
25 ed01528f Dominik Poch
    /**
26
     * Selects the sub tag.
27
     */
28 5593c10b Dominik Poch
    const onSelectSubTag = () => {
29
        selectTag(props.tag, props.subTag);
30
    };
31 ed01528f Dominik Poch
32
    return (
33
        <Container>
34
            <Row>
35 dee53692 Jaroslav Hrubý
                <Button
36
                    onClick={onSelectSubTag}
37
                    className="w-100 text-start rounded"
38
                    disabled={submitting}
39
                >
40 ed01528f Dominik Poch
                    {props.subTag.name}
41 a44aa67e Jaroslav Hrubý
                    {props.subTag.description && props.subTag.description !== '' && (
42
                        <Tooltip
43
                            title={props.subTag.description}
44
                            key={props.subTag.description}
45
                        >
46
                            <QuestionCircleOutlined />
47
                        </Tooltip>
48
                    )}
49 ed01528f Dominik Poch
                </Button>
50
            </Row>
51
        </Container>
52
    );
53
}