Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
kswenson committed Nov 20, 2018
2 parents 15790ea + 852937c commit d05f1b4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## Version 0.1.1 - released November 20, 2018

- Bug fixes

### Asset Sizes

| File | Size | % Change from Previous Release |
|---|---|---|
| index.css | 64,876 bytes | 0.0% |
| index.js | 2,288,722 bytes | 0.0% |

## Version 0.1.0 - released November 19, 2018

- DrawTool: Support background image
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "collaborative-learning",
"version": "0.1.0",
"version": "0.1.1",
"description": "Collaborative Learning environment",
"main": "index.js",
"jest": {
Expand Down
19 changes: 11 additions & 8 deletions src/models/tools/drawing/drawing-content.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,30 @@ import { DrawingContentModel, kDrawingToolID, DrawingToolMetadataModel } from ".

describe("DrawingContentModel", () => {

it("accepts default arguments on creation", () => {
function createDrawingContent() {
const model = DrawingContentModel.create();
const metadata = DrawingToolMetadataModel.create({ id: "drawing-1" });
model.doPostCreate(metadata);
return model;
}

it("accepts default arguments on creation", () => {
const model = createDrawingContent();
expect(model.type).toBe(kDrawingToolID);
expect(model.changes).toEqual([]);
expect(model.selectedButton).toBe("select");
});

it("can reset the tool button", () => {
const model = DrawingContentModel.create();
const model = createDrawingContent();
model.setSelectedButton("vector");
expect(model.selectedButton).toBe("vector");
model.reset();
expect(model.selectedButton).toBe("select");
});

it("can delete a set of selected drawing objects", () => {
const model = DrawingContentModel.create();
const metadata = DrawingToolMetadataModel.create({ id: "drawing-1" });
model.doPostCreate(metadata);
const model = createDrawingContent();

model.setSelection(["a", "b"]);
model.deleteSelectedObjects();
Expand All @@ -32,9 +37,7 @@ describe("DrawingContentModel", () => {
});

it("can update the properties of a set of selected drawing objects", () => {
const model = DrawingContentModel.create();
const metadata = DrawingToolMetadataModel.create({ id: "drawing-1" });
model.doPostCreate(metadata);
const model = createDrawingContent();

model.setSelection(["a", "b"]);
model.setStroke("#000000");
Expand Down
12 changes: 9 additions & 3 deletions src/models/tools/drawing/drawing-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@ export interface DrawingToolChange {
export const DrawingToolMetadataModel = types
.model("DrawingToolMetadata", {
id: types.string,
selectedButton: "select",
selection: types.array(types.string)
})
.actions(self => ({
setSelectedButton(button: ToolbarModalButton) {
self.selectedButton = button;
},
setSelection(selection: string[]) {
self.selection.replace(selection);
}
Expand All @@ -100,7 +104,6 @@ export const DrawingContentModel = types
.model("DrawingTool", {
type: types.optional(types.literal(kDrawingToolID), kDrawingToolID),
changes: types.array(types.string),
selectedButton: "select",
stroke: DefaultToolbarSettings.stroke,
fill: DefaultToolbarSettings.fill,
strokeDashArray: DefaultToolbarSettings.strokeDashArray,
Expand Down Expand Up @@ -147,6 +150,9 @@ export const DrawingContentModel = types
get isUserResizable() {
return true;
},
get selectedButton() {
return self.metadata.selectedButton;
},
get hasSelectedObjects() {
return self.metadata.selection.length > 0;
}
Expand Down Expand Up @@ -174,7 +180,7 @@ export const DrawingContentModel = types
},

setSelectedButton(button: ToolbarModalButton) {
self.selectedButton = button;
self.metadata.setSelectedButton(button);
},

setSelection(ids: string[]) {
Expand All @@ -186,7 +192,7 @@ export const DrawingContentModel = types

// sets the model to how we want it to appear when a user first opens a document
reset() {
self.selectedButton = "select";
self.metadata.setSelectedButton("select");
}
}
};
Expand Down

0 comments on commit d05f1b4

Please sign in to comment.