Skip to content

Commit 4deea83

Browse files
authored
Merge pull request #128 from performant-software/feature/rc127_read_only_views
RC #127 - Read-only views
2 parents de4da52 + e4ecea1 commit 4deea83

File tree

14 files changed

+988
-35
lines changed

14 files changed

+988
-35
lines changed

packages/semantic-ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"@performant-software/shared-components": "^0.5.2",
1313
"@react-google-maps/api": "^2.8.1",
14+
"axios": "^0.26.1",
1415
"flow-copy-source": "^2.0.9",
1516
"i18next": "^19.4.4",
1617
"react-calendar": "^3.3.0",

packages/semantic-ui/src/components/DataList.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ type Props = {
1919
props?: any,
2020
onChange?: (filter: any) => Promise<any>
2121
},
22-
onDelete: (item: any) => Promise<any>,
22+
onDelete?: (item: any) => Promise<any>,
2323
onDeleteAll?: () => Promise<any>,
2424
onLoad: (params: any) => Promise<any>,
25-
onSave: (item: any) => Promise<any>,
25+
onSave?: (item: any) => Promise<any>,
2626
perPageOptions?: Array<number>,
2727
polling?: number,
2828
resolveErrors?: (error: any) => Array<string>,
@@ -251,6 +251,10 @@ const useDataList = (WrappedComponent: ComponentType<any>) => (
251251
* @returns {Q.Promise<any> | Promise<R> | Promise<any> | void | *}
252252
*/
253253
onDelete(selectedItem: any) {
254+
if (!this.props.onDelete) {
255+
return Promise.resolve();
256+
}
257+
254258
return this.props
255259
.onDelete(selectedItem)
256260
.then(this.afterDelete.bind(this))
@@ -333,6 +337,10 @@ const useDataList = (WrappedComponent: ComponentType<any>) => (
333337
* @returns {Q.Promise<any> | Promise<R> | Promise<any> | void | *}
334338
*/
335339
onSave(item: any) {
340+
if (!this.props.onSave) {
341+
return Promise.resolve();
342+
}
343+
336344
return Promise.resolve(this.props.onSave(item))
337345
.then(() => this.setState({ saved: true }, this.fetchData.bind(this)));
338346
}

packages/semantic-ui/src/components/DataTableColumnSelector.js

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow
22

3-
import React, { Component, type ComponentType } from 'react';
3+
import React, { Component, type ComponentType, type Element } from 'react';
44
import { Checkbox, Dropdown, Icon } from 'semantic-ui-react';
55
import _ from 'underscore';
66
import Draggable from './Draggable';
@@ -10,7 +10,8 @@ import type { Column } from './DataTable';
1010

1111
type Props = {
1212
className: string,
13-
columns: Array<Column>
13+
columns: Array<Column>,
14+
renderListHeader?: () => Element<any>
1415
};
1516

1617
type State = {
@@ -107,37 +108,40 @@ const useColumnSelector = (WrappedComponent: ComponentType<any>) => (
107108
*/
108109
renderHeader() {
109110
return (
110-
<Dropdown
111-
basic
112-
button
113-
icon='cog'
114-
className='icon configure-button open-right'
115-
simple
116-
>
117-
<Dropdown.Menu>
118-
{ this.state.columns
119-
.filter((c) => c.label && c.label.length)
120-
.map((c, index) => (
121-
<Draggable
122-
id={c.name}
123-
index={index}
124-
key={c.name}
125-
onDrag={this.onDrag.bind(this)}
126-
>
127-
<Dropdown.Item>
128-
<Icon
129-
name='bars'
130-
/>
131-
<Checkbox
132-
checked={!c.hidden}
133-
label={c.label}
134-
onClick={this.onColumnCheckbox.bind(this, c)}
135-
/>
136-
</Dropdown.Item>
137-
</Draggable>
138-
))}
139-
</Dropdown.Menu>
140-
</Dropdown>
111+
<>
112+
{ this.props.renderListHeader && this.props.renderListHeader() }
113+
<Dropdown
114+
basic
115+
button
116+
icon='cog'
117+
className='icon configure-button open-right'
118+
simple
119+
>
120+
<Dropdown.Menu>
121+
{ this.state.columns
122+
.filter((c) => c.label && c.label.length)
123+
.map((c, index) => (
124+
<Draggable
125+
id={c.name}
126+
index={index}
127+
key={c.name}
128+
onDrag={this.onDrag.bind(this)}
129+
>
130+
<Dropdown.Item>
131+
<Icon
132+
name='bars'
133+
/>
134+
<Checkbox
135+
checked={!c.hidden}
136+
label={c.label}
137+
onClick={this.onColumnCheckbox.bind(this, c)}
138+
/>
139+
</Dropdown.Item>
140+
</Draggable>
141+
))}
142+
</Dropdown.Menu>
143+
</Dropdown>
144+
</>
141145
);
142146
}
143147
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.data-view-modal.ui.form .field span.label {
2+
display: block;
3+
font-weight: bold;
4+
}

0 commit comments

Comments
 (0)