Skip to content

Commit 8ec43e8

Browse files
committed
copy file to project
1 parent 4e57e9f commit 8ec43e8

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

CHANGELOG

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
- Added File menu
1010
- Create new files / better file selection
1111
- Save/Load individual assets
12-
- Art offset
12+
- Art offset [#15](/../../issues/15)
1313
- Blank entries in palette line
1414
- Rebuilt Project screen
1515
- Tree structure for projects

app/components/file/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,24 @@ import { workspace } from '#store/workspace';
55
import { Button } from '#ui';
66
import { selectTab } from '#components/layout/model';
77

8-
// set focused tab
9-
// selt focused obejct
8+
// TODO: set focused obejct
9+
1010
export const File = observer(() => {
1111
return (
1212
<>
1313
<FileObject obj={workspace.file} />
1414
{workspace.project && (
1515
<div className="project-copy">
16-
<Button color="blue" large onClick={() => {selectTab('Project')}}>copy to project</Button>
16+
<Button
17+
color="blue"
18+
large
19+
onClick={() => {
20+
workspace.project.copyFrom(workspace.file);
21+
selectTab('Project');
22+
}}
23+
>
24+
copy to project
25+
</Button>
1726
</div>
1827
)}
1928
</>

app/store/project.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { observable, autorun, action, computed } from 'mobx';
1+
import { observable, autorun, action, computed, toJS } from 'mobx';
22
import { uuid } from '#util/uuid';
33
import { ObjectDef } from '#store/objectdef';
44
import { promises, exists as fsExists } from 'fs';
@@ -89,4 +89,12 @@ export class Project {
8989
obj.uuid = uuid();
9090
this.objects.unshift(obj);
9191
};
92+
93+
@action copyFrom = (obj) => {
94+
const clone = toJS(obj);
95+
clone.name = 'file object';
96+
clone.uuid = uuid();
97+
this.node = clone.uuid;
98+
this.objects.unshift(clone);
99+
};
92100
}

0 commit comments

Comments
 (0)