Skip to content

Commit

Permalink
feat(client): make properties panel resizable
Browse files Browse the repository at this point in the history
Related to #866
Closes #911
  • Loading branch information
philippfromme authored and nikku committed Dec 1, 2018
1 parent 08a9376 commit f38fef8
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 28 deletions.
4 changes: 0 additions & 4 deletions client/src/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,6 @@ export class App extends Component {
}

saveWorkspace = () => {
console.log('App#saveWorkspace');

const {
workspace
} = this.props.globals;
Expand Down Expand Up @@ -378,8 +376,6 @@ export class App extends Component {
// save layout
config.layout = layout;

console.log('saving workspace', config);

workspace.save(config);
}

Expand Down
53 changes: 50 additions & 3 deletions client/src/app/tabs/bpmn/BpmnEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ import css from './BpmnEditor.less';

import generateImage from '../../util/generateImage';

import dragger from '../../../util/dom/dragger';

import classNames from 'classnames';

import { merge } from 'min-dash';

import defaultLayout from '../defaultLayout';


const COLORS = [{
title: 'White',
fill: 'white',
Expand Down Expand Up @@ -407,6 +410,37 @@ export class BpmnEditor extends CachedComponent {
onLayoutChanged(newLayout);
}

/**
* Returns dragger with cached properties panel width.
*/
handlePropertiesPanelResize = (width) => {

return dragger((event, delta) => {
const {
x
} = delta;

const {
onLayoutChanged
} = this.props;

const newWidth = width - x;

const open = newWidth > 25;

this.setState({
layout: merge(this.state.layout, {
propertiesPanel: {
open,
width: (open ? newWidth : 0)
}
})
}, () => {
onLayoutChanged(this.state.layout);
});
});
}

resize = () => {
const {
modeler
Expand All @@ -425,6 +459,10 @@ export class BpmnEditor extends CachedComponent {

const propertiesPanel = layout.propertiesPanel || defaultLayout.propertiesPanel;

const propertiesPanelStyle = {
width: propertiesPanel.open ? propertiesPanel.width : 0
};

return (
<div className={ css.BpmnEditor }>

Expand Down Expand Up @@ -533,9 +571,18 @@ export class BpmnEditor extends CachedComponent {
onContextMenu={ this.handleContextMenu }
></div>

<div className={ classNames('properties', { 'open': propertiesPanel.open }) }>
<div className="toggle" onClick={ this.handlePropertiesPanelToggle }>Properties Panel</div>
<div className="resize-handle"></div>
<div
className={ classNames('properties', { 'open': propertiesPanel.open }) }
style={ propertiesPanelStyle }>
<div
className="toggle"
onClick={ this.handlePropertiesPanelToggle }
draggable="true"
onDragStart={ this.handlePropertiesPanelResize(propertiesPanel.width) }>Properties Panel</div>
<div
className="resize-handle"
draggable="true"
onDragStart={ this.handlePropertiesPanelResize(propertiesPanel.width) }></div>
<div className="properties-container" ref={ this.propertiesPanelRef }></div>
</div>
</div>
Expand Down
12 changes: 6 additions & 6 deletions client/src/app/tabs/bpmn/BpmnEditor.less
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
border-left: solid 1px #CCC;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);

&:not(.open) .properties-container {
width: 0px;
}

.toggle {
position: absolute;
left: -30px;
Expand Down Expand Up @@ -54,8 +50,12 @@
}

.properties-container {
overflow: auto;
max-height: 100%;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow-y: auto;
}
}

Expand Down
52 changes: 49 additions & 3 deletions client/src/app/tabs/cmmn/CmmnEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { getCmmnEditMenu } from './getCmmnEditMenu';

import generateImage from '../../util/generateImage';

import dragger from '../../../util/dom/dragger';

import { merge } from 'min-dash';

import classNames from 'classnames';
Expand Down Expand Up @@ -345,13 +347,48 @@ export class CmmnEditor extends CachedComponent {
onLayoutChanged(newLayout);
}

/**
* Returns dragger with cached properties panel width.
*/
handlePropertiesPanelResize = (width) => {

return dragger((event, delta) => {
const {
x
} = delta;

const {
onLayoutChanged
} = this.props;

const newWidth = width - x;

const open = newWidth > 25;

this.setState({
layout: merge(this.state.layout, {
propertiesPanel: {
open,
width: (open ? newWidth : 0)
}
})
}, () => {
onLayoutChanged(this.state.layout);
});
});
}

render() {
const {
layout
} = this.state;

const propertiesPanel = layout.propertiesPanel || defaultLayout.propertiesPanel;

const propertiesPanelStyle = {
width: propertiesPanel.open ? propertiesPanel.width : 0
};

return (
<div className={ css.CmmnEditor }>

Expand All @@ -362,9 +399,18 @@ export class CmmnEditor extends CachedComponent {
onContextMenu={ this.handleContextMenu }
></div>

<div className={ classNames('properties', { 'open': propertiesPanel.open }) }>
<div className="toggle" onClick={ this.handlePropertiesPanelToggle }>Properties Panel</div>
<div className="resize-handle"></div>
<div
className={ classNames('properties', { 'open': propertiesPanel.open }) }
style={ propertiesPanelStyle }>
<div
className="toggle"
onClick={ this.handlePropertiesPanelToggle }
draggable="true"
onDragStart={ this.handlePropertiesPanelResize(propertiesPanel.width) }>Properties Panel</div>
<div
className="resize-handle"
draggable="true"
onDragStart={ this.handlePropertiesPanelResize(propertiesPanel.width) }></div>
<div className="properties-container" ref={ this.propertiesPanelRef }></div>
</div>
</div>
Expand Down
4 changes: 0 additions & 4 deletions client/src/app/tabs/cmmn/CmmnEditor.less
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
border-left: solid 1px #CCC;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);

&:not(.open) .properties-container {
width: 0px;
}

.toggle {
position: absolute;
left: -30px;
Expand Down
3 changes: 2 additions & 1 deletion client/src/app/tabs/defaultLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export default {
open: false
},
propertiesPanel: {
open: true
open: true,
width: 250
}
};
52 changes: 49 additions & 3 deletions client/src/app/tabs/dmn/DmnEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import css from './DmnEditor.less';

import generateImage from '../../util/generateImage';

import dragger from '../../../util/dom/dragger';

import { merge } from 'min-dash';

import classNames from 'classnames';
Expand Down Expand Up @@ -469,13 +471,48 @@ class DmnEditor extends CachedComponent {
});
}

/**
* Returns dragger with cached properties panel width.
*/
handlePropertiesPanelResize = (width) => {

return dragger((event, delta) => {
const {
x
} = delta;

const {
onLayoutChanged
} = this.props;

const newWidth = width - x;

const open = newWidth > 25;

this.setState({
layout: merge(this.state.layout, {
propertiesPanel: {
open,
width: (open ? newWidth : 0)
}
})
}, () => {
onLayoutChanged(this.state.layout);
});
});
}

render() {
const {
layout
} = this.state;

const propertiesPanel = layout.propertiesPanel || defaultLayout.propertiesPanel;

const propertiesPanelStyle = {
width: propertiesPanel.open ? propertiesPanel.width : 0
};

return (
<div className={ css.DmnEditor }>

Expand All @@ -493,9 +530,18 @@ class DmnEditor extends CachedComponent {

<div className="diagram" ref={ this.ref }></div>

<div className={ classNames('properties', { 'open': propertiesPanel.open }) }>
<div className="toggle" onClick={ this.handlePropertiesPanelToggle }>Properties Panel</div>
<div className="resize-handle"></div>
<div
className={ classNames('properties', { 'open': propertiesPanel.open }) }
style={ propertiesPanelStyle }>
<div
className="toggle"
onClick={ this.handlePropertiesPanelToggle }
draggable="true"
onDragStart={ this.handlePropertiesPanelResize(propertiesPanel.width) }>Properties Panel</div>
<div
className="resize-handle"
draggable="true"
onDragStart={ this.handlePropertiesPanelResize(propertiesPanel.width) }></div>
<div className="properties-container" ref={ this.propertiesPanelRef }></div>
</div>
</div>
Expand Down
4 changes: 0 additions & 4 deletions client/src/app/tabs/dmn/DmnEditor.less
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
border-left: solid 1px #CCC;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);

&:not(.open) .properties-container {
width: 0px;
}

.toggle {
position: absolute;
left: -30px;
Expand Down
Loading

0 comments on commit f38fef8

Please sign in to comment.