Projekt

Obecné

Profil

Stáhnout (1.98 KB) Statistiky
| Větev: | Tag: | Revize:
1 669ffe38 Jaroslav Hrubý
import { Button, Input, Space } from 'antd';
2
import { SearchOutlined } from '@ant-design/icons';
3
import React from 'react';
4
import { style } from 'dom-helpers';
5
6
export const getLocaleProps = () => ({
7
    filterSearchPlaceholder: 'Hledat uživatele',
8
    triggerDesc: 'Seřadit sestupně',
9
    triggerAsc: 'Seřadit vzestupně',
10
    cancelSort: 'Vypnout řazení',
11
});
12
13
const handleSearch = (
14
    selectedKeys: React.SetStateAction<string>[],
15
    confirm: () => void
16
) => {
17
    confirm();
18
};
19
20
const handleReset = (clearFilters: () => void) => {
21
    clearFilters();
22
};
23
24
export const getColumnSearchProps = (dataIndex: string, searchLabel: string) => ({
25
    // @ts-ignore
26
    filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => (
27
        <div style={{ padding: 8 }}>
28
            <Input
29
                placeholder={`Vyhledat ${searchLabel}`}
30
                value={selectedKeys[0]}
31
                onChange={(e) => setSelectedKeys(e.target.value ? [e.target.value] : [])}
32
                onPressEnter={() => handleSearch(selectedKeys, confirm)}
33
                style={{ marginBottom: 8, display: 'block' }}
34
            />
35
            <Space>
36
                <Button
37
                    type="primary"
38
                    onClick={() => handleSearch(selectedKeys, confirm)}
39
                    icon={<SearchOutlined />}
40
                    style={{ width: 90 }}
41
                >
42
                    Hledat
43
                </Button>
44
                <Button onClick={() => handleReset(clearFilters)} style={{ width: 90 }}>
45
                    Smazat
46
                </Button>
47
            </Space>
48
        </div>
49
    ),
50
    filterIcon: (filtered: any) => (
51
        <SearchOutlined
52
            style={{ color: filtered ? '#1890ff' : '#757575', fontSize: '140%' }}
53
        />
54
    ),
55
    onFilter: (value: string, record: { [x: string]: { toString: () => string } }) =>
56
        record[dataIndex]
57
            ? record[dataIndex].toString().toLowerCase().includes(value.toLowerCase())
58
            : '',
59
});