add notification to investigations, clean up

This commit is contained in:
Jeff Bryner 2015-04-13 16:23:25 -07:00
Родитель 6c52c33313
Коммит 6d09eef85c
2 изменённых файлов: 34 добавлений и 8 удалений

Просмотреть файл

@ -476,7 +476,7 @@ if (Meteor.isClient) {
});
};
//log the user entering the incident
//log the user entering the template
activity=models.userAction();
activity.path='incident';
activity.itemId=Session.get('incidentID');
@ -506,10 +506,7 @@ if (Meteor.isClient) {
Session.set('displayMessage',fields.userId + '& is viewing this incident')
}
});
})
});
}); //end deps.autorun
@ -576,7 +573,7 @@ if (Meteor.isClient) {
};
Template.editincidentform.destroyed = function () {
//remove the record of the user entering the incident
//remove the record of the user entering the template
userActivity.remove(Template.instance.uaId);
}

Просмотреть файл

@ -547,11 +547,35 @@ if (Meteor.isClient) {
});
};
//log the user entering the template
activity=models.userAction();
activity.path='investigation';
activity.itemId=Session.get('investigationID');
Template.instance.uaId=userActivity.insert(activity);
//set up reactive data
Deps.autorun(function() {
Meteor.subscribe("investigation-details",Session.get('investigationID'), onReady=function(){
initDatePickers();
});
Meteor.subscribe("userActivity",onReady=function(){
//register a callback for new user activity
//to show a notify when someone enters
//screens the user is on
//only run onReady to avoid initialization 'add' messages.
cursorUserActivity=userActivity.find({path:'investigation',
itemId:Session.get('investigationID'),
userId: {$ne: Meteor.user().profile.email}
},
{
reactive:true})
.observeChanges(
{added: function(id,fields){
console.log(fields);
Session.set('displayMessage',fields.userId + '& is viewing this investigation')
}
});
});
}); //end deps.autorun
saveInvestigation = function(e, template) {
@ -621,6 +645,11 @@ if (Meteor.isClient) {
}();
};
Template.editinvestigationform.destroyed = function () {
//remove the record of the user entering the template
userActivity.remove(Template.instance.uaId);
}
Template.addinvestigationform.rendered = function() {
$('#dateOpened').daterangepicker({
singleDatePicker: true,