Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VCalendarDaily.js 8.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  2. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  3. // Styles
  4. import '../../../src/stylus/components/_calendar-daily.styl';
  5. // Directives
  6. import Resize from '../../directives/resize';
  7. // Mixins
  8. import CalendarWithIntervals from './mixins/calendar-with-intervals';
  9. // Util
  10. import { convertToUnit } from '../../util/helpers';
  11. /* @vue/component */
  12. export default CalendarWithIntervals.extend({
  13. name: 'v-calendar-daily',
  14. directives: { Resize: Resize },
  15. data: function data() {
  16. return {
  17. scrollPush: 0
  18. };
  19. },
  20. computed: {
  21. classes: function classes() {
  22. return _extends({
  23. 'v-calendar-daily': true
  24. }, this.themeClasses);
  25. }
  26. },
  27. mounted: function mounted() {
  28. this.init();
  29. },
  30. methods: {
  31. init: function init() {
  32. this.$nextTick(this.onResize);
  33. },
  34. onResize: function onResize() {
  35. this.scrollPush = this.getScrollPush();
  36. },
  37. getScrollPush: function getScrollPush() {
  38. var area = this.$refs.scrollArea;
  39. var pane = this.$refs.pane;
  40. return area && pane ? area.offsetWidth - pane.offsetWidth : 0;
  41. },
  42. genHead: function genHead() {
  43. return this.$createElement('div', {
  44. staticClass: 'v-calendar-daily__head',
  45. style: {
  46. marginRight: this.scrollPush + 'px'
  47. }
  48. }, [this.genHeadIntervals()].concat(_toConsumableArray(this.genHeadDays())));
  49. },
  50. genHeadIntervals: function genHeadIntervals() {
  51. return this.$createElement('div', {
  52. staticClass: 'v-calendar-daily__intervals-head'
  53. });
  54. },
  55. genHeadDays: function genHeadDays() {
  56. return this.days.map(this.genHeadDay);
  57. },
  58. genHeadDay: function genHeadDay(day) {
  59. var _this = this;
  60. var slot = this.$scopedSlots.dayHeader;
  61. return this.$createElement('div', {
  62. key: day.date,
  63. staticClass: 'v-calendar-daily_head-day',
  64. class: this.getRelativeClasses(day),
  65. on: this.getDefaultMouseEventHandlers(':day', function (_e) {
  66. return _this.getSlotScope(day);
  67. })
  68. }, [this.genHeadWeekday(day), this.genHeadDayLabel(day), slot ? slot(day) : '']);
  69. },
  70. genHeadWeekday: function genHeadWeekday(day) {
  71. var color = day.present ? this.color : undefined;
  72. return this.$createElement('div', this.setTextColor(color, {
  73. staticClass: 'v-calendar-daily_head-weekday'
  74. }), this.weekdayFormatter(day, this.shortWeekdays));
  75. },
  76. genHeadDayLabel: function genHeadDayLabel(day) {
  77. var color = day.present ? this.color : undefined;
  78. return this.$createElement('div', this.setTextColor(color, {
  79. staticClass: 'v-calendar-daily_head-day-label',
  80. on: this.getMouseEventHandlers({
  81. 'click:date': { event: 'click', stop: true },
  82. 'contextmenu:date': { event: 'contextmenu', stop: true, prevent: true, result: false }
  83. }, function (_e) {
  84. return day;
  85. })
  86. }), this.dayFormatter(day, false));
  87. },
  88. genBody: function genBody() {
  89. return this.$createElement('div', {
  90. staticClass: 'v-calendar-daily__body'
  91. }, [this.genScrollArea()]);
  92. },
  93. genScrollArea: function genScrollArea() {
  94. return this.$createElement('div', {
  95. ref: 'scrollArea',
  96. staticClass: 'v-calendar-daily__scroll-area'
  97. }, [this.genPane()]);
  98. },
  99. genPane: function genPane() {
  100. return this.$createElement('div', {
  101. ref: 'pane',
  102. staticClass: 'v-calendar-daily__pane',
  103. style: {
  104. height: convertToUnit(this.bodyHeight)
  105. }
  106. }, [this.genDayContainer()]);
  107. },
  108. genDayContainer: function genDayContainer() {
  109. return this.$createElement('div', {
  110. staticClass: 'v-calendar-daily__day-container'
  111. }, [this.genBodyIntervals()].concat(_toConsumableArray(this.genDays())));
  112. },
  113. genDays: function genDays() {
  114. return this.days.map(this.genDay);
  115. },
  116. genDay: function genDay(day, index) {
  117. var _this2 = this;
  118. var slot = this.$scopedSlots.dayBody;
  119. var scope = this.getSlotScope(day);
  120. return this.$createElement('div', {
  121. key: day.date,
  122. staticClass: 'v-calendar-daily__day',
  123. class: this.getRelativeClasses(day),
  124. on: this.getDefaultMouseEventHandlers(':time', function (e) {
  125. return _this2.getSlotScope(_this2.getTimestampAtEvent(e, day));
  126. })
  127. }, [].concat(_toConsumableArray(this.genDayIntervals(index)), [slot ? slot(scope) : '']));
  128. },
  129. genDayIntervals: function genDayIntervals(index) {
  130. return this.intervals[index].map(this.genDayInterval);
  131. },
  132. genDayInterval: function genDayInterval(interval) {
  133. var height = convertToUnit(this.intervalHeight);
  134. var styler = this.intervalStyle || this.intervalStyleDefault;
  135. var slot = this.$scopedSlots.interval;
  136. var scope = this.getSlotScope(interval);
  137. var data = {
  138. key: interval.time,
  139. staticClass: 'v-calendar-daily__day-interval',
  140. style: _extends({
  141. height: height
  142. }, styler(interval))
  143. };
  144. var children = slot ? slot(scope) : undefined;
  145. return this.$createElement('div', data, children);
  146. },
  147. genBodyIntervals: function genBodyIntervals() {
  148. var _this3 = this;
  149. var data = {
  150. staticClass: 'v-calendar-daily__intervals-body',
  151. on: this.getDefaultMouseEventHandlers(':interval', function (e) {
  152. return _this3.getTimestampAtEvent(e, _this3.parsedStart);
  153. })
  154. };
  155. return this.$createElement('div', data, this.genIntervalLabels());
  156. },
  157. genIntervalLabels: function genIntervalLabels() {
  158. return this.intervals[0].map(this.genIntervalLabel);
  159. },
  160. genIntervalLabel: function genIntervalLabel(interval) {
  161. var height = convertToUnit(this.intervalHeight);
  162. var short = this.shortIntervals;
  163. var shower = this.showIntervalLabel || this.showIntervalLabelDefault;
  164. var show = shower(interval);
  165. var label = show ? this.intervalFormatter(interval, short) : undefined;
  166. return this.$createElement('div', {
  167. key: interval.time,
  168. staticClass: 'v-calendar-daily__interval',
  169. style: {
  170. height: height
  171. }
  172. }, [this.$createElement('div', {
  173. staticClass: 'v-calendar-daily__interval-text'
  174. }, label)]);
  175. }
  176. },
  177. render: function render(h) {
  178. return h('div', {
  179. class: this.classes,
  180. nativeOn: {
  181. dragstart: function dragstart(e) {
  182. e.preventDefault();
  183. }
  184. },
  185. directives: [{
  186. modifiers: { quiet: true },
  187. name: 'resize',
  188. value: this.onResize
  189. }]
  190. }, [!this.hideHeader ? this.genHead() : '', this.genBody()]);
  191. }
  192. });
  193. //# sourceMappingURL=VCalendarDaily.js.map