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/contexts/AnnotationContext.tsx
1 1
import React, { createContext, useEffect, useState } from 'react';
2
import { AnnotationInfo, ETagType, SubTagInfo, TagInfo, TagInstanceInfo } from '../api';
2
import {
3
    AnnotationInfo,
4
    ETagSentiment,
5
    ETagType,
6
    SubTagInfo,
7
    TagInfo,
8
    TagInstanceInfo,
9
} from '../api';
3 10
import { Tag } from '../components/types/tag';
4 11
import { annotationController } from '../controllers';
5 12
import { GetSelectionInfo } from '../utils/selectionUtils';
......
25 32
     */
26 33
    addOccurrence: (tag: Tag) => void;
27 34

  
28
    /**
29
     * Changes visibility of an annotation.
30
     * @param tag Tag whose visibility should be changed.
31
     */
32
    changeVisibility: (tag: Tag) => void;
33

  
34 35
    /**
35 36
     * Deletes an occurrence of an annotation.
36 37
     * @param occurrence Occurrence that should be deleted.
......
51 52
     */
52 53
    changeLength: (occurrence: TagInstanceInfo, newValue: number) => void;
53 54

  
55
    /**
56
     * Changes sentiment of an annotation.
57
     * @param occurrence Occurrence whose sentiment should be changed.
58
     * @param newValue New value of the sentiment.
59
     */
60
    changeSentiment: (occurrence: TagInstanceInfo, newValue: ETagSentiment) => void;
61

  
54 62
    annotation: AnnotationInfo | null;
55 63
    mappedTags: Tag[] | null;
56 64
    refreshAnnotation: () => void;
......
87 95
        return;
88 96
    },
89 97

  
90
    /**
91
     * Default implementation of changeVisibility method.
92
     * @param tag The tag whose visibility should be changed.
93
     */
94
    changeVisibility: (tag: Tag) => {
95
        return;
96
    },
97

  
98 98
    /**
99 99
     * Default implementation of deleteOccurrence method.
100 100
     * @param occurrence Occurrence that should be deleted.
......
121 121
        return;
122 122
    },
123 123

  
124
    /**
125
     * Changes sentiment of an annotation.
126
     * @param occurrence Occurrence whose sentiment should be changed.
127
     * @param newValue New value of the sentiment.
128
     */
129
    changeSentiment: (occurrence: TagInstanceInfo, newValue: ETagSentiment) => {
130
        return;
131
    },
132

  
124 133
    annotation: null,
125 134
    mappedTags: null,
126 135
    refreshAnnotation: () => {
......
193 202
        await markSelectedText(tag.tagId, tag.subtagId ?? null, tag.instanceId);
194 203
    };
195 204

  
196
    /**
197
     * Changes visibility of an annotation.
198
     * @param tag Tag whose visibility should be changed.
199
     */
200
    const changeVisibility = (tag: Tag) => {
201
        //TODO: Implement method (should use objects from server API)
202
    };
203

  
204 205
    /**
205 206
     * Deletes an occurrence of an annotation.
206 207
     * @param occurrence Occurrence that should be deleted.
......
238 239
        //TODO: Implement method (should use objects from server API)
239 240
    };
240 241

  
242
    /**
243
     * Changes sentiment of an annotation.
244
     * @param occurrence Occurrence whose sentiment should be changed.
245
     * @param newValue New value of the sentiment.
246
     */
247
    const changeSentiment = async (
248
        occurrence: TagInstanceInfo,
249
        newValue: ETagSentiment
250
    ) => {
251
        if (!occurrence.instance) {
252
            console.log('invalid instance');
253
            return;
254
        }
255

  
256
        const putRes =
257
            await annotationController.annotationAnnotationIdInstanceIdSentimentPut(
258
                props.annotationId,
259
                occurrence.instance,
260
                { sentiment: newValue }
261
            );
262

  
263
        await refreshAnnotation();
264
    };
265

  
241 266
    const remapAnnotations = (data: AnnotationInfo) => {
242 267
        let map = new Map<string, Tag>();
243 268
        data.tagInstances?.forEach((tagInstance) => {
......
249 274
                    tagName: tagInstance.tagName ?? '',
250 275
                    subtagName: tagInstance.subTagName ?? null,
251 276
                    category: tagInstance.tagCategoryName ?? '',
252
                    visible: true,
253 277
                    occurrences: [tagInstance],
254 278
                    tagId: tagInstance.tagId ?? '',
255 279
                    instanceId: tagInstance.instance ?? '',
......
283 307
                tags,
284 308
                setTags,
285 309
                addOccurrence,
286
                changeVisibility,
287 310
                deleteOccurrence,
288 311
                changeLength,
289 312
                changePosition,
313
                changeSentiment,
290 314
                refreshAnnotation,
291 315
                annotation,
292 316
                mappedTags,

Také k dispozici: Unified diff