Projekt

Obecné

Profil

Stáhnout (1.16 KB) Statistiky
| Větev: | Tag: | Revize:
1
import { EState, UserInfo } from '../api';
2

    
3
export function getName(user: UserInfo) {
4
    //return `${user.name} ${user.surname}`;
5
    return `${user.surname} ${user.name}`;
6
}
7

    
8
export function getNameTruncated(user: UserInfo, maxLength: number = 15) {
9
    const name = getName(user);
10
    return getTextMaxLength(name, maxLength);
11
}
12

    
13
export function getTextMaxLength(text: string, maxLength: number) {
14
    if (text.length > maxLength) {
15
        return text.substring(0, maxLength - 3) + '...';
16
    } else {
17
        return text;
18
    }
19
}
20

    
21
export function getUserInfoAlt(user: UserInfo) {
22
    return `${getName(user)}\nUživatelské jméno: ${user.username}`;
23
}
24

    
25
export function getAnnotationStateString(state: EState) {
26
    switch (state) {
27
        case 'NEW':
28
            return 'Nový';
29
        case 'IN_PROGRESS':
30
            return 'Rozpracovaný';
31
        case 'DONE':
32
            return 'Hotovo';
33
    }
34
}
35

    
36
export function getAnnotationStateColor(state: EState | undefined) {
37
    switch (state) {
38
        case 'NEW':
39
            return 'indianred';
40
        case 'IN_PROGRESS':
41
            return 'orange';
42
        case 'DONE':
43
            return 'green';
44
    }
45
    return 'black';
46
}
(5-5/6)