ui.scheduler.timeline_month.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * DevExtreme (ui/scheduler/workspaces/ui.scheduler.timeline_month.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. var registerComponent = require("../../../core/component_registrator");
  11. var SchedulerTimeline = require("./ui.scheduler.timeline");
  12. var dateUtils = require("../../../core/utils/date");
  13. var TIMELINE_CLASS = "dx-scheduler-timeline-month";
  14. var DAY_IN_MILLISECONDS = 864e5;
  15. var toMs = dateUtils.dateToMilliseconds;
  16. var SchedulerTimelineMonth = SchedulerTimeline.inherit({
  17. _renderView: function() {
  18. this.callBase();
  19. this._updateScrollable()
  20. },
  21. _getElementClass: function() {
  22. return TIMELINE_CLASS
  23. },
  24. _getDateHeaderTemplate: function() {
  25. return this.option("dateCellTemplate")
  26. },
  27. _getHiddenInterval: function() {
  28. return 0
  29. },
  30. _getIndicationFirstViewDate: function() {
  31. return dateUtils.trimTime(new Date(this._firstViewDate))
  32. },
  33. getCellDuration: function() {
  34. return toMs("day")
  35. },
  36. calculateEndViewDate: function(dateOfLastViewCell) {
  37. return new Date(dateOfLastViewCell.getTime() + this._calculateDayDuration() * toMs("hour"))
  38. },
  39. _getCellCount: function() {
  40. var currentDate = this.option("currentDate");
  41. var cellCount = 0;
  42. if (this._isWorkSpaceWithCount()) {
  43. var intervalCount = this.option("intervalCount");
  44. for (var i = 1; i <= intervalCount; i++) {
  45. cellCount += new Date(currentDate.getFullYear(), currentDate.getMonth() + i, 0).getDate()
  46. }
  47. } else {
  48. cellCount = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0).getDate()
  49. }
  50. return cellCount
  51. },
  52. _setFirstViewDate: function() {
  53. this._firstViewDate = dateUtils.getFirstMonthDate(this.option("currentDate"));
  54. this._setStartDayHour(this._firstViewDate)
  55. },
  56. _getFormat: function() {
  57. return this._formatWeekdayAndDay
  58. },
  59. _getDateByIndex: function(headerIndex) {
  60. var resultDate = new Date(this._firstViewDate);
  61. resultDate.setDate(this._firstViewDate.getDate() + headerIndex);
  62. return resultDate
  63. },
  64. _getInterval: function() {
  65. return DAY_IN_MILLISECONDS
  66. },
  67. _getIntervalBetween: function(currentDate) {
  68. var firstViewDate = this.getStartViewDate();
  69. var timeZoneOffset = dateUtils.getTimezonesDifference(firstViewDate, currentDate);
  70. return currentDate.getTime() - (firstViewDate.getTime() - 36e5 * this.option("startDayHour")) - timeZoneOffset
  71. },
  72. calculateEndDate: function(startDate) {
  73. var startDateCopy = new Date(startDate);
  74. return new Date(startDateCopy.setHours(this.option("endDayHour")))
  75. },
  76. _calculateHiddenInterval: function() {
  77. return 0
  78. },
  79. _getDateByCellIndexes: function(rowIndex, cellIndex) {
  80. var date = this.callBase(rowIndex, cellIndex);
  81. this._setStartDayHour(date);
  82. return date
  83. },
  84. needUpdateScrollPosition: function(hours, minutes, bounds, date) {
  85. return this._dateWithinBounds(bounds, date)
  86. },
  87. getPositionShift: function() {
  88. return {
  89. top: 0,
  90. left: 0,
  91. cellPosition: 0
  92. }
  93. }
  94. });
  95. registerComponent("dxSchedulerTimelineMonth", SchedulerTimelineMonth);
  96. module.exports = SchedulerTimelineMonth;