Projekt

Obecné

Profil

« Předchozí | Další » 

Revize bcbaa7d3

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

Removed visibility, added sentiment

Zobrazit rozdíly:

webapp/components/annotation/AnnotationItem.tsx
2 2
import { Tag } from '../types/tag';
3 3
import { ChangeEvent, useContext, useState } from 'react';
4 4
import 'antd/dist/antd.css';
5
import { Button, Input } from 'antd';
5
import { Button, Input, Select } from 'antd';
6 6
import {
7 7
    PlusOutlined,
8
    EyeOutlined,
9 8
    DownOutlined,
10 9
    DeleteOutlined,
11 10
    TagOutlined,
12 11
} from '@ant-design/icons';
13 12
import { AnnotationContext } from '../../contexts/AnnotationContext';
14
import { TagInstanceInfo } from '../../api';
13
import { ETagSentiment, TagInstanceInfo } from '../../api';
14

  
15
const { Option } = Select;
15 16

  
16 17
/**
17 18
 * Creates a single item in an annotation panel.
......
32 33
    const {
33 34
        addOccurrence,
34 35
        deleteOccurrence,
35
        changeVisibility,
36 36
        changePosition,
37
        changeSentiment,
37 38
        changeLength,
38 39
    } = useContext(AnnotationContext);
39 40

  
......
52 53
        deleteOccurrence(occurrence);
53 54
    };
54 55

  
55
    /**
56
     * Changes visibility of this annotation in the context.
57
     */
58
    const onChangeVisibility = () => {
59
        changeVisibility(props.tag);
60
    };
61

  
62 56
    /**
63 57
     * Changes a position of an occurrence of this annotation in the context.
64 58
     * @param occurrence The occurrence that should be changed.
......
77 71
            changeLength(occurrence, Number(e.currentTarget.value));
78 72
        };
79 73

  
74
    const onChangeSentiment = (occurrence: TagInstanceInfo) => (val: ETagSentiment) => {
75
        changeSentiment(occurrence, val);
76
    };
77

  
80 78
    /**
81 79
     * Changes visibility of properties of this annotation.
82 80
     */
......
101 99
                        icon={<PlusOutlined />}
102 100
                        onClick={onAddOccurrence}
103 101
                    />
104
                    <Button
105
                        type="text"
106
                        shape="circle"
107
                        icon={<EyeOutlined />}
108
                        onClick={onChangeVisibility}
109
                    />
110 102
                    <Button
111 103
                        type="text"
112 104
                        shape="circle"
......
121 113
                    <div>Výskyty:</div>
122 114
                    {props.tag.occurrences.map((occurrence, index) => {
123 115
                        return (
124
                            <Container key={index} className="shadow-sm">
125
                                <Row className="mb-1 mt-1">
116
                            <Container key={index} className="shadow-sm pb-1 pt-1">
117
                                <Row>
126 118
                                    <Col>
127 119
                                        <Row>
128
                                            <Col className="d-flex align-items-center">
120
                                            <Col
121
                                                className="d-flex align-items-center"
122
                                                sm="4"
123
                                            >
129 124
                                                Pozice:
130 125
                                            </Col>
131
                                            <Col sm="auto">
126
                                            <Col>
132 127
                                                <Input
133 128
                                                    value={occurrence.position}
134 129
                                                    onChange={onChangePosition(
......
138 133
                                            </Col>
139 134
                                        </Row>
140 135
                                        <Row>
141
                                            <Col className="d-flex align-items-center">
136
                                            <Col
137
                                                className="d-flex align-items-center"
138
                                                sm="4"
139
                                            >
142 140
                                                Délka:
143 141
                                            </Col>
144
                                            <Col sm="auto">
142
                                            <Col>
145 143
                                                <Input
146 144
                                                    value={occurrence.length}
147 145
                                                    onChange={onChangeLength(occurrence)}
148 146
                                                />
149 147
                                            </Col>
150 148
                                        </Row>
149
                                        {occurrence.sentiment && (
150
                                            <Row>
151
                                                <Col
152
                                                    className="d-flex align-items-center"
153
                                                    sm="4"
154
                                                >
155
                                                    Sentiment:
156
                                                </Col>
157
                                                <Col>
158
                                                    <Select
159
                                                        value={occurrence.sentiment}
160
                                                        style={{ width: '100%' }}
161
                                                        onChange={onChangeSentiment(
162
                                                            occurrence
163
                                                        )}
164
                                                    >
165
                                                        <Option
166
                                                            value={ETagSentiment.Positive}
167
                                                        >
168
                                                            Pozitivní
169
                                                        </Option>
170
                                                        <Option
171
                                                            value={ETagSentiment.Neutral}
172
                                                        >
173
                                                            Neutrální
174
                                                        </Option>
175
                                                        <Option
176
                                                            value={ETagSentiment.Negative}
177
                                                        >
178
                                                            Negativní
179
                                                        </Option>
180
                                                    </Select>
181
                                                </Col>
182
                                            </Row>
183
                                        )}
151 184
                                    </Col>
152 185
                                    <Col sm="auto" className="d-flex align-items-center">
153 186
                                        <Button

Také k dispozici: Unified diff