Template.activities.created = function () {
  // Get reference to template instance
  var instance = this;

  instance.showLatestActivities = new ReactiveVar();
};

Template.activities.rendered = function () {
  // Get reference to template instance
  var instance = this;

  // Set options for toggle switch
  var options = {secondaryColor: 'silver'};
  instance.allOrLatestToggle = document.querySelector("[name='all-or-latest']");
  instance.switch = new Switchery(instance.allOrLatestToggle, options);
};

Template.activities.events({
  "change [name='all-or-latest']": function (event, template) {
    // Get reference to template instance
    var instance = Template.instance();

    // Set reactive variable with value of all-or-latest toggle
    instance.showLatestActivities.set(instance.allOrLatestToggle.checked);
  }
});


Template.activities.helpers({
  "showLatestActivities": function () {
    // Get reference to template instance
    var instance = Template.instance();

    // Get value of show latest activities switch
    var showOnlyLatestActivities = instance.showLatestActivities.get();

    return showOnlyLatestActivities;
  }
});

@@ -1141,16 +1141,2114 @@
 vities;%0A
+  %7D,%0A  %22activities%22: function () %7B%0A    // Query Activities collection for all activities%0A    var activities = Activities.find().fetch();%0A%0A    // Create a placeholder array for resident objects%0A    var activitiesArray = %5B%5D;%0A%0A    // Iterate through activities%0A    activities.forEach(function (activity) %7B%0A      // Get all resident IDs%0A      var residentIds = activity.residentIds;%0A%0A      // Placeholder for resident names%0A      var homeNames = _.map(residentIds, function (residentId) %7B%0A        // Get the resident%0A        var resident = Residents.findOne(residentId);%0A%0A        // Get resident home name%0A        var homeName = resident.homeName();%0A%0A        return homeName;%0A      %7D);%0A%0A      // Get only unique home names%0A      var homeNamesUnique = _.uniq(homeNames);%0A%0A      // set resident names, type, duration, and date values%0A      var activityObject = %7B%0A        residents: activity.residentNames(),%0A        type: activity.activityType(),%0A        duration: activity.duration,%0A        activityDate: activity.activityDate,%0A        homeNames: homeNamesUnique%0A      %7D;%0A%0A      // Add activity object to residents list%0A      activitiesArray.push(activityObject);%0A    %7D);%0A%0A    return activitiesArray;%0A  %7D,%0A  'tableSettings': function () %7B%0A    var tableSettings = %7B%0A      showFilter: false,%0A      filters: %5B'residentFilter', 'homeFilter', 'typeFilter'%5D,%0A      fields: %5B%0A        %7B%0A          key: 'residents',%0A          label: 'Resident(s)',%0A          sortOrder: 1,%0A          sortDirection: 'ascending'%0A        %7D,%0A        %7B%0A          key: 'homeNames',%0A          label: 'Resident(s) Home(s)',%0A          sortOrder: 2,%0A          sortDirection: 'ascending'%0A        %7D,%0A        %7B%0A          key: 'type',%0A          label: 'Activity Type',%0A          sortOrder: 2,%0A          sortDirection: 'ascending'%0A        %7D,%0A        %7B%0A          key: 'duration',%0A          label: 'Duration',%0A        %7D,%0A        %7B%0A          key: 'activityDate',%0A          label: 'Activity Date',%0A          sortOrder: 0,%0A          sortDirection: 'descending',%0A          tmpl: Template.dateCell,%0A        %7D%0A      %5D,%0A    %7D;%0A%0A    return tableSettings;%0A
   %7D%0A%7D);%0A

Add activities and tableSettings helpers