Projekt

Obecné

Profil

« Předchozí | Další » 

Revize a547b12c

Přidáno uživatelem Lukáš Vlček před více než 2 roky(ů)

Occurrence - like canceling

Zobrazit rozdíly:

webapp/components/annotation/AnnotationOccurrenceItem.tsx
3 3
import { ChangeEvent, useContext } from 'react';
4 4
import 'antd/dist/antd.css';
5 5
import { Button, Input, Select } from 'antd';
6
import { DeleteOutlined, EyeOutlined, LikeOutlined } from '@ant-design/icons';
6
import {
7
    DeleteOutlined,
8
    DislikeOutlined,
9
    EyeOutlined,
10
    LikeOutlined,
11
} from '@ant-design/icons';
7 12
import { AnnotationContext } from '../../contexts/AnnotationContext';
8 13
import { ETagSentiment, TagInstanceInfo } from '../../api';
9 14
import { getNameTruncated, getTextMaxLength } from '../../utils/strings';
......
153 158
                    />
154 159
                    {isFinal && (
155 160
                        <Button
156
                            icon={<LikeOutlined />}
157
                            title={'Označit jako správné řešení'}
161
                            icon={
162
                                props.occurrence.isFinal ? (
163
                                    <DislikeOutlined />
164
                                ) : (
165
                                    <LikeOutlined />
166
                                )
167
                            }
168
                            title={
169
                                props.occurrence.isFinal
170
                                    ? 'ZRUŠIT označení správného řešení'
171
                                    : 'Označit jako správné řešení'
172
                            }
158 173
                            onClick={() => {
159
                                ShowConfirm(() => {
160
                                    makeOccurrenceFinal(props.occurrence);
161
                                }, 'označit toto řešení jako správné');
174
                                ShowConfirm(
175
                                    () => {
176
                                        makeOccurrenceFinal(
177
                                            props.occurrence,
178
                                            !props.occurrence.isFinal
179
                                        );
180
                                    },
181
                                    props.occurrence.isFinal
182
                                        ? 'ZRUŠIT označené správného řešení'
183
                                        : 'označit toto řešení jako správné'
184
                                );
162 185
                            }}
163 186
                            className={'mt-1'}
164 187
                        />
webapp/contexts/AnnotationContext.tsx
79 79
     */
80 80
    changeSentiment: (occurrence: TagInstanceInfo, newValue: ETagSentiment) => void;
81 81

  
82
    makeOccurrenceFinal: (occurrence: TagInstanceInfo) => void;
82
    makeOccurrenceFinal: (occurrence: TagInstanceInfo, final: boolean) => void;
83 83

  
84 84
    annotation: AnnotationInfo | null;
85 85
    mappedTags: Tag[] | null;
......
206 206
    },
207 207

  
208 208
    isFinal: false,
209
    makeOccurrenceFinal: (occurrence: TagInstanceInfo) => {
209
    makeOccurrenceFinal: (occurrence: TagInstanceInfo, final: boolean) => {
210 210
        return;
211 211
    },
212 212
});
......
425 425
        setMappedTags(Array.from(map.values()));
426 426
    };
427 427

  
428
    async function makeOccurrenceFinal(occurrence: TagInstanceInfo) {
428
    async function makeOccurrenceFinal(
429
        occurrence: TagInstanceInfo,
430
        final: boolean = true
431
    ) {
429 432
        if (!occurrence?.occurenceId) {
430 433
            return;
431 434
        }
......
433 436
        await annotationController.annotationAnnotationIdOccurenceIdFinalPut(
434 437
            props.annotationId,
435 438
            occurrence.occurenceId,
436
            { isFinal: true }
439
            { isFinal: final }
437 440
        );
438 441

  
439 442
        await refreshAnnotation();

Také k dispozici: Unified diff