1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

WIP: fix image widget edit menu #267

This commit is contained in:
Laura Fuentes Grau 2020-11-01 20:57:24 +01:00
parent 95680ca5b7
commit c37a8d067f
3 changed files with 13 additions and 9 deletions

View file

@ -298,6 +298,11 @@ class Dashboard extends Component {
return;
}
if(data.type === "Image")
{
data.customProperties.update = true;
}
AppDispatcher.dispatch({
type: 'widgets/start-edit',
token: this.state.sessionToken,

View file

@ -115,6 +115,7 @@ class WidgetFactory {
widget.height = 200;
widget.customProperties.lockAspect = true;
widget.customProperties.file = -1; // ID of image file, -1 means non selected
widget.customProperties.update = false;
break;
case 'Button':
widget.minWidth = 100;

View file

@ -26,7 +26,6 @@ class WidgetImage extends React.Component {
this.state = {
file: undefined,
fileDate: null
}
}
@ -44,24 +43,23 @@ class WidgetImage extends React.Component {
componentDidUpdate(prevProps: Readonly<P>, prevState: Readonly<S>, snapshot: SS) {
if(this.props.widget.customProperties.file === -1){
this.props.widget.customProperties.update = false;
if(this.state.file !== undefined) this.setState({ file: undefined })
}
let file = this.props.files.find(file => file.id === parseInt(this.props.widget.customProperties.file, 10));
if (file !== undefined) {
if (this.state.file === undefined || (this.state.file.id !== file.id) || this.state.fileDate !== file.date) {
if (this.props.widget.customProperties.update) {
this.props.widget.customProperties.update = false;
AppDispatcher.dispatch({
type: 'files/start-download',
data: file.id,
token: this.props.token
});
this.setState({ file: file, fileDate: file.date });
this.setState({ file: file })
}
} else if (this.setState.file !== undefined) {
console.log("file undefined", file)
this.setState({file:undefined})
}
}