Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat(component): simplify functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexpeschel authored and lkuechler committed Dec 14, 2017
1 parent 3996f36 commit f86d353
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions src/component/container/element_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,42 +94,31 @@ export class ElementList extends React.Component<ElementListProps> {
value: patternPath.replace(/^.*\//, ''),
onClick: updatePageElement,
handleDragStart: (e: React.DragEvent<HTMLElement>) => {
console.log('this', element);
this.props.store.setClipboardElement(element);
},
handleDragDropForChild: (e: React.DragEvent<HTMLElement>) => {
const transfePatternPath = e.dataTransfer.getData('patternPath');
const transferPatternPath = e.dataTransfer.getData('patternPath');
const parentElement = element.getParent();
if (!parentElement) {
return;
}
const pageElement = transferPatternPath ? new PageElement(this.props.store.getPattern(transferPatternPath)) : this.props.store.getClipboardElement();

if (!transfePatternPath) {
const elementListElement = this.props.store.getClipboardElement();
if (elementListElement) {
parentElement.addChild(
elementListElement,
element.getIndex()
);
}
if (!parentElement || !pageElement) {
return;
}

parentElement.addChild(
new PageElement(this.props.store.getPattern(transfePatternPath)),
pageElement,
element.getIndex()
);
},
handleDragDrop: (e: React.DragEvent<HTMLElement>) => {
const transfePatternPath = e.dataTransfer.getData('patternPath');
if (!transfePatternPath) {
const elementListElement = this.props.store.getClipboardElement();
if (elementListElement) {
element.addChild(elementListElement);
}
const transferPatternPath = e.dataTransfer.getData('patternPath');
const pageElement = transferPatternPath ? new PageElement(this.props.store.getPattern(transferPatternPath)) : this.props.store.getClipboardElement();

if (!pageElement) {
return;
}
element.addChild(new PageElement(this.props.store.getPattern(transfePatternPath)));

element.addChild(pageElement);
},
children: items,
active: element === selectedElement
Expand Down

0 comments on commit f86d353

Please sign in to comment.