Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 5593c10b

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

Connected tag panel to server

Zobrazit rozdíly:

webapp/components/annotation/TagItem.tsx
2 2
import { TagInfo } from '../../api';
3 3
import { Button } from 'antd';
4 4
import { DownOutlined, TagOutlined } from '@ant-design/icons';
5
import { useState } from 'react';
5
import { useContext, useState } from 'react';
6 6
import { SubTagItem } from './SubTagItem';
7
import { TagCategoryContext } from '../../contexts/TagCategoryContext';
7 8

  
8 9
/**
9 10
 * Creates a single tag item in a tag panel.
......
16 17
     */
17 18
    const [visibleSubTags, setVisibleSubTags] = useState(false);
18 19

  
20
    const { selectTag } = useContext(TagCategoryContext);
21

  
19 22
    /**
20 23
     * Changes visibility of sub tags.
21 24
     */
......
26 29
    /**
27 30
     * Selects the tag.
28 31
     */
29
    const selectTag = () => {};
32
    const onSelectTag = () => {
33
        selectTag(props.tag, null);
34
    };
30 35

  
31 36
    return (
32 37
        <Container>
......
45 50
                    {!props.tag.subTags && (
46 51
                        <Button
47 52
                            type="text"
48
                            onClick={selectTag}
53
                            onClick={onSelectTag}
49 54
                            className="w-100 text-start"
50 55
                        >
51 56
                            {props.tag.name}
......
59 64
            {props.tag.subTags && visibleSubTags && (
60 65
                <Stack>
61 66
                    {props.tag.subTags?.map((subTag, index) => (
62
                        <SubTagItem subTag={subTag} key={index} />
67
                        <SubTagItem tag={props.tag} subTag={subTag} key={index} />
63 68
                    ))}
64 69
                </Stack>
65 70
            )}

Také k dispozici: Unified diff