removing single shape and removing all shapes from slide

This commit is contained in:
Anton Georgiev 2014-08-15 15:04:35 +00:00
parent 52e542adfc
commit 498725fdba
3 changed files with 45 additions and 0 deletions

View File

@ -12,6 +12,7 @@ Template.slide.helpers
callback(Template.slide.whiteboardPaperModel)
displaySlide: (wpm) ->
console.log "displaying slide"
currentPresentation = Meteor.Presentations.findOne({"presentation.current": true})
presentationId = currentPresentation?.presentation?.id
currentSlide = Meteor.Slides.findOne({"presentationId": presentationId, "slide.current": true})
@ -23,6 +24,25 @@ Template.slide.helpers
wpm = Template.slide.whiteboardPaperModel
wpm?.moveCursor(pointer.x, pointer.y)
manuallyDisplayShapes: ->
console.log "manually display shapes"
currentPresentation = Meteor.Presentations.findOne({"presentation.current": true})
presentationId = currentPresentation?.presentation?.id
currentSlide = Meteor.Slides.findOne({"presentationId": presentationId, "slide.current": true})
wpm = Template.slide.whiteboardPaperModel
shapes = Meteor.Shapes.find({whiteboardId: currentSlide?.slide?.id}).fetch()
for s in shapes
shapeInfo = s.shape?.shape
shapeType = shapeInfo?.type
for num in [0..3] # the coordinates must be in the range 0 to 1
shapeInfo.points[num] = shapeInfo.points[num] / 100
console.log "manually drawing shapee"
wpm.makeShape(shapeType, shapeInfo)
wpm.updateShape(shapeType, shapeInfo)
#### SHAPE ####
Template.shape.rendered = ->
# @data is the shape object coming from the {{#each}} in the html file
@ -36,3 +56,11 @@ Template.shape.rendered = ->
wpm.makeShape(shapeType, shapeInfo)
wpm.updateShape(shapeType, shapeInfo)
Template.shape.destroyed = ->
console.log "destroyed"
wpm = Template.slide.whiteboardPaperModel
wpm.clearShapes()
Template.slide.displaySlide(wpm)
Template.slide.manuallyDisplayShapes()

View File

@ -36,3 +36,15 @@ Meteor.methods
Meteor.Shapes.remove(id._id)
console.log "----removed shape[" + s.shape.id + "] from " + whiteboardId
console.log "remaining shapes on the slide:" + Meteor.Shapes.find({meetingId: meetingId, whiteboardId: whiteboardId}).fetch().length
removeShapeFromSlide: (meetingId, whiteboardId, shapeId) ->
console.log "remove a shape from slide:" + shapeId
shapeToRemove = Meteor.Shapes.findOne({meetingId: meetingId, whiteboardId: whiteboardId, "shape.id": shapeId})
if meetingId? and whiteboardId? and shapeId? and shapeToRemove?
console.log "found the shape to be removed"
Meteor.Shapes.remove(shapeToRemove._id)
console.log "----removed shape[" + shapeId + "] from " + whiteboardId
console.log "remaining shapes on the slide:" + Meteor.Shapes.find({meetingId: meetingId, whiteboardId: whiteboardId}).count()

View File

@ -237,6 +237,11 @@ class Meteor.RedisPubSub
Meteor.call("removeAllShapesFromSlide", meetingId, whiteboardId)
if message.header?.name is "undo_whiteboard_request"
whiteboardId = message.payload?.whiteboard_id
shapeId = message.payload?.shape_id
Meteor.call("removeShapeFromSlide", meetingId, whiteboardId, shapeId)
if message.header?.name in ["meeting_ended_message", "meeting_destroyed_event",