Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. Template.privateStatementCalendarDay.onCreated(function () {
  2. var self = this;
  3. this.autorun(function () {
  4. console.log('created');
  5. var sId = Session.get("selectedStation"),
  6. station = Station.findOne(sId, {
  7. fields: {
  8. workTime: true
  9. }
  10. });
  11. self.m = moment(Router.current().params.date, "YYYY-MM-DD");
  12. if (isCurrentRoute('privateStatementCalendarDay') && !self.m.isValid()) {
  13. sAlert.warning('Не корректная дата!');
  14. Router.go('privateStatementCalendarMonth', {
  15. month: moment().format('YYYY-MM')
  16. });
  17. }
  18. if (isCurrentRoute('privateStatementCalendarDay') && !station.checkWorkDay(self.m)) {
  19. sAlert.warning('Выбранный день выходной!');
  20. Router.go('privateStatementCalendarMonth', {
  21. month: self.m.format('YYYY-MM')
  22. });
  23. }
  24. self.subscribe('calendarStatements', self.m.clone().startOf('day').toDate(), self.m.clone().endOf('day').toDate(), sId);
  25. });
  26. });
  27.  
  28. Template.privateStatementCalendarDay.onRendered(function () {
  29. var self = this;
  30. this.autorun(function () {
  31. console.log('rendered');
  32. var m = moment(Router.current().params.date, "YYYY-MM-DD");
  33. self.$('[data-toggle="popover"]').popover();
  34. });
  35. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement