Compare commits
2 Commits
f3638d918d
...
4e92d717d5
Author | SHA1 | Date | |
---|---|---|---|
4e92d717d5 | |||
8c25b953b5 |
@ -19,7 +19,10 @@ def delete(user, id):
|
||||
|
||||
def get(user, id):
|
||||
db = database.get_db()
|
||||
return db.objects.find_one(ObjectId(id))
|
||||
obj = db.objects.find_one(ObjectId(id))
|
||||
if not obj:
|
||||
raise util.errors.NotFound('Object not found')
|
||||
return obj
|
||||
|
||||
def copy_to_project(user, id, project_id):
|
||||
db = database.get_db()
|
||||
|
@ -227,7 +227,7 @@ const mapStateToProps = (state, ownProps) => {
|
||||
return aDate < bDate;
|
||||
});
|
||||
const user = state.users.users.filter(u => state.auth.currentUserId === u._id)[0];
|
||||
const myProjects = state.projects.projects.filter(p => p.owner && p.owner.username === user.username);
|
||||
const myProjects = state.projects.projects.filter(p => p.owner?.username === user?.username);
|
||||
return { user, myProjects, project, objects, fullProjectPath: `${username}/${projectPath}`, object, comments };
|
||||
};
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
|
@ -59,14 +59,16 @@ class DraftPreview extends Component {
|
||||
const weftColourwayCanvas = document.querySelector(`.preview-${id} .weft-colourway`);
|
||||
const drawdownCanvas = document.querySelector(`.preview-${id} .drawdown`);
|
||||
const tieupsCanvas = document.querySelector(`.preview-${id} .tieups`);
|
||||
ctx.drawImage(warpColourwayCanvas, canvas.width - warpCanvas.width - weft.treadles * baseSize - 20, 0);
|
||||
ctx.drawImage(warpCanvas, canvas.width - warpCanvas.width - weft.treadles * baseSize - 20, 10);
|
||||
ctx.drawImage(weftCanvas, canvas.width - 10 - weft.treadles * baseSize, warp.shafts * baseSize + 20);
|
||||
ctx.drawImage(weftColourwayCanvas, canvas.width - 10, warp.shafts * baseSize + 20);
|
||||
ctx.drawImage(tieupsCanvas, canvas.width - weft.treadles * baseSize - 10, 10);
|
||||
ctx.drawImage(drawdownCanvas, canvas.width - drawdownCanvas.width - weft.treadles * baseSize - 20, warp.shafts * baseSize + 20);
|
||||
if (warpCanvas) {
|
||||
ctx.drawImage(warpColourwayCanvas, canvas.width - warpCanvas.width - weft.treadles * baseSize - 20, 0);
|
||||
ctx.drawImage(warpCanvas, canvas.width - warpCanvas.width - weft.treadles * baseSize - 20, 10);
|
||||
ctx.drawImage(weftCanvas, canvas.width - 10 - weft.treadles * baseSize, warp.shafts * baseSize + 20);
|
||||
ctx.drawImage(weftColourwayCanvas, canvas.width - 10, warp.shafts * baseSize + 20);
|
||||
ctx.drawImage(tieupsCanvas, canvas.width - weft.treadles * baseSize - 10, 10);
|
||||
ctx.drawImage(drawdownCanvas, canvas.width - drawdownCanvas.width - weft.treadles * baseSize - 20, warp.shafts * baseSize + 20);
|
||||
|
||||
this.props.onImageLoaded(canvas.toDataURL());
|
||||
this.props.onImageLoaded(canvas.toDataURL());
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,10 @@ class Tieups extends Component {
|
||||
const tieups = Object.assign([], this.props.tieups);
|
||||
|
||||
if (tieup >= tieups.length) this.fillUpTo(tieups, tieup);
|
||||
if (tieups[tieup] && tieups[tieup].indexOf(shaft) === -1) tieups[tieup].push(shaft);
|
||||
else tieups[tieup].splice(tieups[tieup].indexOf(shaft));
|
||||
if (tieups[tieup] !== undefined) {
|
||||
if (tieups[tieup].indexOf(shaft) === -1) tieups[tieup].push(shaft);
|
||||
else tieups[tieup].splice(tieups[tieup].indexOf(shaft));
|
||||
}
|
||||
this.props.updatePattern({ tieups });
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user