ui.scheduler.appointmentsPositioning.strategy.base.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /**
  2. * DevExtreme (ui/scheduler/rendering_strategies/ui.scheduler.appointmentsPositioning.strategy.base.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 _type = require("../../../core/utils/type");
  11. var _type2 = _interopRequireDefault(_type);
  12. function _interopRequireDefault(obj) {
  13. return obj && obj.__esModule ? obj : {
  14. "default": obj
  15. }
  16. }
  17. function _classCallCheck(instance, Constructor) {
  18. if (!(instance instanceof Constructor)) {
  19. throw new TypeError("Cannot call a class as a function")
  20. }
  21. }
  22. function _defineProperties(target, props) {
  23. for (var i = 0; i < props.length; i++) {
  24. var descriptor = props[i];
  25. descriptor.enumerable = descriptor.enumerable || false;
  26. descriptor.configurable = true;
  27. if ("value" in descriptor) {
  28. descriptor.writable = true
  29. }
  30. Object.defineProperty(target, descriptor.key, descriptor)
  31. }
  32. }
  33. function _createClass(Constructor, protoProps, staticProps) {
  34. if (protoProps) {
  35. _defineProperties(Constructor.prototype, protoProps)
  36. }
  37. if (staticProps) {
  38. _defineProperties(Constructor, staticProps)
  39. }
  40. Object.defineProperty(Constructor, "prototype", {
  41. writable: false
  42. });
  43. return Constructor
  44. }
  45. var COLLECTOR_DEFAULT_WIDTH = 24;
  46. var COMPACT_APPOINTMENT_DEFAULT_OFFSET = 3;
  47. var COMPACT_THEME_APPOINTMENT_DEFAULT_OFFSET = 22;
  48. var APPOINTMENT_MIN_COUNT = 1;
  49. var APPOINTMENT_DEFAULT_WIDTH = 40;
  50. var COLLECTOR_WIDTH_IN_PERCENTS = 75;
  51. var APPOINTMENT_INCREASED_WIDTH = 50;
  52. var AppointmentPositioningStrategy = function() {
  53. function AppointmentPositioningStrategy(renderingStrategy) {
  54. _classCallCheck(this, AppointmentPositioningStrategy);
  55. this._renderingStrategy = renderingStrategy
  56. }
  57. _createClass(AppointmentPositioningStrategy, [{
  58. key: "getRenderingStrategy",
  59. value: function() {
  60. return this._renderingStrategy
  61. }
  62. }, {
  63. key: "getDropDownAppointmentWidth",
  64. value: function(intervalCount, isAllDay) {
  65. if (isAllDay || !_type2.default.isDefined(isAllDay)) {
  66. return COLLECTOR_WIDTH_IN_PERCENTS * this.getRenderingStrategy().getDefaultCellWidth() / 100
  67. } else {
  68. return COLLECTOR_DEFAULT_WIDTH
  69. }
  70. }
  71. }, {
  72. key: "getCompactAppointmentTopOffset",
  73. value: function() {
  74. return COMPACT_APPOINTMENT_DEFAULT_OFFSET
  75. }
  76. }, {
  77. key: "getCompactAppointmentLeftOffset",
  78. value: function() {
  79. return COMPACT_APPOINTMENT_DEFAULT_OFFSET
  80. }
  81. }, {
  82. key: "getAppointmentDefaultOffset",
  83. value: function() {
  84. if (this.getRenderingStrategy()._isCompactTheme()) {
  85. return COMPACT_THEME_APPOINTMENT_DEFAULT_OFFSET
  86. }
  87. return this.getRenderingStrategy().instance.option("_appointmentOffset")
  88. }
  89. }, {
  90. key: "getDynamicAppointmentCountPerCell",
  91. value: function() {
  92. var renderingStrategy = this.getRenderingStrategy();
  93. var cellHeight = renderingStrategy.instance.fire("getCellHeight");
  94. var allDayCount = Math.floor((cellHeight - renderingStrategy._getAppointmentDefaultOffset()) / renderingStrategy._getAppointmentDefaultHeight()) || this._getAppointmentMinCount();
  95. if (renderingStrategy.hasAllDayAppointments()) {
  96. return {
  97. allDay: "vertical" === renderingStrategy.instance._groupOrientation ? allDayCount : renderingStrategy.instance.option("_appointmentCountPerCell"),
  98. simple: this._calculateDynamicAppointmentCountPerCell() || this._getAppointmentMinCount()
  99. }
  100. } else {
  101. return allDayCount
  102. }
  103. }
  104. }, {
  105. key: "getDropDownAppointmentHeight",
  106. value: function() {
  107. return
  108. }
  109. }, {
  110. key: "_getAppointmentMinCount",
  111. value: function() {
  112. return APPOINTMENT_MIN_COUNT
  113. }
  114. }, {
  115. key: "_calculateDynamicAppointmentCountPerCell",
  116. value: function() {
  117. return Math.floor(this.getRenderingStrategy()._getAppointmentMaxWidth() / APPOINTMENT_INCREASED_WIDTH)
  118. }
  119. }, {
  120. key: "_getAppointmentDefaultWidth",
  121. value: function() {
  122. return APPOINTMENT_DEFAULT_WIDTH
  123. }
  124. }]);
  125. return AppointmentPositioningStrategy
  126. }();
  127. module.exports = AppointmentPositioningStrategy;