Last active
July 27, 2016 17:57
-
-
Save jurajkrivda/69cadf99681114d952f5 to your computer and use it in GitHub Desktop.
Reactive fullcalendar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Template.Calendar.onCreated(function () { | |
const instance = this; | |
instance.viewDate = new ReactiveVar(); | |
instance.autorun(() => { | |
const viewDate = instance.viewDate.get(); | |
if (typeof viewDate !== 'undefined') { | |
const startDate = Math.round(viewDate.start / 1000); | |
const endDate = Math.round(viewDate.end / 1000); | |
instance.subscribe('subscribe', startDate, endDate); | |
} | |
}); | |
}); | |
Template.Calendar.onRendered(function () { | |
const instance = Template.instance(); | |
const calendar = instance.$('#calendar'); | |
instance.autorun(function () { | |
calendar.fullCalendar({ | |
// options | |
}); | |
const viewDate = instance.viewDate.get(); | |
if (typeof viewDate !== 'undefined') { | |
if (!!instance.handle) { | |
instance.handle.stop(); | |
} | |
const someData = Collection.find({ | |
$or: [ | |
{date: {$gte: new Date(viewDate.start * 1000)}}, | |
{date: {$lte: new Date(viewDate.end * 1000)}} | |
] | |
}); | |
instance.handle = someData.observeChanges({ | |
added: function (id, doc) { | |
calendar.fullCalendar('renderEvent', { | |
id, title | |
}, true); | |
}, | |
removed: function (value) { | |
calendar.fullCalendar('removeEvents', value); | |
} | |
}); | |
} | |
}) | |
}) |
Solved.
Appointments.find({ start: { $gte: new Date(args.start) }, end: { $lte: new Date(args.end) }, 'provider_id': args.provider_id }
Thanks
);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @jurajkrivda. i have been able to implement this partially. My challenge now is with the publish query.
this is the only variation i have been able to come up with and it only works partially.
this however ignores the provider_id term and also when u less than today, it doenst work, meaing only the greater than or equal to today works.
using the $or as u explained doesn't work at all. Please help me