aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/search/IconBar.tsx
blob: 9b7cf2fc600d91f4e80d2a9308d351d624bc93bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import * as React from 'react';
import { observer } from 'mobx-react';
import { observable, action } from 'mobx';
// import "./SearchBox.scss";
import "./IconBar.scss";
import "./IconButton.scss";
import { faSearch, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote, faMusic, faLink, faChartBar, faGlobeAsia, faBan, faTimesCircle, faCheckCircle } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { library } from '@fortawesome/fontawesome-svg-core';
import * as _ from "lodash";
import { IconButton } from './IconButton';
import { DocumentType } from "../../documents/DocumentTypes";


library.add(faSearch);
library.add(faObjectGroup);
library.add(faImage);
library.add(faStickyNote);
library.add(faFilePdf);
library.add(faFilm);
library.add(faMusic);
library.add(faLink);
library.add(faChartBar);
library.add(faGlobeAsia);
library.add(faBan);

export interface IconBarProps {
    setIcons: (icons: string[]) => void;
}


@observer
export class IconBar extends React.Component<IconBarProps> {
    public _allIcons: string[] = [DocumentType.AUDIO, DocumentType.COL, DocumentType.IMG, DocumentType.LINK, DocumentType.PDF, DocumentType.RTF, DocumentType.VID, DocumentType.WEB];

    @observable private _icons: string[] = this._allIcons;

    static Instance: IconBar;

    @observable public _resetClicked: boolean = false;
    @observable public _selectAllClicked: boolean = false;
    @observable public _reset: number = 0;
    @observable public _select: number = 0;

    @action.bound
    updateIcon(newArray: string[]) {
        this._icons = newArray;
        this.props.setIcons?.(this._icons);
    }

    @action.bound
    getIcons(): string[] { return this._icons; }

    constructor(props: any) {
        super(props);
        IconBar.Instance = this;
    }

    @action.bound
    getList(): string[] { return this.getIcons(); }

    @action.bound
    updateList(newList: string[]) { this.updateIcon(newList); }

    @action.bound
    resetSelf = () => {
        this._resetClicked = true;
        this.updateList([]);
    }

    @action.bound
    selectAll = () => {
        this._selectAllClicked = true;
        this.updateList(this._allIcons);
    }

    render() {
        return (
            <div className="icon-bar">
                {this._allIcons.map((type: string) =>
                    <IconButton key={type.toString()} type={type} />
                )}
            </div>
        );
    }
}