Created
November 3, 2015 16:09
-
-
Save czbaker/6d2a0cf3fed4bdf4a376 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.adminSystem.events({ | |
| "submit form": function(event) { | |
| event.preventDefault(); | |
| // Fetch current settings | |
| CurrentSettings = Settings.findOne(); | |
| theID = CurrentSettings._id; | |
| // Check options set. | |
| var timeSlots = $('#timeSlots').prop('checked'); | |
| //CurrentSettings.timeSlots = timeSlots; | |
| // var bDate = new Date($('.form').form('get value', 'beginDateTime')); | |
| // var eDate = new Date($('.form').form('get value', 'endDateTime')); | |
| var beginDateTime = moment($('.form').form('get value', 'beginDateTime'), "MM/DD/YYYY h:mm a"); | |
| var endDateTime = moment($('.form').form('get value', 'endDateTime'), "MM/DD/YYYY h:mm a"); | |
| console.log("Begin Date: " + beginDateTime.isValid()); | |
| console.log("End Date: " + endDateTime.isValid()); | |
| // If both fields are filled in | |
| if (beginDateTime && endDateTime) { | |
| if (!endDateTime.isAfter()) { | |
| // This is in the past! | |
| $('ui.basic.modal.error1').modal('show'); | |
| } | |
| if (endDateTime.isAfter(beginDateTime)) { | |
| console.log(theID); | |
| // Settings.update(theID, { $set: {timeSlots: timeSlots, start: beginDateTime, end: endDateTime} }); | |
| settingsDoc = { | |
| start: beginDateTime, | |
| end: endDateTime, | |
| timeSlots: timeSlots | |
| }; | |
| console.log(settingsDoc); | |
| Meteor.call('changeSettings', settingsDoc, function(err, result) { | |
| if (err && err.error === "not-admin") { | |
| console.log("Unable to update settings, not an admin!"); | |
| } else { | |
| console.log(result); | |
| } | |
| }); | |
| } | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment