Skip to content

Commit

Permalink
Migrated palette to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Apr 27, 2024
1 parent 438e801 commit 52fe07b
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 135 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,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**
* (bluefox) Allowed applying styles to jqui buttons

### 2.9.52 (2024-04-25)
* (bluefox) Navigation was improved: adjustable menu width and bulk edit were added

Expand Down
29 changes: 17 additions & 12 deletions packages/iobroker.vis-2/src/src/Attributes/View/AllViewsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Button,
Dialog, DialogActions,
DialogContent, DialogTitle, IconButton,
Tooltip,
} from '@mui/material';

import { Close, DragHandle, FormatPaint } from '@mui/icons-material';
Expand Down Expand Up @@ -138,19 +139,23 @@ export default function showAllViewsDialog(props: ShowAllViewsDialogProps) {
<div style={{ display: 'inline-block', minWidth: 100, flexGrow: 1 }}>
{item.control}
</div>
{applyToAllButtonVisible ? <IconButton
size="small"
onClick={() => {
const newProject: Project = deepClone(props.project) as Project;
const _viewsToChange = getViewsWithDifferentValues(props.project, props.field, item.view, null, props.checkFunction) || [];
_viewsToChange?.forEach(_view => {
(newProject[_view].settings as Record<string, any>)[props.field.attr] = (newProject[item.view].settings as Record<string, any>)[props.field.attr];
});
props.changeProject(newProject);
}}
{applyToAllButtonVisible ? <Tooltip
title={I18n.t('Apply to all views')}
classes={{ tooltip: 'vis-tooltip' }}
>
<FormatPaint />
</IconButton> : null}
<IconButton
size="small"
onClick={() => {
const newProject: Project = deepClone(props.project) as Project;
const _viewsToChange = getViewsWithDifferentValues(props.project, props.field, item.view, null, props.checkFunction) || [];
_viewsToChange?.forEach(_view => {
(newProject[_view].settings as Record<string, any>)[props.field.attr] = (newProject[item.view].settings as Record<string, any>)[props.field.attr];
});
props.changeProject(newProject);
}}
>
<FormatPaint />
</IconButton></Tooltip> : null}
</div>}
</Draggable>)}
{dropProvided.placeholder}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ class Widget extends Component {
classes={{
root: Utils.clsx(classes.clearPadding, this.state.accordionOpen[group.name]
? classes.groupSummaryExpanded : classes.groupSummary, classes.lightedPanel),
content: Utils.clsx(classes.clearPadding, this.state.accordionOpen[group.name] && classes.accordionOpenedSummary),
content: Utils.clsx(classes.clearPadding, this.state.accordionOpen[group.name] && group.hasValues && classes.accordionOpenedSummary),
expanded: classes.clearPadding,
expandIcon: classes.clearPadding,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {

// eslint-disable-next-line import/no-cycle
import VisRxWidget from '../../visRxWidget';
import VisBaseWidget from "@/Vis/visBaseWidget";

class JQuiBinaryState extends VisRxWidget {
constructor(props) {
Expand Down Expand Up @@ -778,10 +779,17 @@ class JQuiBinaryState extends VisRxWidget {
if (!type && this.props.tpl === 'tplJquiRadio') {
type = 'radio';
}
if (buttonStyle.borderWidth) {
buttonStyle.borderWidth = VisBaseWidget.correctStylePxValue(buttonStyle.borderWidth);
}
if (buttonStyle.fontSize) {
buttonStyle.fontSize = VisBaseWidget.correctStylePxValue(buttonStyle.fontSize);
}

// extra no rxData here, as it is not possible to set it with bindings
buttonStyle.width = '100%';
buttonStyle.height = '100%';
buttonStyle.minWidth = 'unset';
let content;
const bodyStyle = { textAlign: 'center' };
if (type === 'radio') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
import { isVarFinite } from '../../../Utils/utils';
// eslint-disable-next-line import/no-cycle
import VisRxWidget from '../../visRxWidget';
import VisBaseWidget from "@/Vis/visBaseWidget";

class JQuiButton extends VisRxWidget {
constructor(props) {
Expand Down Expand Up @@ -762,6 +763,12 @@ class JQuiButton extends VisRxWidget {
buttonStyle[attr] = value;
}
});
if (buttonStyle.borderWidth) {
buttonStyle.borderWidth = VisBaseWidget.correctStylePxValue(buttonStyle.borderWidth);
}
if (buttonStyle.fontSize) {
buttonStyle.fontSize = VisBaseWidget.correctStylePxValue(buttonStyle.fontSize);
}

// the following widgets are resizable by default
let visResizable = this.state.data.visResizable;
Expand All @@ -787,6 +794,7 @@ class JQuiButton extends VisRxWidget {
} else {
buttonStyle.padding = this.state.rxData.padding;
}
buttonStyle.minWidth = 'unset';

let buttonText;
if (this.state.rxData.html) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {

// eslint-disable-next-line import/no-cycle
import VisRxWidget from '../../visRxWidget';
import VisBaseWidget from "@/Vis/visBaseWidget";

class JQuiButtonDialogClose extends VisRxWidget {
constructor(props) {
Expand Down Expand Up @@ -284,6 +285,13 @@ class JQuiButtonDialogClose extends VisRxWidget {
buttonStyle[attr] = value;
}
});
buttonStyle.minWidth = 'unset';
if (buttonStyle.borderWidth) {
buttonStyle.borderWidth = VisBaseWidget.correctStylePxValue(buttonStyle.borderWidth);
}
if (buttonStyle.fontSize) {
buttonStyle.fontSize = VisBaseWidget.correctStylePxValue(buttonStyle.fontSize);
}

// extra no rxData here, as it is not possible to set it with bindings
if (this.state.data.visResizable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
import VisRxWidget from '../../visRxWidget';
import BulkEditor from './BulkEditor';
import { deepClone } from '../../../Utils/utils';
import VisBaseWidget from "@/Vis/visBaseWidget";

class JQuiState extends VisRxWidget {
static getWidgetInfo() {
Expand Down Expand Up @@ -539,6 +540,13 @@ class JQuiState extends VisRxWidget {
buttonStyle[attr] = value;
}
});
buttonStyle.minWidth = 'unset';
if (buttonStyle.borderWidth) {
buttonStyle.borderWidth = VisBaseWidget.correctStylePxValue(buttonStyle.borderWidth);
}
if (buttonStyle.fontSize) {
buttonStyle.fontSize = VisBaseWidget.correctStylePxValue(buttonStyle.fontSize);
}

let content;
if (
Expand Down
Loading

0 comments on commit 52fe07b

Please sign in to comment.