Skip to content

Commit

Permalink
fix dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
zindlerb committed Feb 12, 2017
1 parent 3eb76c3 commit 4680c7f
Show file tree
Hide file tree
Showing 9 changed files with 259 additions and 181 deletions.
22 changes: 22 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ const Editor = React.createClass({
}
});

// TD:
// create menu from instances
// save redo instance on component
// enable and disable per-state

const template = [
{
submenu: [
Expand Down Expand Up @@ -78,6 +83,23 @@ const Editor = React.createClass({
}
}
]
},
{
label: 'Edit',
submenu: [
{
label: 'Undo',
click() {
actions.undo();
}
},
{
label: 'Redo',
click() {
actions.redo()
}
}
]
}
];

Expand Down
20 changes: 9 additions & 11 deletions app/base_components.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ ComponentsContainer.prototype = {
// Read
_getAttributes(componentMap, componentId, attributeOptions) {
let component = componentMap.get(componentId);
const { state, breakpoint } = attributeOptions || { state: NONE, breakpoint: NONE };

const masterId = component.get('masterId');
let masterAttrs = {};
let attributes;
Expand All @@ -369,16 +371,12 @@ ComponentsContainer.prototype = {
);
}

if (attributeOptions) {
const { state, breakpoint } = attributeOptions;

if (state !== NONE &&
component.getIn(['states', state])) {
attributes = component.getIn(['states', state]).toJS();
} else if (breakpoint !== NONE &&
component.getIn(['breakpoints', breakpoint])) {
attributes = component.getIn(['breakpoints', breakpoint]).toJS();
}
if (state !== NONE &&
component.getIn(['states', state])) {
attributes = component.getIn(['states', state]).toJS();
} else if (breakpoint !== NONE &&
component.getIn(['breakpoints', breakpoint])) {
attributes = component.getIn(['breakpoints', breakpoint]).toJS();
} else {
attributes = component.get('defaultAttributes').toJS();
}
Expand Down Expand Up @@ -511,7 +509,7 @@ ComponentsContainer.prototype = {

return componentJs;
} else {
return;
return null;
}
},

Expand Down
12 changes: 10 additions & 2 deletions app/containers/AssetsView.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { createSelector } from 'reselect';
import _ from 'lodash';
import { connect } from 'react-redux';
import { remote } from 'electron';
Expand Down Expand Up @@ -134,11 +135,18 @@ const AssetsView = React.createClass({
}
});

const assetsSelector = createSelector(
state => state.get('assets'),
(assets) => {
return _.toArray(assets.toJS());
}
);

export default connect(
(state) => {
return {
currentMainView: state.currentMainView,
assets: _.toArray(state.assets)
currentMainView: state.get('currentMainView'),
assets: assetsSelector(state)
}
},
null,
Expand Down
2 changes: 1 addition & 1 deletion app/containers/Attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export default connect((state) => {

return {
componentName: componentsContainer.getName(activeComponentId),
componentType: componentsContainer.getIn([
componentType: componentsContainer.components.getIn([
activeComponentId,
'componentType'
]),
Expand Down
49 changes: 3 additions & 46 deletions app/containers/LeftPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,6 @@ import TextField from '../components/forms/TextField';
import SidebarHeader from '../components/SidebarHeader';
import ComponentTree from '../components/ComponentTree';

/*
function Pages() {
let {
pages,
currentPageId,
} = this.props;
const pageList = _.map(pages, (page, ind) => {
const isActive = page.id === currentPageId;
return (
<li
className={classnames({
highlighted: isActive,
'c-default': isActive,
'c-pointer': !isActive
}, 'pl2 pv1 page-item')}
onClick={() => this.props.actions.changePage(page.id)}
key={ind}
>
{page.name}
</li>);
});
return (
<div>
<div className="tc">
<h2 className="f4 mt3 mb2">Pages</h2>
<CartoonButton
text="New Page"
onClick={() => this.props.actions.addPage()}
/>
</div>
<ul className="mt3">
{pageList}
</ul>
</div>
);
}
*/

const LeftPanel = React.createClass({
render() {
let body;
Expand Down Expand Up @@ -157,12 +117,9 @@ export default connect((state) => {
hoveredComponentId: state.get('hoveredComponentId'),
componentsContainer: state.get('componentsContainer'),
componentTreeId: state.getIn(['pages', state.get('currentPageId'), 'componentTreeId']),
siteComponents: state.siteComponents,
currentPageId: state.get('currentPageId'),
currentPage: state.getIn(['pages', state.get('currentPageId')])

// TD: figure out new droppoints
//otherPossibleTreeViewDropSpots: state.otherPossibleTreeViewDropSpots,
//selectedTreeViewDropSpot: state.selectedTreeViewDropSpot,
currentPage: state.getIn(['pages', state.get('currentPageId')]),
otherPossibleTreeViewDropSpots: state.get('otherPossibleTreeViewDropSpots') && state.get('otherPossibleTreeViewDropSpots').toJS(),
selectedTreeViewDropSpot: state.get('selectedTreeViewDropSpot') && state.get('selectedTreeViewDropSpot').toJS(),
}
}, null, null, { pure: false })(LeftPanel);
2 changes: 1 addition & 1 deletion app/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function serializerFactory() {
}

function deserialize(jsonState) {
let stateData = JSON.parse(jsonState);
let stateData = JSON.parse(jsonState);
let componentsMap = stateData.componentsContainer;
delete stateData.componentsContainer;
let imState = Immutable.fromJS(stateData);
Expand Down
Loading

0 comments on commit 4680c7f

Please sign in to comment.