Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented select/unselect all buttons #160

Merged
merged 2 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ E.g., if it was used in a menu and the menu is red, the circle would be red.
### **WORK IN PROGRESS**
-->
## Changelog
### **WORK IN PROGRESS**
* (foxriver76) implemented select/unselect all buttons

### 2.5.0 (2023-11-11)
* (foxriver76) allow to use real html in HTML prepend and HTML append (basic string widget)
* (foxriver76) fixed problem while editing groups
Expand Down
5 changes: 3 additions & 2 deletions src/src/Attributes/Widget/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,9 @@ class Widget extends Component {
});
} else {
fields = selectedWidgetsFields[0];
widgets[this.props.selectedWidgets[0]].data.bindings.forEach(attr => !bindFields.includes(`data_${attr}`) && bindFields.push(`data_${attr}`));
widgets[this.props.selectedWidgets[0]].style.bindings.forEach(attr => !bindFields.includes(`style_${attr}`) && bindFields.push(`style_${attr}`));

widgets[this.props.selectedWidgets[0]].data.bindings?.forEach(attr => !bindFields.includes(`data_${attr}`) && bindFields.push(`data_${attr}`));
widgets[this.props.selectedWidgets[0]].style.bindings?.forEach(attr => !bindFields.includes(`style_${attr}`) && bindFields.push(`style_${attr}`));
}

newState.bindFields = bindFields.sort();
Expand Down
8 changes: 6 additions & 2 deletions src/src/Toolbar/MultiSelect.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { Component } from 'react';
import { withStyles } from '@mui/styles';
import {
Checkbox, FormControl, MenuItem, Menu, List, ListItemButton, ListItemText, ListItemIcon, InputLabel,
Checkbox, FormControl, MenuItem, Menu, List, ListItemButton, ListItemText, ListItemIcon, InputLabel, Button,
} from '@mui/material';

import IconArrowDown from '@mui/icons-material/ArrowDropDown';
import IconArrowUp from '@mui/icons-material/ArrowDropUp';

import { Utils } from '@iobroker/adapter-react-v5';
import { Utils, I18n } from '@iobroker/adapter-react-v5';

const styles = theme => ({
navMain: {
Expand Down Expand Up @@ -145,6 +145,10 @@ class MultiSelect extends Component {
anchorEl={this.state.elAnchor}
onClose={() => this.setState({ elAnchor: null })}
>
<div>
<Button onClick={() => this.props.setSelectedWidgets(props.options.map(item => item.value))}>{I18n.t('Select all')}</Button>
<Button onClick={() => this.props.setSelectedWidgets([])}>{I18n.t('Unselect all')}</Button>
</div>
{props.options.map(item => <MenuItem
value={item.value}
key={item.value}
Expand Down
1 change: 1 addition & 0 deletions src/src/Toolbar/ToolbarItems.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const getItem = (item, key, props, full) => {
width={item.width}
value={item.value ? item.value : value}
onChange={_value => item.onChange(_value)}
setSelectedWidgets={props.setSelectedWidgets}
options={item.items}
themeType={props.themeType}
/>;
Expand Down
1 change: 1 addition & 0 deletions src/src/Toolbar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ Toolbar.propTypes = {
instance: PropTypes.number,
projectName: PropTypes.string,
version: PropTypes.string,
setSelectedWidgets: PropTypes.func.isRequired,
};

export default withStyles(styles)(Toolbar);
Loading