From 550d2e71fee8d6c208de31821b2dc46a2029272a Mon Sep 17 00:00:00 2001 From: Kenneth Jao Date: Tue, 25 Apr 2017 22:09:03 -0400 Subject: [PATCH] updateWork fixes --- hourglass/client/main/main.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hourglass/client/main/main.js b/hourglass/client/main/main.js index a831a24..c0833ca 100644 --- a/hourglass/client/main/main.js +++ b/hourglass/client/main/main.js @@ -373,7 +373,6 @@ Template.main.helpers({ sendData("editWork"); }, eventClick: function(event, jsEvent, view) { // On-click for work. - console.log(event); Session.set("newWork", false); Session.set("currentWork", work.findOne({_id: event.id})); $(".overlay").velocity("fadeIn", 150); @@ -384,7 +383,6 @@ Template.main.helpers({ }); }, eventMouseover: function(event, jsEvent, view) { - console.log(event); var classid = work.findOne({_id: event.id})["class"]; var className = (classid === Meteor.userId()) ? "Personal" : classes.findOne({_id: classid}).name; var span = this.children[0].children[0]; @@ -1008,13 +1006,23 @@ getClasses = function(myClasses) { } updateWork = function(id, fields, type) { + if(type === "added") { + var allWork = Session.get("myWork").concat(Session.get("filterWork")); + if(allWork.filter(function(work) { + return work._id === id; + }).length !== 0) return; + } + if(type === "remove" && Session.get("myWork").concat(Session.get("filterWork")).length === 0) return; - if(type === "remove" && Session.get("myWork").filter(function(work) { // Removed work and exists in user data. + if(type === "remove" && Session.get("myWork").concat(Session.get("filterWork")).filter(function(work) { // Removed work and exists in user data. return work._id === id; }).length !== 0) { Session.set("myWork", Session.get("myWork").filter(function(work) { return work._id !== id; })); + Session.set("filterWork", Session.get("filterWork").filter(function(work) { + return work._id !== id; + })); return; }