Projekt

Obecné

Profil

Stáhnout (1.63 KB) Statistiky
| Větev: | Tag: | Revize:
1
import { SubTagInfo, TagInfo } from '../../api';
2
import { Container, Row } from 'react-bootstrap';
3
import { Button, Tooltip } from 'antd';
4
import React, { useContext } from 'react';
5
import { TagCategoryContext } from '../../contexts/TagCategoryContext';
6
import { AnnotationContext } from '../../contexts/AnnotationContext';
7
import { QuestionCircleOutlined } from '@ant-design/icons';
8

    
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
export function SubTagItem(props: { tag: TagInfo; subTag: SubTagInfo }) {
15
    /**
16
     * Tag context.
17
     */
18
    const { selectTag } = useContext(TagCategoryContext);
19

    
20
    /**
21
     * Annotation context
22
     */
23
    const { submitting } = useContext(AnnotationContext);
24

    
25
    /**
26
     * Selects the sub tag.
27
     */
28
    const onSelectSubTag = () => {
29
        selectTag(props.tag, props.subTag);
30
    };
31

    
32
    return (
33
        <Container>
34
            <Row>
35
                <Button
36
                    onClick={onSelectSubTag}
37
                    className="w-100 text-start rounded"
38
                    disabled={submitting}
39
                >
40
                    {props.subTag.name}
41
                    {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
                </Button>
50
            </Row>
51
        </Container>
52
    );
53
}
(5-5/7)