From 02c24bfecd85b2d4bba7404a65882e4ac6e40faf Mon Sep 17 00:00:00 2001 From: Laura Fuentes Grau Date: Sun, 24 May 2020 19:02:53 +0200 Subject: [PATCH] (edit-)lockAspect now works --- src/dashboard/dashboard.js | 3 +-- src/widget/edit-widget/edit-widget.js | 7 ++++--- src/widget/editable-widget-container.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dashboard/dashboard.js b/src/dashboard/dashboard.js index a03a418..3f38e30 100644 --- a/src/dashboard/dashboard.js +++ b/src/dashboard/dashboard.js @@ -42,7 +42,7 @@ class Dashboard extends Component { static lastWidgetKey = 0; static getStores() { - return [ DashboardStore, LoginStore, WidgetStore, SignalStore, ConfigStore, ICStore]; + return [ DashboardStore, LoginStore,FileStore, WidgetStore, SignalStore, ConfigStore, ICStore]; } static calculateState(prevState, props) { @@ -273,7 +273,6 @@ class Dashboard extends Component { }; uploadFile(data,widget){ - console.log("tschuuuu tschuuuu"); AppDispatcher.dispatch({ type: 'files/start-upload', data: data, diff --git a/src/widget/edit-widget/edit-widget.js b/src/widget/edit-widget/edit-widget.js index 331e3a6..30b9fd0 100644 --- a/src/widget/edit-widget/edit-widget.js +++ b/src/widget/edit-widget/edit-widget.js @@ -53,6 +53,7 @@ class EditWidgetDialog extends React.Component { } assignAspectRatio(changeObject, fileId) { + fileId = parseInt(fileId, 10) // get aspect ratio of file const file = this.props.files.find(element => element.id === fileId); @@ -113,9 +114,9 @@ class EditWidgetDialog extends React.Component { if (parts[1] === 'lockAspect') { //not a customProperty customProperty ? changeObject[parts[0]][parts[1]] = e.target.checked : changeObject[e.target.id] = e.target.checked; - + // correct image aspect if turned on - if (e.target.checked && this.state.temporal.customProperties.file) { + if (e.target.checked && (this.state.temporal.customProperties.file !== -1)) { changeObject = this.assignAspectRatio(changeObject, this.state.temporal.customProperties.file); } } else if (e.target.id.includes('file')) { @@ -123,7 +124,7 @@ class EditWidgetDialog extends React.Component { customProperty ? changeObject[parts[0]][parts[1]] = e.target.value : changeObject[e.target.id] = e.target.value; // get file and update size (if it's an image) - if ('lockAspect' in this.state.temporal && this.state.temporal.lockAspect) { + if ((changeObject.customProperties.file !== -1)&&('lockAspect' in this.state.temporal && this.state.temporal.lockAspect)) { // TODO this if condition requires changes to work!!! changeObject = this.assignAspectRatio(changeObject, e.target.value); } diff --git a/src/widget/editable-widget-container.js b/src/widget/editable-widget-container.js index f96e02c..5ac2a55 100644 --- a/src/widget/editable-widget-container.js +++ b/src/widget/editable-widget-container.js @@ -114,7 +114,7 @@ class EditableWidgetContainer extends React.Component { minWidth={widget.minWidth} minHeight={widget.minHeight} maxWidth ={widget.customProperties.maxWidth || '100%' } - lockAspectRatio={Boolean(widget.isLocked)} + lockAspectRatio={Boolean(widget.customProperties.lockAspect)} bounds={'parent'} className={widgetClasses} onResizeStart={this.borderWasClicked}