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.4KB

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