Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
renderEnum(obj) {
let smartName = Utils.getSmartNameFromObj(obj, this.props.adapterName + '.' + this.props.instance, this.props.native.noCommon);
// convert old format
if (smartName && typeof smartName === 'object') {
smartName = smartName[I18n.getLanguage()] || smartName.en || '';
}
let name = Utils.getObjectNameFromObj(obj);
return (<div style="{{background:">
<span style="{{opacity:">{smartName || null}{smartName ? (<span> ({name})</span>) : name}</span>
<span style="{{opacity:">{obj._id}</span>
</div>
onToggleEnum(id) {
let obj = this.state.funcs.find(e => e._id === id) || this.state.rooms.find(e => e._id === id);
let smartName = Utils.getSmartNameFromObj(obj);
obj = JSON.parse(JSON.stringify(obj));
if (smartName !== false) {
Utils.disableSmartName(obj, this.props.adapterName + '.' + this.props.instance, this.props.native.noCommon);
} else {
Utils.removeSmartName(obj, this.props.adapterName + '.' + this.props.instance, this.props.native.noCommon);
}
this.addChanged(id);
this.props.socket.setObject(id, obj)
.then(() => {
// update obj
this.updateObjInState(id, obj);
this.informInstance(id);
setTimeout(() => this.removeChanged(id), 500);
onEdit(id) {
const obj = this.state.funcs.find(e => e._id === id) || this.state.rooms.find(e => e._id === id);
let smartName = Utils.getSmartNameFromObj(obj, this.props.adapterName + '.' + this.props.instance, this.props.native.noCommon);
if (typeof smartName === 'object' && smartName) {
smartName = smartName[I18n.getLanguage()] || smartName.en;
}
smartName = smartName || Utils.getObjectNameFromObj(obj, null, {language: I18n.getLanguage()});
this.setState({editId: id, editedSmartName: smartName});
}
if (enums.find(obj =>
this.state.editId !== obj._id && (
this.state.editedSmartName === Utils.getObjectNameFromObj(obj, null, {language: I18n.getLanguage()}) ||
this.state.editedSmartName === Utils.getSmartNameFromObj(obj, this.props.adapterName + '.' + this.props.instance, this.props.native.noCommon)))) {
this.setState({message: I18n.t('Duplicate name')});