@performant-software/semantic-components 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/build/index.js +2 -0
- package/build/index.js.map +1 -0
- package/build/main.css +786 -0
- package/index.js +1 -0
- package/package.json +37 -0
- package/src/components/AccordionDataList.css +8 -0
- package/src/components/AccordionDataList.js +224 -0
- package/src/components/AccordionList.css +27 -0
- package/src/components/AccordionList.js +596 -0
- package/src/components/AccordionSelector.css +3 -0
- package/src/components/AccordionSelector.js +359 -0
- package/src/components/ArrowButtons.css +4 -0
- package/src/components/ArrowButtons.js +38 -0
- package/src/components/AssociatedDropdown.css +44 -0
- package/src/components/AssociatedDropdown.js +338 -0
- package/src/components/BooleanIcon.css +0 -0
- package/src/components/BooleanIcon.js +33 -0
- package/src/components/CancelButton.css +0 -0
- package/src/components/CancelButton.js +25 -0
- package/src/components/ColorButton.css +4 -0
- package/src/components/ColorButton.js +34 -0
- package/src/components/ColorPickerModal.css +3 -0
- package/src/components/ColorPickerModal.js +77 -0
- package/src/components/ColumnResize.css +9 -0
- package/src/components/ColumnResize.js +20 -0
- package/src/components/DataList.css +0 -0
- package/src/components/DataList.js +531 -0
- package/src/components/DataTable.css +43 -0
- package/src/components/DataTable.js +596 -0
- package/src/components/DataTableColumnSelector.css +10 -0
- package/src/components/DataTableColumnSelector.js +146 -0
- package/src/components/DateInput.css +6 -0
- package/src/components/DateInput.js +58 -0
- package/src/components/DatePicker.css +72 -0
- package/src/components/DatePicker.js +81 -0
- package/src/components/DescriptorField.css +0 -0
- package/src/components/DescriptorField.js +42 -0
- package/src/components/DownloadButton.css +0 -0
- package/src/components/DownloadButton.js +23 -0
- package/src/components/Draggable.css +0 -0
- package/src/components/Draggable.js +94 -0
- package/src/components/DropdownButton.css +3 -0
- package/src/components/DropdownButton.js +65 -0
- package/src/components/DropdownMenu.css +0 -0
- package/src/components/DropdownMenu.js +68 -0
- package/src/components/EditModal.css +8 -0
- package/src/components/EditModal.js +99 -0
- package/src/components/EditPage.css +7 -0
- package/src/components/EditPage.js +249 -0
- package/src/components/EmbeddedList.css +7 -0
- package/src/components/EmbeddedList.js +278 -0
- package/src/components/FileInputButton.css +0 -0
- package/src/components/FileInputButton.js +54 -0
- package/src/components/FileUpload.css +31 -0
- package/src/components/FileUpload.js +188 -0
- package/src/components/FileUploadModal.css +0 -0
- package/src/components/FileUploadModal.js +408 -0
- package/src/components/FuzzyDate.css +8 -0
- package/src/components/FuzzyDate.js +575 -0
- package/src/components/GoogleMap.css +0 -0
- package/src/components/GoogleMap.js +105 -0
- package/src/components/GooglePlacesSearch.css +0 -0
- package/src/components/GooglePlacesSearch.js +43 -0
- package/src/components/HorizontalCards.css +50 -0
- package/src/components/HorizontalCards.js +226 -0
- package/src/components/ItemCollection.css +3 -0
- package/src/components/ItemCollection.js +159 -0
- package/src/components/ItemList.css +0 -0
- package/src/components/ItemList.js +126 -0
- package/src/components/Items.css +19 -0
- package/src/components/Items.js +365 -0
- package/src/components/ItemsToggle.css +0 -0
- package/src/components/ItemsToggle.js +168 -0
- package/src/components/KeyboardField.css +4 -0
- package/src/components/KeyboardField.js +147 -0
- package/src/components/LazyDocument.css +21 -0
- package/src/components/LazyDocument.js +113 -0
- package/src/components/LazyImage.css +21 -0
- package/src/components/LazyImage.js +119 -0
- package/src/components/LazyVideo.css +21 -0
- package/src/components/LazyVideo.js +131 -0
- package/src/components/LinkButton.css +8 -0
- package/src/components/LinkButton.js +23 -0
- package/src/components/LinkLabel.css +8 -0
- package/src/components/LinkLabel.js +29 -0
- package/src/components/List.css +8 -0
- package/src/components/List.js +761 -0
- package/src/components/ListFilters.css +0 -0
- package/src/components/ListFilters.js +408 -0
- package/src/components/ListLoader.css +8 -0
- package/src/components/ListLoader.js +32 -0
- package/src/components/ListTable.css +3 -0
- package/src/components/ListTable.js +86 -0
- package/src/components/LoginModal.css +7 -0
- package/src/components/LoginModal.js +102 -0
- package/src/components/MasonryGrid.css +48 -0
- package/src/components/MasonryGrid.js +202 -0
- package/src/components/MediaGallery.css +37 -0
- package/src/components/MediaGallery.js +148 -0
- package/src/components/MediaGrid.css +72 -0
- package/src/components/MediaGrid.js +74 -0
- package/src/components/MediaList.css +3 -0
- package/src/components/MediaList.js +98 -0
- package/src/components/ModalDropdown.css +11 -0
- package/src/components/ModalDropdown.js +84 -0
- package/src/components/NestedAccordion.css +41 -0
- package/src/components/NestedAccordion.js +276 -0
- package/src/components/PhotoViewer.css +3 -0
- package/src/components/PhotoViewer.js +36 -0
- package/src/components/PlayButton.css +3 -0
- package/src/components/PlayButton.js +37 -0
- package/src/components/RemoteDropdown.css +13 -0
- package/src/components/RemoteDropdown.js +368 -0
- package/src/components/SaveButton.css +0 -0
- package/src/components/SaveButton.js +31 -0
- package/src/components/Section.css +0 -0
- package/src/components/Section.js +41 -0
- package/src/components/Selectize.css +11 -0
- package/src/components/Selectize.js +297 -0
- package/src/components/SelectizeHeader.css +3 -0
- package/src/components/SelectizeHeader.js +40 -0
- package/src/components/TabbedModal.css +14 -0
- package/src/components/TabbedModal.js +165 -0
- package/src/components/TabsMenu.css +0 -0
- package/src/components/TabsMenu.js +35 -0
- package/src/components/TagsList.css +0 -0
- package/src/components/TagsList.js +43 -0
- package/src/components/Thumbnail.css +0 -0
- package/src/components/Thumbnail.js +47 -0
- package/src/components/Toaster.css +9 -0
- package/src/components/Toaster.js +73 -0
- package/src/components/VideoFrameSelector.css +3 -0
- package/src/components/VideoFrameSelector.js +148 -0
- package/src/components/VideoPlayer.css +3 -0
- package/src/components/VideoPlayer.js +55 -0
- package/src/components/VideoPlayerButton.css +17 -0
- package/src/components/VideoPlayerButton.js +17 -0
- package/src/components/ViewXML.css +0 -0
- package/src/components/ViewXML.js +72 -0
- package/src/i18n/en.json +204 -0
- package/src/i18n/i18n.js +24 -0
- package/src/index.js +76 -0
- package/types/components/AccordionDataList.js.flow +224 -0
- package/types/components/AccordionList.js.flow +596 -0
- package/types/components/AccordionSelector.js.flow +359 -0
- package/types/components/ArrowButtons.js.flow +38 -0
- package/types/components/AssociatedDropdown.js.flow +338 -0
- package/types/components/BooleanIcon.js.flow +33 -0
- package/types/components/CancelButton.js.flow +25 -0
- package/types/components/ColorButton.js.flow +34 -0
- package/types/components/ColorPickerModal.js.flow +77 -0
- package/types/components/ColumnResize.js.flow +20 -0
- package/types/components/DataList.js.flow +531 -0
- package/types/components/DataTable.js.flow +596 -0
- package/types/components/DataTableColumnSelector.js.flow +146 -0
- package/types/components/DataView.js.flow +125 -0
- package/types/components/DateInput.js.flow +58 -0
- package/types/components/DatePicker.js.flow +81 -0
- package/types/components/DescriptorField.js.flow +42 -0
- package/types/components/DownloadButton.js.flow +23 -0
- package/types/components/Draggable.js.flow +94 -0
- package/types/components/DropdownButton.js.flow +65 -0
- package/types/components/DropdownMenu.js.flow +68 -0
- package/types/components/EditModal.js.flow +99 -0
- package/types/components/EditPage.js.flow +249 -0
- package/types/components/EmbeddedList.js.flow +278 -0
- package/types/components/FileInputButton.js.flow +54 -0
- package/types/components/FileUpload.js.flow +188 -0
- package/types/components/FileUploadModal.js.flow +408 -0
- package/types/components/FuzzyDate.js.flow +575 -0
- package/types/components/GoogleMap.js.flow +105 -0
- package/types/components/GooglePlacesSearch.js.flow +43 -0
- package/types/components/HorizontalCards.js.flow +226 -0
- package/types/components/ItemCollection.js.flow +159 -0
- package/types/components/ItemList.js.flow +126 -0
- package/types/components/Items.js.flow +365 -0
- package/types/components/ItemsToggle.js.flow +168 -0
- package/types/components/KeyboardField.js.flow +147 -0
- package/types/components/LazyDocument.js.flow +113 -0
- package/types/components/LazyImage.js.flow +119 -0
- package/types/components/LazyVideo.js.flow +131 -0
- package/types/components/LinkButton.js.flow +23 -0
- package/types/components/LinkLabel.js.flow +29 -0
- package/types/components/List.js.flow +761 -0
- package/types/components/ListFilters.js.flow +408 -0
- package/types/components/ListLoader.js.flow +32 -0
- package/types/components/ListTable.js.flow +86 -0
- package/types/components/LoginModal.js.flow +102 -0
- package/types/components/MasonryGrid.js.flow +202 -0
- package/types/components/MediaGallery.js.flow +148 -0
- package/types/components/MediaGrid.js.flow +74 -0
- package/types/components/MediaList.js.flow +98 -0
- package/types/components/MenuBar.js.flow +77 -0
- package/types/components/MenuSidebar.js.flow +72 -0
- package/types/components/ModalDropdown.js.flow +84 -0
- package/types/components/NestedAccordion.js.flow +276 -0
- package/types/components/PhotoViewer.js.flow +36 -0
- package/types/components/PlayButton.js.flow +37 -0
- package/types/components/RemoteDropdown.js.flow +368 -0
- package/types/components/SaveButton.js.flow +31 -0
- package/types/components/Section.js.flow +41 -0
- package/types/components/Selectize.js.flow +297 -0
- package/types/components/SelectizeHeader.js.flow +40 -0
- package/types/components/TabbedModal.js.flow +165 -0
- package/types/components/TabsMenu.js.flow +35 -0
- package/types/components/TagsList.js.flow +43 -0
- package/types/components/Thumbnail.js.flow +47 -0
- package/types/components/Toaster.js.flow +73 -0
- package/types/components/VideoFrameSelector.js.flow +148 -0
- package/types/components/VideoPlayer.js.flow +55 -0
- package/types/components/VideoPlayerButton.js.flow +17 -0
- package/types/components/ViewXML.js.flow +72 -0
- package/types/hooks/Imageable.js.flow +54 -0
- package/types/i18n/i18n.js.flow +24 -0
- package/types/index.js.flow +78 -0
- package/webpack.config.js +3 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import { Timer } from '@performant-software/shared-components';
|
|
4
|
+
import React, { Component, type ComponentType, type Element } from 'react';
|
|
5
|
+
import { withTranslation } from 'react-i18next';
|
|
6
|
+
import {
|
|
7
|
+
Button,
|
|
8
|
+
Grid,
|
|
9
|
+
Header,
|
|
10
|
+
Icon,
|
|
11
|
+
Input,
|
|
12
|
+
Message,
|
|
13
|
+
Modal
|
|
14
|
+
} from 'semantic-ui-react';
|
|
15
|
+
import _ from 'underscore';
|
|
16
|
+
import i18n from '../i18n/i18n';
|
|
17
|
+
import EditModal from './EditModal';
|
|
18
|
+
import NestedAccordion from './NestedAccordion';
|
|
19
|
+
import SelectizeHeader from './SelectizeHeader';
|
|
20
|
+
import Toaster from './Toaster';
|
|
21
|
+
import './AccordionSelector.css';
|
|
22
|
+
|
|
23
|
+
type Props = {
|
|
24
|
+
collectionName: string,
|
|
25
|
+
getChildItems: (items: Array<any>, item: any) => Array<any>,
|
|
26
|
+
getRootItems: (items: Array<any>) => Array<any>,
|
|
27
|
+
isSelectable?: (item: any) => boolean,
|
|
28
|
+
modal?: {
|
|
29
|
+
component: ComponentType<{}>,
|
|
30
|
+
onSave: (item: any) => Promise<any>,
|
|
31
|
+
props: any,
|
|
32
|
+
state: any,
|
|
33
|
+
},
|
|
34
|
+
multiple?: boolean,
|
|
35
|
+
onClose: () => void,
|
|
36
|
+
onSave: (selectedItems: Array<any>) => void,
|
|
37
|
+
onSearch: (parentId: ?number, search: ?string) => any,
|
|
38
|
+
open?: boolean,
|
|
39
|
+
renderItem: (item: any) => string | Element<any>,
|
|
40
|
+
selectedItems?: Array<any>,
|
|
41
|
+
showToggle: (item: any) => boolean,
|
|
42
|
+
t: (key: string) => string,
|
|
43
|
+
title?: string
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type State = {
|
|
47
|
+
items: Array<any>,
|
|
48
|
+
modalAdd: boolean,
|
|
49
|
+
saved: boolean,
|
|
50
|
+
searchQuery: string,
|
|
51
|
+
selectedItem: ?any,
|
|
52
|
+
selectedItems: Array<any>
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
class AccordionSelector extends Component<Props, State> {
|
|
56
|
+
static defaultProps: any;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Constructs a new AccordionSelector component.
|
|
60
|
+
*
|
|
61
|
+
* @param props
|
|
62
|
+
*/
|
|
63
|
+
constructor(props) {
|
|
64
|
+
super(props);
|
|
65
|
+
|
|
66
|
+
this.state = {
|
|
67
|
+
items: [],
|
|
68
|
+
modalAdd: false,
|
|
69
|
+
saved: false,
|
|
70
|
+
searchQuery: '',
|
|
71
|
+
selectedItem: null,
|
|
72
|
+
selectedItems: props.selectedItems
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Executes the initial search when the modal is opened.
|
|
78
|
+
*/
|
|
79
|
+
componentDidUpdate(prevProps) {
|
|
80
|
+
if (this.props.open && !prevProps.open) {
|
|
81
|
+
this.onSearch();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (this.props.selectedItems !== prevProps.selectedItems) {
|
|
85
|
+
this.setState({ selectedItems: this.props.selectedItems });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Returns true if the passed item is selected.
|
|
91
|
+
*
|
|
92
|
+
* @param item
|
|
93
|
+
*
|
|
94
|
+
* @returns {boolean}
|
|
95
|
+
*/
|
|
96
|
+
isSelected(item) {
|
|
97
|
+
return !!_.findWhere(this.state.selectedItems, { id: item.id });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Toggles selection for the passed item.
|
|
102
|
+
*
|
|
103
|
+
* @param item
|
|
104
|
+
*/
|
|
105
|
+
onItemClick(item) {
|
|
106
|
+
if (this.props.isSelectable && !this.props.isSelectable(item)) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
this.setState((state) => {
|
|
111
|
+
let selectedItems;
|
|
112
|
+
|
|
113
|
+
if (this.isSelected(item)) {
|
|
114
|
+
selectedItems = _.filter(state.selectedItems, (i) => i.id !== item.id);
|
|
115
|
+
} else if (!this.props.multiple) {
|
|
116
|
+
selectedItems = [item];
|
|
117
|
+
} else {
|
|
118
|
+
selectedItems = [
|
|
119
|
+
...state.selectedItems,
|
|
120
|
+
item
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return { selectedItems };
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Toggles selection for the passed item.
|
|
130
|
+
*
|
|
131
|
+
* @param item
|
|
132
|
+
*/
|
|
133
|
+
onItemSelection(item) {
|
|
134
|
+
if (this.state.selectedItem === item) {
|
|
135
|
+
this.setState({ selectedItem: null }, this.onItemClick.bind(this, item));
|
|
136
|
+
} else {
|
|
137
|
+
this.setState({ selectedItem: item });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Lazy-loads the children for the passed item.
|
|
143
|
+
*
|
|
144
|
+
* @param item
|
|
145
|
+
*/
|
|
146
|
+
onItemToggle(item) {
|
|
147
|
+
if (!item.loaded) {
|
|
148
|
+
this.onSearch(item.id).then(() => {
|
|
149
|
+
// Set the "loaded" property on item to prevent multiple API calls
|
|
150
|
+
this.setState((state) => ({
|
|
151
|
+
items: _.map(state.items, (i) => (i.id === item.id ? { ...i, loaded: true } : i))
|
|
152
|
+
}));
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Executes the search.
|
|
159
|
+
*
|
|
160
|
+
* @param parentId
|
|
161
|
+
*
|
|
162
|
+
* @returns {*}
|
|
163
|
+
*/
|
|
164
|
+
onSearch(parentId = null) {
|
|
165
|
+
return this.props
|
|
166
|
+
.onSearch(parentId, this.state.searchQuery)
|
|
167
|
+
.then(({ data }) => {
|
|
168
|
+
const items = data[this.props.collectionName];
|
|
169
|
+
this.setState((state) => (parentId ? { items: [...state.items || [], ...items] } : { items }));
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Sets the search query value on the state.
|
|
175
|
+
*
|
|
176
|
+
* @param e
|
|
177
|
+
* @param value
|
|
178
|
+
*/
|
|
179
|
+
onSearchChange(e, { value }) {
|
|
180
|
+
this.setState({ searchQuery: value });
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Renders the AccordionSelector modal.
|
|
185
|
+
*
|
|
186
|
+
* @returns {*}
|
|
187
|
+
*/
|
|
188
|
+
render() {
|
|
189
|
+
return (
|
|
190
|
+
<Modal
|
|
191
|
+
className='accordion-selector'
|
|
192
|
+
open={this.props.open}
|
|
193
|
+
size='small'
|
|
194
|
+
>
|
|
195
|
+
<Modal.Header>
|
|
196
|
+
<Grid
|
|
197
|
+
columns={2}
|
|
198
|
+
verticalAlign='middle'
|
|
199
|
+
>
|
|
200
|
+
<Grid.Column
|
|
201
|
+
textAlign='left'
|
|
202
|
+
>
|
|
203
|
+
<Header
|
|
204
|
+
content={this.props.title
|
|
205
|
+
? this.props.title
|
|
206
|
+
: i18n.t('AccordionSelector.title')}
|
|
207
|
+
/>
|
|
208
|
+
</Grid.Column>
|
|
209
|
+
<Grid.Column
|
|
210
|
+
textAlign='right'
|
|
211
|
+
>
|
|
212
|
+
<Input
|
|
213
|
+
autoFocus
|
|
214
|
+
icon='search'
|
|
215
|
+
onKeyDown={Timer.clearSearchTimer.bind(this)}
|
|
216
|
+
onKeyUp={Timer.setSearchTimer.bind(this, this.onSearch.bind(this))}
|
|
217
|
+
onChange={this.onSearchChange.bind(this)}
|
|
218
|
+
size='mini'
|
|
219
|
+
type='text'
|
|
220
|
+
value={this.state.searchQuery}
|
|
221
|
+
/>
|
|
222
|
+
{ this.renderAddButton() }
|
|
223
|
+
</Grid.Column>
|
|
224
|
+
</Grid>
|
|
225
|
+
</Modal.Header>
|
|
226
|
+
<Modal.Content>
|
|
227
|
+
<SelectizeHeader
|
|
228
|
+
isSelected={(item) => this.state.selectedItem === item}
|
|
229
|
+
items={this.state.selectedItems}
|
|
230
|
+
onItemClick={this.onItemSelection.bind(this)}
|
|
231
|
+
renderItem={this.props.renderItem.bind(this)}
|
|
232
|
+
/>
|
|
233
|
+
<NestedAccordion
|
|
234
|
+
getChildItems={this.props.getChildItems.bind(this, this.state.items)}
|
|
235
|
+
onItemClick={this.onItemClick.bind(this)}
|
|
236
|
+
onItemToggle={this.onItemToggle.bind(this)}
|
|
237
|
+
renderItem={this.props.renderItem.bind(this)}
|
|
238
|
+
renderRight={this.renderRight.bind(this)}
|
|
239
|
+
rootItems={this.props.getRootItems(this.state.items)}
|
|
240
|
+
showToggle={this.props.showToggle.bind(this)}
|
|
241
|
+
/>
|
|
242
|
+
{ this.renderAddModal() }
|
|
243
|
+
{ this.state.saved && (
|
|
244
|
+
<Toaster
|
|
245
|
+
onDismiss={() => this.setState({ saved: false })}
|
|
246
|
+
type={Toaster.MessageTypes.positive}
|
|
247
|
+
>
|
|
248
|
+
<Message.Header
|
|
249
|
+
content={i18n.t('Common.messages.save.header')}
|
|
250
|
+
/>
|
|
251
|
+
<Message.Content
|
|
252
|
+
content={i18n.t('Common.messages.save.content')}
|
|
253
|
+
/>
|
|
254
|
+
</Toaster>
|
|
255
|
+
)}
|
|
256
|
+
</Modal.Content>
|
|
257
|
+
<Modal.Actions>
|
|
258
|
+
<Button
|
|
259
|
+
onClick={this.props.onSave.bind(this, this.state.selectedItems)}
|
|
260
|
+
primary
|
|
261
|
+
size='medium'
|
|
262
|
+
type='submit'
|
|
263
|
+
>
|
|
264
|
+
{ this.props.t('Common.buttons.save') }
|
|
265
|
+
</Button>
|
|
266
|
+
<Button
|
|
267
|
+
inverted
|
|
268
|
+
onClick={this.props.onClose.bind(this)}
|
|
269
|
+
primary
|
|
270
|
+
size='medium'
|
|
271
|
+
type='button'
|
|
272
|
+
>
|
|
273
|
+
{ this.props.t('Common.buttons.cancel') }
|
|
274
|
+
</Button>
|
|
275
|
+
</Modal.Actions>
|
|
276
|
+
</Modal>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Renders the add button.
|
|
282
|
+
*
|
|
283
|
+
* @returns {null|*}
|
|
284
|
+
*/
|
|
285
|
+
renderAddButton() {
|
|
286
|
+
if (!this.props.modal) {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return (
|
|
291
|
+
<Button
|
|
292
|
+
basic
|
|
293
|
+
className='add-button'
|
|
294
|
+
content={this.props.t('Common.buttons.add')}
|
|
295
|
+
icon='plus'
|
|
296
|
+
onClick={() => this.setState({ modalAdd: true })}
|
|
297
|
+
/>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Renders the add modal.
|
|
303
|
+
*
|
|
304
|
+
* @returns {null|*}
|
|
305
|
+
*/
|
|
306
|
+
renderAddModal() {
|
|
307
|
+
if (!(this.state.modalAdd && this.props.modal)) {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const { component, props, onSave } = this.props.modal;
|
|
312
|
+
|
|
313
|
+
return (
|
|
314
|
+
<EditModal
|
|
315
|
+
component={component}
|
|
316
|
+
onClose={() => this.setState({ modalAdd: false, selectedItem: null })}
|
|
317
|
+
onSave={(item) => onSave(item)
|
|
318
|
+
.then((saved) => this.setState({
|
|
319
|
+
modalAdd: false,
|
|
320
|
+
saved: true,
|
|
321
|
+
searchQuery: '',
|
|
322
|
+
selectedItems: [saved]
|
|
323
|
+
}, this.onSearch.bind(this)))}
|
|
324
|
+
{...props}
|
|
325
|
+
/>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Renders the right column for the passed item.
|
|
331
|
+
*
|
|
332
|
+
* @param item
|
|
333
|
+
*
|
|
334
|
+
* @returns {null|*}
|
|
335
|
+
*/
|
|
336
|
+
renderRight(item) {
|
|
337
|
+
if (!this.isSelected(item)) {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
return (
|
|
342
|
+
<Icon
|
|
343
|
+
color='green'
|
|
344
|
+
name='check'
|
|
345
|
+
/>
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
AccordionSelector.defaultProps = {
|
|
351
|
+
isSelectable: undefined,
|
|
352
|
+
modal: undefined,
|
|
353
|
+
multiple: false,
|
|
354
|
+
open: false,
|
|
355
|
+
selectedItems: [],
|
|
356
|
+
title: undefined
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
export default withTranslation()(AccordionSelector);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Button } from 'semantic-ui-react';
|
|
5
|
+
import './ArrowButtons.css';
|
|
6
|
+
|
|
7
|
+
type Date = {
|
|
8
|
+
accuracy: number,
|
|
9
|
+
description: string,
|
|
10
|
+
endDate?: Date,
|
|
11
|
+
range: boolean,
|
|
12
|
+
startDate?: Date
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type Props = {
|
|
16
|
+
onLeft: (data: Date) => void,
|
|
17
|
+
onRight: (data: Date) => void
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const ArrowButtons = (props: Props) => (
|
|
21
|
+
<Button.Group
|
|
22
|
+
className='arrow-buttons'
|
|
23
|
+
vertical
|
|
24
|
+
>
|
|
25
|
+
<Button
|
|
26
|
+
basic
|
|
27
|
+
icon='arrow right'
|
|
28
|
+
onClick={props.onRight.bind(this)}
|
|
29
|
+
/>
|
|
30
|
+
<Button
|
|
31
|
+
basic
|
|
32
|
+
icon='arrow left'
|
|
33
|
+
onClick={props.onLeft.bind(this)}
|
|
34
|
+
/>
|
|
35
|
+
</Button.Group>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export default ArrowButtons;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.association-dropdown {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
flex-wrap: wrap;
|
|
5
|
+
width: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.association-dropdown .buttons {
|
|
9
|
+
width: 40%;
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-wrap: wrap;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.association-dropdown .dropdown-container {
|
|
15
|
+
width: 60%;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.association-dropdown .inline-dropdown {
|
|
19
|
+
width: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.association-dropdown .ui.search.selection.dropdown > input.search {
|
|
23
|
+
width: 100%;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.association-dropdown div[role="listbox"] div[role="option"] span.text {
|
|
27
|
+
display: block;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.association-dropdown div[role="alert"] {
|
|
31
|
+
max-width: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.ui.form.field .ui.input .association-dropdown input.dropdown-search-input {
|
|
35
|
+
width: 100%;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.ui.form .wide.field .ui.input .association-dropdown input.dropdown-search-input {
|
|
39
|
+
width: 100%;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.ui.dropdown:not(.button) > .default.text {
|
|
43
|
+
color: rgba(95, 95, 95, 0.86);
|
|
44
|
+
}
|