Compare commits

...

2 Commits

Author SHA1 Message Date
4e92d717d5 Resolve outstanding issues 2022-04-18 15:02:52 +01:00
8c25b953b5 Fixed access to username when user is not yet 2022-04-18 14:31:19 +01:00
4 changed files with 18 additions and 11 deletions

View File

@ -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()

View File

@ -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 => ({

View File

@ -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);
}

View File

@ -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 });
}