Skip to content

Commit

Permalink
* (bluefox) Changed the minimal required js-controller version to 3.3.21
Browse files Browse the repository at this point in the history
* (bluefox) Used web-socket library 8 (no node 10 support anymore)
  • Loading branch information
GermanBluefox committed Dec 24, 2021
1 parent 910a7f4 commit 3ea7dae
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 23 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ The icons may not be reused in other projects without the proper flaticon licens
-->

## Changelog
### __WORK IN PROGRESS__
* (bluefox) Fixed error in `AutocompleteSendTo`
* (bluefox) Fixed error in charts

### 5.2.2 (2021-12-21)
* (bluefox) Changed the minimal required js-controller version to 3.3.22
* (bluefox) Used web-socket library 8 (no node 10 support anymore)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ConfigAutocomplete extends ConfigGeneric {
this.setState({value: val}, () => this.onChange(this.props.attr, val));
}}
options={options}
getOptionLabel={option => option.label}
getOptionLabel={option => (option && option.label) || ''}
renderInput={params => <TextField
{...params}
error={!!error}
Expand All @@ -91,4 +91,4 @@ ConfigAutocomplete.propTypes = {
onChange: PropTypes.func,
};

export default withStyles(styles)(ConfigAutocomplete);
export default withStyles(styles)(ConfigAutocomplete);
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ class ConfigAutocompleteSendTo extends ConfigGeneric {
if (this.props.alive) {
const context = this.getContext();
if (context !== this.state.context) {
setTimeout(() => {
this.askInstance();
}, 300);
setTimeout(() => this.askInstance(), 300);
}
}

Expand Down Expand Up @@ -138,7 +136,7 @@ class ConfigAutocompleteSendTo extends ConfigGeneric {
fullWidth
freeSolo={!!this.props.schema.freeSolo}
options={options}
getOptionLabel={option => option.label}
getOptionLabel={option => (option && option.label) || ''}
className={this.props.classes.indeterminate}
onChange={(_, value) => {
const val = typeof value === 'object' ? (value ? value.value : '') : value;
Expand Down
14 changes: 7 additions & 7 deletions src-rx/src/components/JsonConfigComponent/ConfigGeneric.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ class ConfigGeneric extends Component {

componentDidMount() {
this.props.registerOnForceUpdate && this.props.registerOnForceUpdate(this.props.attr, this.onUpdate);

const LIKE_SELECT = ['select', 'autocomplete', 'autocompleteSendTo'];
// init default value
if (this.defaultValue !== undefined) {
const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
if (value === undefined || (this.props.schema.type === 'select' && (value === '' || value === null))) {
if (value === undefined || (LIKE_SELECT.includes(this.props.schema.type) && (value === '' || value === null))) {
setTimeout(() => {
if (this.props.custom) {
this.props.onChange(this.props.attr, this.defaultValue);
this.props.onChange(this.props.attr, this.defaultValue, () =>
this.props.forceUpdate([this.props.attr], this.props.data));
//this.onChange(this.props.attr, this.defaultValue);
} else {
ConfigGeneric.setValue(this.props.data, this.props.attr, this.defaultValue);
Expand Down Expand Up @@ -266,9 +267,8 @@ class ConfigGeneric extends Component {
if (this.props.custom) {
this.props.onChange(attr, newValue);

changed && changed.length && changed.forEach((_attr, i) => {
setTimeout(() => this.props.onChange(_attr, data[_attr]), i * 50);
});
changed && changed.length && changed.forEach((_attr, i) =>
setTimeout(() => this.props.onChange(_attr, data[_attr]), i * 50));
} else {
this.props.onChange(data, undefined, () =>
changed.length && this.props.forceUpdate(changed, data));
Expand Down Expand Up @@ -521,4 +521,4 @@ ConfigGeneric.propTypes = {
custom: PropTypes.bool,
};

export default ConfigGeneric;
export default ConfigGeneric;
19 changes: 14 additions & 5 deletions src-rx/src/components/JsonConfigComponent/ConfigStaticText.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,31 @@ const styles = theme => ({

class ConfigStaticText extends ConfigGeneric {
renderItem(error, disabled) {

if (this.props.schema.button) {
return <Button
variant={this.props.schema.variant || undefined}
color={this.props.schema.color || undefined}
className={this.props.classes.fullWidth}
disabled={disabled}
onClick={this.props.schema.href ? () => this.props.schema.href && window.open(this.props.schema.href, '_blank') : null}
onClick={this.props.schema.href ? () => {
// calculate one more time just before call
const href = this.props.schema.href ? this.getText(this.props.schema.href, true) : null;
href && window.open(href, '_blank');
} : null}
>
{this.props.schema.icon ? <Icon src={this.props.schema.icon} className={this.props.classes.icon}/> : null}
{this.getText(this.props.schema.text || this.props.schema.label, this.props.schema.noTranslation)}
</Button>
} else {
const href = this.props.schema.href ? this.getText(this.props.schema.href, true) : null;

return <span onClick={href ? () => window.open(href, '_blank') : null}
>{this.getText(this.props.schema.text || this.props.schema.label)}</span>;
return <span onClick={this.props.schema.href ? () => {
// calculate one more time just before call
const href = this.props.schema.href ? this.getText(this.props.schema.href, true) : null;
href && window.open(href, '_blank');
} : null}>
{this.getText(this.props.schema.text || this.props.schema.label)}
</span>;
}
}
}
Expand All @@ -49,4 +58,4 @@ ConfigStaticText.propTypes = {
onChange: PropTypes.func,
};

export default withStyles(styles)(ConfigStaticText);
export default withStyles(styles)(ConfigStaticText);
2 changes: 1 addition & 1 deletion src-rx/src/components/JsonConfigComponent/SCHEMA.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Possible types:

- `staticLink` - static link
- `label` - multi-language text
- `href` - link
- `href` - link. Link could be dynamic like `#tab-objects/customs/${data.parentId}`
- `button` - show link as button
- `icon` - icon for button

Expand Down
3 changes: 1 addition & 2 deletions src-rx/src/components/Object/ObjectChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,8 @@ const GRID_PADDING_RIGHT = 25;
class ObjectChart extends Component {
constructor(props) {
super(props);
let from;
if (!this.props.from) {
from = Date.now();
const from = new Date();
from.setHours(from.getHours() - 24 * 7);
this.start = from.getTime();
} else {
Expand Down
4 changes: 2 additions & 2 deletions src-rx/src/components/Object/ObjectHistoryData.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ class ObjectHistoryData extends Component {
<FormControl className={ classes.selectHistoryControl }>
<InputLabel>{ this.props.t('History instance') }</InputLabel>
<Select
value={ this.state.historyInstance}
value={ this.state.historyInstance || ''}
onChange={ e => {
const historyInstance = e.target.value;
window.localStorage.setItem('App.historyInstance', historyInstance);
Expand Down Expand Up @@ -1312,4 +1312,4 @@ ObjectHistoryData.propTypes = {
isFloatComma: PropTypes.bool,
};

export default withWidth()(withStyles(styles)(ObjectHistoryData));
export default withWidth()(withStyles(styles)(ObjectHistoryData));

0 comments on commit 3ea7dae

Please sign in to comment.