diff --git a/src-rx/src/components/Object/ObjectBrowserEditObject.jsx b/src-rx/src/components/Object/ObjectBrowserEditObject.jsx index 3468afa9e..d66611531 100644 --- a/src-rx/src/components/Object/ObjectBrowserEditObject.jsx +++ b/src-rx/src/components/Object/ObjectBrowserEditObject.jsx @@ -1,7 +1,7 @@ -import React, { Component } from 'react'; +import React, {Component} from 'react'; import clsx from 'clsx'; import PropTypes from 'prop-types'; -import { withStyles } from '@mui/styles'; +import {withStyles} from '@mui/styles'; import AceEditor from 'react-ace'; // import 'ace-builds/webpack-resolver'; @@ -28,7 +28,7 @@ import IconButton from '@mui/material/IconButton'; import IconClose from '@mui/icons-material/Close'; import IconCheck from '@mui/icons-material/Check'; import AddIcon from '@mui/icons-material/Add'; -import { FaClipboard as IconCopyClipboard } from 'react-icons/fa'; +import {FaClipboard as IconCopyClipboard} from 'react-icons/fa'; import IconCopy from '@mui/icons-material/FileCopy'; import IconFx from '@iobroker/adapter-react-v5/icons/IconFx'; @@ -36,7 +36,7 @@ import DialogSelectID from '@iobroker/adapter-react-v5/Dialogs/SelectID'; import Utils from '@iobroker/adapter-react-v5/Components/Utils'; import I18n from '@iobroker/adapter-react-v5/i18n'; import copy from '@iobroker/adapter-react-v5/Components/copy-to-clipboard'; -import { FormControl, InputLabel, MenuItem, Select, Tooltip, Autocomplete } from '@mui/material'; +import {FormControl, InputLabel, MenuItem, Select, Tooltip, Autocomplete} from '@mui/material'; import UploadImage from '../UploadImage'; const styles = theme => ({ @@ -105,7 +105,10 @@ const styles = theme => ({ width: '100%' }, flex: { - display: 'flex' + display: 'flex', + '& > div': { + marginRight: theme.spacing(1) + }, }, close: { width: '20px', @@ -150,15 +153,15 @@ const styles = theme => ({ }, '@media screen and (max-width: 465px)': { wrapperButton: { - '& *':{ - fontSize:10 + '& *': { + fontSize: 10 } }, }, '@media screen and (max-width: 380px)': { wrapperButton: { - '& *':{ - fontSize:9 + '& *': { + fontSize: 9 } }, }, @@ -269,7 +272,7 @@ class ObjectBrowserEditObject extends Component { } onChange(value, cb) { - const newState = { text: value }; + const newState = {text: value}; const json = this.prepareObject(value); if (json) { newState.changed = this.originalObj !== JSON.stringify(json, null, 2); @@ -314,11 +317,12 @@ class ObjectBrowserEditObject extends Component { renderTabs() { return { window.localStorage.setItem((this.props.dialogName || 'App') + '.editTab', tab); - this.setState({ tab }); + this.setState({tab}); }}> - - - {this.props.obj._id.startsWith('alias.0') && this.props.obj.type === 'state' && } + + + {this.props.obj._id.startsWith('alias.0') && this.props.obj.type === 'state' && + } ; } @@ -356,7 +360,7 @@ class ObjectBrowserEditObject extends Component { const selectRead = this.state.selectRead; const selectWrite = this.state.selectWrite; const selectId = this.state.selectId; - this.setState({ selectId: false, selectRead: false, selectWrite: false }, () => { + this.setState({selectId: false, selectRead: false, selectWrite: false}, () => { if (selectRead) { this.setAliasItem(json, 'id.read', id); } else if (selectWrite) { @@ -366,7 +370,7 @@ class ObjectBrowserEditObject extends Component { } }); }} - onClose={() => this.setState({ selectId: false, selectRead: false, selectWrite: false })} + onClose={() => this.setState({selectId: false, selectRead: false, selectWrite: false})} />; } @@ -404,21 +408,23 @@ class ObjectBrowserEditObject extends Component { } buttonAddKey(nameKey, cb) { - const { t, classes } = this.props; + const { classes } = this.props; return
+ startIcon={} + onClick={cb}>{nameKey}
; } buttonRemoveKey(nameKey, cb) { - const { t, classes } = this.props; - return
; + const {t, classes} = this.props; + return +
+ ; } renderCommonEdit() { @@ -435,7 +441,7 @@ class ObjectBrowserEditObject extends Component { 'mixed' ]; const disabled = false; - const { classes, t, roleArray, obj } = this.props; + const {classes, t, roleArray, obj} = this.props; const checkState = obj.type === 'state'; const checkRole = obj.type === 'channel' || obj.type === 'device' || checkState; @@ -449,45 +455,86 @@ class ObjectBrowserEditObject extends Component { className={clsx(classes.marginBlock, classes.textField)} fullWidth value={Utils.getObjectNameFromObj(json, I18n.getLanguage())} - onChange={(el) => this.setCommonItem(json, 'name', el.target.value)} + onChange={el => this.setCommonItem(json, 'name', el.target.value)} /> : this.buttonAddKey('name', () => this.setCommonItem(json, 'name', '')) } - {checkState ? typeof json.common.type !== 'undefined' ? -
- - {t('State type')} - - - {this.buttonRemoveKey('type', () => this.removeCommonItem(json, 'type'))} -
+ {t('State type')} + + + {this.buttonRemoveKey('type', () => this.removeCommonItem(json, 'type'))} +
+ : + this.buttonAddKey('type', () => this.setCommonItem(json, 'type', 'string'))) + : null + } +
+ {checkState ? (typeof json.common.read !== 'undefined' ? +
+ this.setCommonItem(json, 'read', el.target.checked)} + />} + label={t('Readable')} + /> + {this.buttonRemoveKey('read', () => this.removeCommonItem(json, 'read'))} +
+ : + this.buttonAddKey('read', () => this.setCommonItem(json, 'read', true))) : - this.buttonAddKey('type', () => this.setCommonItem(json, 'type', 'string')) - : null} - {checkRole ? typeof json.common.role !== 'undefined' ? -
- this.setCommonItem(json, 'role', e)} - options={roleArray} - renderInput={params => } - /> - {this.buttonRemoveKey('role', () => this.removeCommonItem(json, 'role'))} -
: - this.buttonAddKey('role', () => this.setCommonItem(json, 'role', '')) - : null} + null + } + {checkState ? (typeof json.common.write !== 'undefined' ? +
+ this.setCommonItem(json, 'write', el.target.checked)} + />} + label={t('Writeable')} + /> + {this.buttonRemoveKey('write', () => this.removeCommonItem(json, 'write'))} +
+ : + this.buttonAddKey('write', () => this.setCommonItem(json, 'write', true))) + : + null + } +
+ {checkRole ? (typeof json.common.role !== 'undefined' ? +
+ this.setCommonItem(json, 'role', e)} + options={roleArray} + renderInput={params => } + /> + {this.buttonRemoveKey('role', () => this.removeCommonItem(json, 'role'))} +
: + this.buttonAddKey('role', () => this.setCommonItem(json, 'role', ''))) + : null + } {typeof json.common.color !== 'undefined' ?
this.setCommonItem(json, 'color', el.target.value)} /> + onChange={el => this.setCommonItem(json, 'color', el.target.value)}/> {this.buttonRemoveKey('color', () => this.removeCommonItem(json, 'color'))}
: this.buttonAddKey('color', () => this.setCommonItem(json, 'color', '')) } +
+ {json.common.type === 'number' ? (typeof json.common.min !== 'undefined' ? +
+ this.setCommonItem(json, 'min', el.target.value)}/> + {this.buttonRemoveKey('min', () => this.removeCommonItem(json, 'min'))} +
: +
+ {this.buttonAddKey('min', () => this.setCommonItem(json, 'min', 0))} +
) : null + } + {json.common.type === 'number' ? (typeof json.common.max !== 'undefined' ? +
+ this.setCommonItem(json, 'max', el.target.value)}/> + {this.buttonRemoveKey('max', () => this.removeCommonItem(json, 'max'))} +
: +
+ {this.buttonAddKey('max', () => this.setCommonItem(json, 'max', 100))} +
) : null + } + {json.common.type === 'number' ? (typeof json.common.step !== 'undefined' ? +
+ this.setCommonItem(json, 'step', el.target.value)}/> + {this.buttonRemoveKey('step', () => this.removeCommonItem(json, 'step'))} +
: +
+ {this.buttonAddKey('step', () => this.setCommonItem(json, 'step', 1))} +
) : null + } +
+ {json.common.type === 'number' ? (typeof json.common.unit !== 'undefined' ? +
+ this.setCommonItem(json, 'unit', el.target.value)}/> + {this.buttonRemoveKey('unit', () => this.removeCommonItem(json, 'unit'))} +
: +
+ {this.buttonAddKey('unit', () => this.setCommonItem(json, 'unit', ''))} +
) : null + }
{typeof json.common.icon !== 'undefined' ? -
+
{this.buttonRemoveKey('icon', () => this.removeCommonItem(json, 'icon'))}
: -
+
{this.buttonAddKey('icon', () => this.setCommonItem(json, 'icon', ''))}
} @@ -541,7 +650,7 @@ class ObjectBrowserEditObject extends Component { } else { this.setAliasItem(json, 'id.read', json.common?.alias?.id || ''); } - }} /> + }}/> } label={this.props.t('Different IDs for read and write')} /> @@ -553,8 +662,9 @@ class ObjectBrowserEditObject extends Component { value={json.common?.alias?.id || ''} className={this.props.classes.aliasIdEdit} InputProps={{ - endAdornment: json.common?.alias?.id ? this.setAliasItem(json, 'id', '')}> : null, + endAdornment: json.common?.alias?.id ? + this.setAliasItem(json, 'id', '')}> : null, }} onChange={e => this.setAliasItem(json, 'id', e.target.value)} margin="normal" @@ -572,8 +682,9 @@ class ObjectBrowserEditObject extends Component { value={json.common?.alias?.id?.read || ''} className={this.props.classes.aliasIdEdit} InputProps={{ - endAdornment: json.common?.alias?.id?.read ? this.setAliasItem(json, 'id.read', '')}> : null, + endAdornment: json.common?.alias?.id?.read ? + this.setAliasItem(json, 'id.read', '')}> : null, }} onChange={e => this.setAliasItem(json, 'id.read', e.target.value)} margin="normal" @@ -591,16 +702,17 @@ class ObjectBrowserEditObject extends Component { value={json.common?.alias?.id?.write || ''} className={this.props.classes.aliasIdEdit} InputProps={{ - endAdornment: json.common?.alias?.id?.write ? this.setAliasItem(json, 'id.write', '')}> : null, + endAdornment: json.common?.alias?.id?.write ? + this.setAliasItem(json, 'id.write', '')}> : null, }} onChange={e => this.setAliasItem(json, 'id.write', e.target.value)} margin="normal" /> this.setState({selectId: false, selectRead: false, selectWrite: true})}>... + className={this.props.classes.button} + size="small" + onClick={() => this.setState({selectId: false, selectRead: false, selectWrite: true})}>... : null} this.setAliasItem(json, 'read', '')}> : null, - startAdornment: , + endAdornment: json.common?.alias?.read ? + this.setAliasItem(json, 'read', '')}> : null, + startAdornment: , }} onChange={e => this.setAliasItem(json, 'read', e.target.value)} helperText={this.state.readError || (this.props.t('JS function like') + ' "val / 5 + 21"')} @@ -651,8 +766,11 @@ class ObjectBrowserEditObject extends Component { helperText={this.state.writeError || (this.props.t('JS function like') + ' "(val - 21) * 5"')} className={this.props.classes.funcEdit} InputProps={{ - endAdornment: json.common?.alias?.write ? this.setAliasItem(json, 'write', '')}> : null, - startAdornment: , + endAdornment: json.common?.alias?.write ? + this.setAliasItem(json, 'write', '')}> : null, + startAdornment: , }} onChange={e => this.setAliasItem(json, 'write', e.target.value)} margin="normal" @@ -716,14 +834,14 @@ class ObjectBrowserEditObject extends Component { this.onClone(this.state.showCopyDialog, this.state.newId); }} color="primary" - startIcon={} + startIcon={} > {this.props.t('Clone')} @@ -736,7 +854,7 @@ class ObjectBrowserEditObject extends Component { const withAlias = this.props.obj._id.startsWith('alias.0') && this.props.obj.type === 'state'; return - {this.props.t('Edit object:')} {this.props.obj._id} + {this.props.t('Edit object:')} {this.props.obj._id} {this.renderTabs()} {this.renderCopyDialog()} {this.state.tab === 'object' ? -
+
: null @@ -791,19 +911,19 @@ class ObjectBrowserEditObject extends Component { onClick={e => this.onCopy(e)} disabled={this.state.error} title={this.isMobile ? this.props.t('Copy into clipboard') : ''} - startIcon={} + startIcon={} >{this.isMobile ? null : this.props.t('Copy into clipboard')}}
; diff --git a/src-rx/src/i18n/de.json b/src-rx/src/i18n/de.json index 258fab063..31b073838 100644 --- a/src-rx/src/i18n/de.json +++ b/src-rx/src/i18n/de.json @@ -913,7 +913,6 @@ "Logs": "Protokolle", "Files": "Dateien", "Edit object:": "Objekt bearbeiten:", - "Add attribute %s": "Attribut %s hinzufügen", "Remove attribute %s": "Attribut %s entfernen", "Write": "Schreiben", "Sorry, you cannot use ioBroker.": "Sie können ioBroker leider nicht verwenden.", diff --git a/src-rx/src/i18n/en.json b/src-rx/src/i18n/en.json index 7dd99d31f..cf03471db 100644 --- a/src-rx/src/i18n/en.json +++ b/src-rx/src/i18n/en.json @@ -913,7 +913,6 @@ "Logs": "Logs", "Files": "Files", "Edit object:": "Edit object:", - "Add attribute %s": "Add attribute %s", "Remove attribute %s": "Remove attribute %s", "Write": "Write", "Sorry, you cannot use ioBroker.": "Sorry, you cannot use ioBroker.", diff --git a/src-rx/src/i18n/es.json b/src-rx/src/i18n/es.json index b1dbe970c..035e8be98 100644 --- a/src-rx/src/i18n/es.json +++ b/src-rx/src/i18n/es.json @@ -913,7 +913,6 @@ "Logs": "Registro", "Files": "Archivos", "Edit object:": "Editar objeto:", - "Add attribute %s": "Agregar atributo %s", "Remove attribute %s": "Eliminar atributo %s", "Write": "Escribir", "Sorry, you cannot use ioBroker.": "Lo sentimos, no puede utilizar ioBroker.", diff --git a/src-rx/src/i18n/fr.json b/src-rx/src/i18n/fr.json index 9ce2c26f3..bc09ed974 100644 --- a/src-rx/src/i18n/fr.json +++ b/src-rx/src/i18n/fr.json @@ -913,7 +913,6 @@ "Logs": "Journal", "Files": "Des dossiers", "Edit object:": "Modifier l'objet:", - "Add attribute %s": "Ajouter l'attribut %s", "Remove attribute %s": "Supprimer l'attribut %s", "Write": "Écrire", "Sorry, you cannot use ioBroker.": "Désolé, vous ne pouvez pas utiliser ioBroker.", diff --git a/src-rx/src/i18n/it.json b/src-rx/src/i18n/it.json index 12f095f1a..22b6eaf0c 100644 --- a/src-rx/src/i18n/it.json +++ b/src-rx/src/i18n/it.json @@ -913,7 +913,6 @@ "Logs": "Registra", "Files": "File", "Edit object:": "Modifica oggetto:", - "Add attribute %s": "Aggiungi l'attributo %s", "Remove attribute %s": "Rimuovi l'attributo %s", "Write": "Scrivi", "Sorry, you cannot use ioBroker.": "Spiacenti, non puoi utilizzare ioBroker.", diff --git a/src-rx/src/i18n/nl.json b/src-rx/src/i18n/nl.json index 59391ec46..6bdb4cd1b 100644 --- a/src-rx/src/i18n/nl.json +++ b/src-rx/src/i18n/nl.json @@ -913,7 +913,6 @@ "Logs": "Log", "Files": "Bestanden", "Edit object:": "Object bewerken:", - "Add attribute %s": "Attribuut %s toevoegen", "Remove attribute %s": "Attribuut %s verwijderen", "Write": "Schrijven", "Sorry, you cannot use ioBroker.": "Sorry, u kunt ioBroker niet gebruiken.", diff --git a/src-rx/src/i18n/pl.json b/src-rx/src/i18n/pl.json index b53428c75..8d2806815 100644 --- a/src-rx/src/i18n/pl.json +++ b/src-rx/src/i18n/pl.json @@ -913,7 +913,6 @@ "Logs": "Zaloguj wiadomości", "Files": "Akta", "Edit object:": "Edytuj obiekt:", - "Add attribute %s": "Dodaj atrybut %s", "Remove attribute %s": "Usuń atrybut %s", "Write": "pisać", "Sorry, you cannot use ioBroker.": "Przepraszamy, nie możesz używać programu ioBroker.", diff --git a/src-rx/src/i18n/pt.json b/src-rx/src/i18n/pt.json index 08536ff3d..bb907400b 100644 --- a/src-rx/src/i18n/pt.json +++ b/src-rx/src/i18n/pt.json @@ -913,7 +913,6 @@ "Logs": "Log", "Files": "arquivos", "Edit object:": "Editar objeto:", - "Add attribute %s": "Adicionar atributo %s", "Remove attribute %s": "Remover atributo %s", "Write": "Escreva", "Sorry, you cannot use ioBroker.": "Desculpe, você não pode usar o ioBroker.", diff --git a/src-rx/src/i18n/ru.json b/src-rx/src/i18n/ru.json index 6e81bc08c..6e41494c4 100644 --- a/src-rx/src/i18n/ru.json +++ b/src-rx/src/i18n/ru.json @@ -917,7 +917,6 @@ "Logs": "Журнал", "Files": "Файлы", "Edit object:": "Изменить объект:", - "Add attribute %s": "Добавить атрибут %s", "Remove attribute %s": "Удалить атрибут %s", "Write": "Сохранить", "Sorry, you cannot use ioBroker.": "К сожалению, вы не можете использовать ioBroker.", diff --git a/src-rx/src/i18n/zh-cn.json b/src-rx/src/i18n/zh-cn.json index d49e856a7..f46e365d7 100644 --- a/src-rx/src/i18n/zh-cn.json +++ b/src-rx/src/i18n/zh-cn.json @@ -913,7 +913,6 @@ "Files": "档案", "loginTitle": "管理员", "Edit object:": "编辑对象:", - "Add attribute %s": "添加属性 %s", "Remove attribute %s": "删除属性 %s", "Write": "写", "Sorry, you cannot use ioBroker.": "抱歉,您不能使用ioBroker。",