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

Commit

Permalink
feat(store): add function for naming the page element
Browse files Browse the repository at this point in the history
  • Loading branch information
TheReincarnator authored and lkuechler committed Apr 4, 2018
1 parent 3c45437 commit 629e2c0
Show file tree
Hide file tree
Showing 11 changed files with 413 additions and 262 deletions.
8 changes: 4 additions & 4 deletions src/component/container/element-list.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { elementMenu } from '../../electron/context-menus';
import { ElementCommand } from '../../store/command/element-command';
import { ElementLocationCommand } from '../../store/command/element-location-command';
import { ElementWrapper } from './element-wrapper';
import { ListItemProps } from '../../lsg/patterns/list';
import { createMenu } from '../../electron/menu';
Expand Down Expand Up @@ -55,7 +55,7 @@ export class ElementList extends React.Component {

return {
label: key,
value: pattern.getName(),
value: element.getName(),
onClick: updatePageElement,
onContextMenu: () => elementMenu(element),
handleDragStart: (e: React.DragEvent<HTMLElement>) => {
Expand Down Expand Up @@ -97,7 +97,7 @@ export class ElementList extends React.Component {
}
}

store.execute(ElementCommand.addChild(newParent, draggedElement, newIndex));
store.execute(ElementLocationCommand.addChild(newParent, draggedElement, newIndex));
store.setSelectedElement(draggedElement);
},
handleDragDrop: (e: React.DragEvent<HTMLElement>) => {
Expand Down Expand Up @@ -125,7 +125,7 @@ export class ElementList extends React.Component {
return;
}

store.execute(ElementCommand.addChild(element, draggedElement));
store.execute(ElementLocationCommand.addChild(element, draggedElement));
store.setSelectedElement(draggedElement);
},
children: items,
Expand Down
4 changes: 2 additions & 2 deletions src/component/container/pattern-list.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Input from '../../lsg/patterns/input/';
import { ElementCommand } from '../../store/command/element-command';
import { ElementLocationCommand } from '../../store/command/element-location-command';
import { PatternFolder } from '../../store/styleguide/folder';
import { action } from 'mobx';
import { observer } from 'mobx-react';
Expand Down Expand Up @@ -114,7 +114,7 @@ export class PatternListContainer extends React.Component {
pattern,
setDefaults: true
});
store.execute(ElementCommand.addSibling(selectedElement, newPageElement));
store.execute(ElementLocationCommand.addSibling(selectedElement, newPageElement));
store.setSelectedElement(newPageElement);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/electron/context-menus.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MenuItemConstructorOptions, remote } from 'electron';
import { ElementCommand } from '../store/command/element-command';
import { ElementLocationCommand } from '../store/command/element-location-command';
import { PageElement } from '../store/page/page-element';
import { Store } from '../store/store';

Expand All @@ -12,7 +12,7 @@ export function elementMenu(element: PageElement): void {
label: 'Cut Element',
click: () => {
store.setClipboardElement(element);
store.execute(ElementCommand.remove(element));
store.execute(ElementLocationCommand.remove(element));
}
},
{
Expand All @@ -24,7 +24,7 @@ export function elementMenu(element: PageElement): void {
{
label: 'Delete element',
click: () => {
store.execute(ElementCommand.remove(element));
store.execute(ElementLocationCommand.remove(element));
}
},
{
Expand All @@ -37,7 +37,7 @@ export function elementMenu(element: PageElement): void {
const newPageElement = clipboardElement && clipboardElement.clone();

if (newPageElement) {
store.execute(ElementCommand.addSibling(element, newPageElement));
store.execute(ElementLocationCommand.addSibling(element, newPageElement));
}
}
},
Expand All @@ -48,7 +48,7 @@ export function elementMenu(element: PageElement): void {
const newPageElement = clipboardElement && clipboardElement.clone();

if (newPageElement) {
store.execute(ElementCommand.addChild(element, newPageElement));
store.execute(ElementLocationCommand.addChild(element, newPageElement));
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions src/electron/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
remote,
WebviewTag
} from 'electron';
import { ElementCommand } from '../store/command/element-command';
import { ElementLocationCommand } from '../store/command/element-location-command';
import * as FileExtraUtils from 'fs-extra';
import { PageElement } from '../store/page/page-element';
import * as PathUtils from 'path';
Expand Down Expand Up @@ -197,7 +197,7 @@ export function createMenu(): void {
const selectedElement: PageElement | undefined = store.getSelectedElement();
if (selectedElement && store.isElementFocussed()) {
store.setClipboardElement(selectedElement);
store.execute(ElementCommand.remove(selectedElement));
store.execute(ElementLocationCommand.remove(selectedElement));
}
Menu.sendActionToFirstResponder('cut:');
}
Expand All @@ -223,7 +223,9 @@ export function createMenu(): void {
const clipboardElement: PageElement | undefined = store.getClipboardElement();
if (selectedElement && clipboardElement && store.isElementFocussed()) {
const newPageElement = clipboardElement.clone();
store.execute(ElementCommand.addSibling(selectedElement, newPageElement));
store.execute(
ElementLocationCommand.addSibling(selectedElement, newPageElement)
);
store.setSelectedElement(newPageElement);
}
Menu.sendActionToFirstResponder('paste:');
Expand All @@ -240,7 +242,9 @@ export function createMenu(): void {
const selectedElement: PageElement | undefined = store.getSelectedElement();
if (selectedElement && store.isElementFocussed()) {
const newPageElement = selectedElement.clone();
store.execute(ElementCommand.addSibling(selectedElement, newPageElement));
store.execute(
ElementLocationCommand.addSibling(selectedElement, newPageElement)
);
store.setSelectedElement(newPageElement);
}
}
Expand Down Expand Up @@ -269,7 +273,7 @@ export function createMenu(): void {
click: () => {
const selectedElement: PageElement | undefined = store.getSelectedElement();
if (selectedElement) {
store.execute(ElementCommand.remove(selectedElement));
store.execute(ElementLocationCommand.remove(selectedElement));
store.setSelectedElement(undefined);
} else {
if (process.platform === 'darwin') {
Expand Down
Loading

0 comments on commit 629e2c0

Please sign in to comment.