aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/selectedDoc/SelectedDocView.tsx
blob: 2139919e0ea51526b67f4271258cbabbf9f40fc3 (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
import React = require('react');
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { ListBox } from 'browndash-components';
import { computed } from 'mobx';
import { observer } from 'mobx-react';
import { Doc } from '../../../fields/Doc';
import { StrCast } from '../../../fields/Types';
import { DocumentManager } from '../../util/DocumentManager';
import { DocFocusOptions } from '../nodes/DocumentView';
import { emptyFunction } from '../../../Utils';
import { SettingsManager } from '../../util/SettingsManager';

export interface SelectedDocViewProps {
    selectedDocs: Doc[];
}

@observer
export class SelectedDocView extends React.Component<SelectedDocViewProps> {
    @computed get selectedDocs() {
        return this.props.selectedDocs;
    }

    render() {
        return (
            <div className="selectedDocView-container">
                <ListBox
                    items={this.selectedDocs.map(doc => {
                        const options: DocFocusOptions = {
                            playAudio: false,
                            playMedia: false,
                            willPan: true,
                        };
                        return {
                            text: StrCast(doc.title),
                            val: StrCast(doc._id),
                            color: SettingsManager.userColor,
                            background: SettingsManager.userBackgroundColor,
                            icon: <FontAwesomeIcon size={'1x'} icon={Doc.toIcon(doc)} />,
                            onClick: () => DocumentManager.Instance.showDocument(doc, options, emptyFunction),
                        };
                    })}
                    color={SettingsManager.userColor}
                    background={SettingsManager.userBackgroundColor}
                />
            </div>
        );
    }
}