1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 96× 96× 96× 1× 96× 96× 96× 96× 96× 96× 635× 635× 96× 96× 22× 74× 74× 36× 36× 38× 96× 96× 1× 22× 22× 264× 264× 264× 264× 264× 264× 264× 264× 264× 9898× 9898× 9898× 9898× 832× 9066× 9066× 99× 99× 99× 1× 38× 38× 38× 38× 38× 38× 38× 38× 38× 38× 38× 38× 456× 456× 456× 456× 456× 456× 456× 456× 456× 324× 456× 13871× 13871× 13871× 4016× 4016× 4016× 4016× 388× 388× 4016× 4016× 9855× 9855× 13871× 13871× 13871× 13871× 13871× 13871× 730× 13871× 13871× 13871× 971× 971× 971× 971× 971× 971× 971× 971× 971× 971× 415× 3200× 415× 3202× 415× 41× 41× 41× 374× 209× 721× 721× 464× 464× 464× 464× 257× 257× 257× 35× 35× 35× 13871× 13871× 971× 13871× 13871× 4016× 4016× 38× 1× 1× 1× 37× 37× 37× 29× 29× 29× 1× 1259× 1259× 1259× 900× 264× 636× 1259× 1083× 447× 636× 1259× 1× 36× 36× 36× 36× 36× 36× 36× 36× 36× 36× 36× 36× 36× 36× 20× 240× 240× 1440× 1440× 16× 100× 100× 1160× 1160× 36× 1× 1× 30× 30× 1× 1× 1× 1× 12× 12× 12× 60× 60× 60× 60× 60× 60× 30× 30× 1× 2600× 2600× 2600× 2600× 2600× 2600× 2600× 2600× 2600× 2600× 177× 177× 177× 177× 177× 177× 177× 177× 177× 177× 3× 174× 109× 209× 109× 55× 109× 43× 131× 111× 111× 111× 20× 20× 20× 8× 9× 20× 2600× 2600× 177× 177× 3× 174× 20× 1× 575× 575× 575× 575× 575× 575× 448× 448× 575× 6× 569× 183× 183× 11× 183× 386× 386× 569× 569× 569× 569× 29× 569× 569× 569× 569× 569× 569× 114× 455× 332× 123× 123× 1× 318× 114× 204× 204× 20× 184× 204× 204× 204× 204× 204× 204× 204× 21× 204× 204× 1× 575× 575× 575× 575× 575× 114× 114× 575× 575× 575× 575× 575× 575× 575× 575× 575× 324× 251× 251× 575× 575× 575× 575× 575× 575× 575× 1× 752× 752× 752× 752× 752× 752× 752× 752× 752× 288× 752× 164× 164× 164× 164× 588× 588× 464× 464× 464× 38× 464× 752× 752× 9× 752× 752× 1× 752× 30× 30× 752× 22× 22× 1× 756× 756× 756× 756× 127× 127× 127× 127× 629× 126× 126× 503× 756× 3769× 3769× 3769× 3769× 3769× 1258× 2511× 120× 41× 756× 1× 96× 96× 1144× 1× 74× 74× 74× 2138× 2138× 1× 80× 80× 1× 1× | /* istanbul ignore next */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "./timeline-view", "../base/util", "../base/constant", "../base/css-constant"], function (require, exports, ej2_base_1, ej2_base_2, timeline_view_1, util, events, cls) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var EVENT_GAP = 2; var YearEvent = (function (_super) { __extends(YearEvent, _super); function YearEvent(parent) { var _this = _super.call(this, parent, 'day') || this; _this.isResource = false; return _this; } YearEvent.prototype.renderAppointments = function () { Eif (this.parent.dragAndDropModule) { this.parent.dragAndDropModule.setDragArea(); } this.fields = this.parent.eventFields; var elementSelector = (this.parent.currentView === 'Year') ? '.' + cls.APPOINTMENT_CLASS : '.' + cls.APPOINTMENT_WRAPPER_CLASS + ',.' + cls.MORE_INDICATOR_CLASS; var eventWrappers = [].slice.call(this.parent.element.querySelectorAll(elementSelector)); for (var _i = 0, eventWrappers_1 = eventWrappers; _i < eventWrappers_1.length; _i++) { var wrapper = eventWrappers_1[_i]; ej2_base_1.remove(wrapper); } this.renderedEvents = []; if (this.parent.currentView === 'Year') { this.yearViewEvents(); } else { this.removeCellHeight(); if (this.parent.activeViewOptions.group.resources.length > 0 && !this.parent.uiStateValues.isGroupAdaptive) { this.isResource = true; this.timelineResourceEvents(); } else { this.timelineYearViewEvents(); } } this.parent.renderTemplates(); this.parent.notify(events.contentReady, {}); }; YearEvent.prototype.yearViewEvents = function () { var months = this.getMonths(); for (var _i = 0, months_1 = months; _i < months_1.length; _i++) { var month = months_1[_i]; var queryString = ".e-month-calendar:nth-child(" + (months.indexOf(month) + 1) + ") td.e-work-cells"; var workCells = [].slice.call(this.parent.element.querySelectorAll(queryString)); var monthDate = new Date(this.parent.selectedDate.getFullYear(), month, 1); var monthStart = this.parent.calendarUtil.getMonthStartDate(new Date(monthDate.getTime())); var monthEnd = this.parent.calendarUtil.getMonthEndDate(new Date(monthDate.getTime())); var startDate = util.getWeekFirstDate(monthStart, this.parent.activeViewOptions.firstDayOfWeek); var endDate = util.addDays(util.getWeekLastDate(monthEnd, this.parent.activeViewOptions.firstDayOfWeek), 1); for (var index = 0; startDate.getTime() < endDate.getTime(); index++) { var start = util.resetTime(new Date(startDate.getTime())); var end = util.addDays(new Date(start.getTime()), 1); startDate = util.addDays(new Date(startDate.getTime()), 1); if (!this.parent.isMinMaxDate(start)) { continue; } var filterEvents = this.parent.eventBase.filterEvents(start, end); if (filterEvents.length > 0) { var workCell = workCells[parseInt(index.toString(), 10)]; Eif (workCell) { workCell.appendChild(ej2_base_1.createElement('div', { className: cls.APPOINTMENT_CLASS })); } } } } }; YearEvent.prototype.timelineYearViewEvents = function () { var _this = this; var workCell = this.parent.element.querySelector('.' + cls.WORK_CELLS_CLASS + ':not(.' + cls.OTHERMONTH_CLASS + ')'); this.cellWidth = this.parent.getElementWidth(workCell); this.cellHeader = util.getOuterHeight(workCell.querySelector('.' + cls.DATE_HEADER_CLASS)); var eventTable = this.parent.element.querySelector('.' + cls.EVENT_TABLE_CLASS); this.eventHeight = this.parent.getElementHeightFromClass(eventTable, cls.APPOINTMENT_CLASS); var selector = "." + cls.MONTH_HEADER_WRAPPER + " tbody tr,." + cls.RESOURCE_COLUMN_TABLE_CLASS + " tbody tr,." + cls.CONTENT_TABLE_CLASS + " tbody tr"; this.addCellHeight(selector, this.eventHeight, EVENT_GAP, this.cellHeader, this.moreIndicatorHeight); var wrapperCollection = [].slice.call(this.parent.element.querySelectorAll('.' + cls.APPOINTMENT_CONTAINER_CLASS)); var months = this.getMonths(); var groupIndex = (this.parent.activeViewOptions.group.resources.length > 0 && this.parent.uiStateValues.isGroupAdaptive) ? this.parent.uiStateValues.groupIndex : undefined; for (var row = 0; row < months.length; row++) { var wrapper = wrapperCollection[parseInt(row.toString(), 10)]; var td = row + 1; var eventWrapper = ej2_base_1.createElement('div', { className: cls.APPOINTMENT_WRAPPER_CLASS }); wrapper.appendChild(eventWrapper); var monthStart = new Date(this.parent.selectedDate.getFullYear(), months[parseInt(row.toString(), 10)], 1); var monthEnd = new Date(monthStart.getFullYear(), monthStart.getMonth() + 1, 0); var dayIndex = monthStart.getDay(); var isSpannedCollection = []; if (this.parent.activeViewOptions.orientation === 'Horizontal') { this.renderedEvents = []; } while (monthStart.getTime() <= monthEnd.getTime()) { var leftValue = void 0; var rightValue = void 0; if (this.parent.activeViewOptions.orientation === 'Vertical') { var wrapper_1 = wrapperCollection[parseInt(dayIndex.toString(), 10)]; td = dayIndex + 1; eventWrapper = wrapper_1.querySelector('.' + cls.APPOINTMENT_WRAPPER_CLASS); if (!eventWrapper) { eventWrapper = ej2_base_1.createElement('div', { className: cls.APPOINTMENT_WRAPPER_CLASS }); wrapper_1.appendChild(eventWrapper); } Iif (this.parent.enableRtl) { rightValue = row * this.cellWidth; } else { leftValue = row * this.cellWidth; } } else { Iif (this.parent.enableRtl) { rightValue = ((dayIndex + monthStart.getDate()) - 1) * this.cellWidth; } else { leftValue = ((dayIndex + monthStart.getDate()) - 1) * this.cellWidth; } } var rowTd = this.parent.element.querySelector(".e-content-wrap tr:nth-child(" + td + ") td"); this.cellHeight = rowTd.offsetHeight; var dayStart = util.resetTime(new Date(monthStart.getTime())); var dayEnd = util.addDays(new Date(dayStart.getTime()), 1); var resource = void 0; if (this.parent.uiStateValues.isGroupAdaptive) { resource = this.parent.resourceBase.lastResourceLevel[this.parent.uiStateValues.groupIndex]; } var dayEvents = this.parent.eventBase.filterEvents(dayStart, dayEnd, undefined, resource); dayEvents = this.parent.eventBase.sortByDateTime(dayEvents); var _loop_1 = function (index, count) { var eventData = ej2_base_1.extend({}, dayEvents[parseInt(index.toString(), 10)], null, true); this_1.updateSpannedEvents(eventData, dayStart, dayEnd); var overlapIndex = this_1.getIndex(dayStart); eventData.Index = overlapIndex; var availedHeight = this_1.cellHeader + (this_1.eventHeight * (overlapIndex + 1)) + EVENT_GAP + this_1.moreIndicatorHeight; var appArea = this_1.cellHeight - this_1.cellHeader - this_1.moreIndicatorHeight; var renderedAppCount = Math.floor(appArea / (this_1.eventHeight + EVENT_GAP)); var eventsPerRow = this_1.parent.rowAutoHeight ? 1 : this_1.parent.activeViewOptions.maxEventsPerRow; var moreIndicatorCount = this_1.parent.activeViewOptions.maxEventsPerRow ? count - eventsPerRow : (count - renderedAppCount) <= 0 ? 1 : count - renderedAppCount; if (this_1.parent.activeViewOptions.orientation === 'Horizontal') { var isRendered = this_1.renderedEvents.filter(function (eventObj) { return eventObj.Guid === eventData.Guid; }); var isSpanned = isSpannedCollection.filter(function (eventObj) { return eventObj.Guid === eventData.Guid; }); if (isRendered.length > 0 && isRendered[0].MoreIndicator || isSpanned.length > 0 && isSpanned[0].MoreIndicator) { var moreIndex = this_1.parent.activeViewOptions.orientation === 'Horizontal' ? row : dayIndex; this_1.renderMoreIndicator(eventWrapper, moreIndicatorCount, dayStart, moreIndex, leftValue, rightValue, groupIndex); return "continue"; } else if (isRendered.length > 0 || isSpanned.length > 0) { return "continue"; } } var enableAppRender = this_1.maxOrIndicator || (overlapIndex < eventsPerRow) || (this_1.cellHeight > availedHeight); if (this_1.parent.rowAutoHeight || enableAppRender || this_1.cellHeight > availedHeight) { this_1.renderEvent(eventWrapper, eventData, row, leftValue, rightValue, monthStart, dayIndex); Eif (this_1.parent.rowAutoHeight || this_1.cellHeight > availedHeight) { this_1.updateCellHeight(rowTd, availedHeight); } isSpannedCollection.push(eventData); } else { var moreIndex = this_1.parent.activeViewOptions.orientation === 'Horizontal' ? row : dayIndex; this_1.renderMoreIndicator(eventWrapper, moreIndicatorCount, dayStart, moreIndex, leftValue, rightValue, groupIndex); if (this_1.parent.activeViewOptions.orientation === 'Horizontal') { eventData.MoreIndicator = true; this_1.renderedEvents.push(eventData); isSpannedCollection.push(eventData); } } }; var this_1 = this; for (var index = 0, count = dayEvents.length; index < count; index++) { _loop_1(index, count); } monthStart = util.addDays(new Date(monthStart.getTime()), 1); if (this.parent.activeViewOptions.orientation === 'Vertical') { dayIndex++; this.renderedEvents = []; } } } if (this.parent.rowAutoHeight && this.parent.activeViewOptions.orientation === 'Vertical') { var appContainer = [].slice.call(this.parent.element.querySelectorAll('.' + cls.APPOINTMENT_CONTAINER_CLASS)); var tr_1 = [].slice.call(this.parent.element.querySelectorAll('.' + cls.CONTENT_TABLE_CLASS + ' tbody tr')); appContainer.forEach(function (ele, index) { var app = [].slice.call(ele.querySelectorAll('.' + cls.APPOINTMENT_CLASS)); var appTop = tr_1[parseInt(index.toString(), 10)].offsetTop + _this.cellHeader + EVENT_GAP; app.forEach(function (app) { var overlap = parseInt(app.getAttribute('data-index'), 10); app.style.top = appTop + (overlap * _this.eventHeight) + 'px'; app.removeAttribute('data-index'); }); }); } }; YearEvent.prototype.updateSpannedEvents = function (eventObj, dayStart, dayEnd) { var isLeftRightResize = (this.isResource && this.parent.activeViewOptions.orientation === 'Vertical') || (!this.isResource && this.parent.activeViewOptions.orientation === 'Horizontal'); var data = { isLeft: true, isRight: true, isBottom: true, isTop: true }; if (dayStart.getTime() <= eventObj[this.fields.startTime].getTime()) { if (isLeftRightResize) { data.isLeft = false; } else { data.isTop = false; } } if ((dayEnd.getTime() >= eventObj[this.fields.endTime].getTime()) || (isLeftRightResize && !this.isResource && util.addDays(dayEnd, -1).getMonth() === eventObj[this.fields.endTime].getMonth()) || (isLeftRightResize && this.isResource && (dayEnd.getTime() <= eventObj[this.fields.endTime].getTime()))) { if (isLeftRightResize) { data.isRight = false; } else { data.isBottom = false; } } eventObj.data = data; }; YearEvent.prototype.timelineResourceEvents = function () { var _this = this; var contentTable = this.parent.element.querySelector('.' + cls.CONTENT_WRAP_CLASS); var isVerticalScrollbarAvail = contentTable.offsetWidth > contentTable.clientWidth; var workCell = this.parent.element.querySelector('.' + cls.WORK_CELLS_CLASS); this.cellWidth = this.parent.getElementWidth(workCell); this.cellHeader = 0; var eventTable = this.parent.element.querySelector('.' + cls.EVENT_TABLE_CLASS); this.eventHeight = this.parent.getElementHeightFromClass(eventTable, cls.APPOINTMENT_CLASS); var selector = "." + cls.MONTH_HEADER_WRAPPER + " tbody tr,." + cls.RESOURCE_COLUMN_TABLE_CLASS + " tbody tr,." + cls.CONTENT_TABLE_CLASS + " tbody tr"; this.addCellHeight(selector, this.eventHeight, EVENT_GAP, this.cellHeader, this.moreIndicatorHeight); var wrapperCollection = [].slice.call(this.parent.element.querySelectorAll('.' + cls.APPOINTMENT_CONTAINER_CLASS)); var resources = this.parent.uiStateValues.isGroupAdaptive ? [this.parent.resourceBase.lastResourceLevel[this.parent.uiStateValues.groupIndex]] : this.parent.activeViewOptions.allowVirtualScrolling ? this.parent.resourceBase.renderedResources : this.parent.resourceBase.lastResourceLevel; var months = this.getMonths(); if (this.parent.activeViewOptions.orientation === 'Horizontal') { for (var month = 0; month < months.length; month++) { var monthStart = new Date(this.parent.selectedDate.getFullYear(), months[parseInt(month.toString(), 10)], 1); for (var i = 0, len = resources.length; i < len; i++) { this.renderedEvents = []; this.renderResourceEvent(wrapperCollection[parseInt(month.toString(), 10)], resources[parseInt(i.toString(), 10)], month, i, monthStart); } } } else { for (var i = 0, len = resources.length; i < len; i++) { this.renderedEvents = []; for (var month = 0; month < months.length; month++) { var monthStart = new Date(this.parent.selectedDate.getFullYear(), months[parseInt(month.toString(), 10)], 1); this.renderResourceEvent(wrapperCollection[parseInt(i.toString(), 10)], resources[parseInt(i.toString(), 10)], month, i, monthStart); } } } if (this.parent.rowAutoHeight && !isVerticalScrollbarAvail && contentTable.offsetWidth > contentTable.clientWidth) { var appointments = [].slice.call(this.parent.element.querySelectorAll('.' + cls.APPOINTMENT_CLASS)); appointments.forEach(function (ele) { ele.style.removeProperty('left'); ele.style.removeProperty('right'); }); var appContainer = [].slice.call(this.parent.element.querySelectorAll('.' + cls.APPOINTMENT_CONTAINER_CLASS)); var conTable_1 = this.parent.element.querySelector('.' + cls.CONTENT_TABLE_CLASS); var tr_2 = [].slice.call(conTable_1.querySelectorAll('tbody tr')); appContainer.forEach(function (ele, index) { var appWrapper = [].slice.call(ele.children); var row = tr_2[parseInt(index.toString(), 10)]; appWrapper.forEach(function (appWrap, cellIndex) { var td = row.querySelector("td:nth-child(" + (cellIndex + 1) + ")"); var app = [].slice.call(appWrap.children); var width = _this.parent.getElementWidth(td); var left = td.offsetLeft; Iif (_this.parent.enableRtl) { var right_1 = conTable_1.offsetWidth - left - td.offsetWidth; app.forEach(function (app) { app.style.width = Math.floor(parseInt(app.style.width, 10) / width) * width + 'px'; app.style.right = right_1 + 'px'; }); } else { app.forEach(function (app) { app.style.width = Math.floor(parseInt(app.style.width, 10) / width) * width + 'px'; app.style.left = left + 'px'; }); } }); }); } }; YearEvent.prototype.renderResourceEvent = function (wrapper, resource, month, index, monthStart) { var eventWrapper = ej2_base_1.createElement('div', { className: cls.APPOINTMENT_WRAPPER_CLASS }); wrapper.appendChild(eventWrapper); var monthEnd = util.addDays(util.lastDateOfMonth(new Date(monthStart.getTime())), 1); var eventDatas = this.parent.eventBase.filterEvents(monthStart, monthEnd, undefined, resource); var rowIndex = this.parent.activeViewOptions.orientation === 'Vertical' ? index : month; var td = this.parent.element.querySelector(".e-content-wrap tr:nth-child(" + (rowIndex + 1) + ") td"); this.cellHeight = td.offsetHeight; this.groupOrder = resource.groupOrder; var isSpannedCollection = []; var _loop_2 = function (a) { var data = eventDatas[parseInt(a.toString(), 10)]; var overlapIndex = void 0; var eventData = ej2_base_1.extend({}, data, null, true); Eif (this_2.parent.activeViewOptions.group.resources.length > 0) { var eventObj = this_2.isSpannedEvent(eventData, monthStart); overlapIndex = this_2.getIndex(eventObj[this_2.fields.startTime]); eventData.Index = overlapIndex; } else { overlapIndex = this_2.getIndex(eventData[this_2.fields.startTime]); eventData.Index = overlapIndex; } var availedHeight = this_2.cellHeader + (this_2.eventHeight * (a + 1)) + EVENT_GAP + this_2.moreIndicatorHeight; var leftValue = (this_2.parent.activeViewOptions.orientation === 'Vertical') ? month * this_2.cellWidth : index * this_2.cellWidth; if (!this_2.parent.isMinMaxDate(eventData[this_2.fields.startTime])) { return { value: void 0 }; } if (this_2.parent.activeViewOptions.orientation === 'Vertical' && this_2.parent.activeViewOptions.group.resources.length > 0) { var isRendered = this_2.renderedEvents.filter(function (eventObj) { return eventObj.Guid === eventData.Guid; }); var isSpanned = isSpannedCollection.filter(function (eventObj) { return eventObj.Guid === eventData.Guid; }); if (isRendered.length > 0 || isSpanned.length > 0) { return "continue"; } } if (this_2.parent.rowAutoHeight || this_2.cellHeight > availedHeight) { this_2.renderEvent(eventWrapper, eventData, month, leftValue, leftValue, monthStart, index); this_2.updateCellHeight(td, availedHeight); isSpannedCollection.push(eventData); } else { var moreIndex = this_2.parent.activeViewOptions.orientation === 'Horizontal' ? month : index; this_2.renderMoreIndicator(eventWrapper, eventDatas.length - a, monthStart, moreIndex, leftValue, leftValue, index); if (this_2.parent.activeViewOptions.orientation === 'Horizontal') { for (var i = index; i < eventDatas.length; i++) { this_2.renderedEvents.push(ej2_base_1.extend({}, eventDatas[parseInt(i.toString(), 10)], { Index: overlapIndex + i }, true)); } } return "break"; } }; var this_2 = this; for (var a = 0; a < eventDatas.length; a++) { var state_1 = _loop_2(a); if (typeof state_1 === "object") return state_1.value; if (state_1 === "break") break; } }; YearEvent.prototype.renderEvent = function (wrapper, eventData, row, left, right, monthDate, rowIndex) { var _this = this; var eventObj = this.isSpannedEvent(eventData, monthDate); var wrap = this.createEventElement(eventObj); var width; var index; if (eventObj.isSpanned.count === 1) { var endTime = util.addDays(eventObj[this.fields.endTime], -1); eventObj[this.fields.endTime] = (endTime > eventObj[this.fields.startTime]) ? endTime : eventObj[this.fields.endTime]; } if (eventObj[this.fields.startTime] > eventObj[this.fields.endTime]) { return; } if (this.parent.activeViewOptions.orientation === 'Horizontal') { index = row + 1; if (eventObj[this.fields.startTime].getTime() === eventObj[this.fields.endTime].getTime()) { eventObj.isSpanned.count = 1; } width = eventObj.isSpanned.count * this.cellWidth; } else { index = rowIndex + 1; width = this.isResource ? eventObj.isSpanned.count * this.cellWidth : this.cellWidth; } var rowTd = this.parent.element.querySelector(".e-content-wrap tr:nth-child(" + index + ") td"); var top = rowTd.offsetTop + this.cellHeader + (this.eventHeight * eventObj.Index) + EVENT_GAP; ej2_base_2.setStyleAttribute(wrap, { 'width': width + 'px', 'height': this.eventHeight + 'px', 'left': left + 'px', 'right': right + 'px', 'top': top + 'px' }); if (!this.isResource && this.parent.rowAutoHeight && this.parent.activeViewOptions.orientation === 'Vertical') { wrap.setAttribute('data-index', eventObj.Index.toString()); } var args = { data: eventObj, element: wrap, cancel: false, type: 'event' }; this.parent.trigger(events.eventRendered, args, function (eventArgs) { Eif (!eventArgs.cancel) { wrapper.appendChild(wrap); _this.wireAppointmentEvents(wrap, eventObj); if (_this.parent.activeViewOptions.group.resources.length > 0) { _this.renderedEvents.push(ej2_base_1.extend({}, eventObj, null, true)); } else if (_this.parent.activeViewOptions.orientation === 'Vertical') { _this.renderedEvents.push(ej2_base_1.extend({}, eventObj, null, true)); } else Eif ((eventObj.isSpanned.isRight || eventObj.isSpanned.isLeft) && _this.parent.activeViewOptions.orientation === 'Horizontal' || !eventObj.isSpanned.isRight) { _this.renderedEvents.push(ej2_base_1.extend({}, eventObj, null, true)); } } }); }; YearEvent.prototype.renderMoreIndicator = function (wrapper, count, startDate, row, left, right, index) { if (this.parent.activeViewOptions.group.resources.length === 0 && wrapper.querySelector('[data-start-date="' + startDate.getTime() + '"]')) { return; } var endDate; if (this.parent.activeViewOptions.group.resources.length > 0 && !this.parent.uiStateValues.isGroupAdaptive) { endDate = util.addDays(util.lastDateOfMonth(new Date(startDate.getTime())), 1); } else { endDate = util.addDays(new Date(startDate.getTime()), 1); } var moreIndicator = this.getMoreIndicatorElement(count, startDate, endDate); var rowTr = this.parent.element.querySelector(".e-content-wrap tr:nth-child(" + (row + 1) + ")"); var top = rowTr.offsetTop + (this.cellHeight - this.moreIndicatorHeight); left = (Math.floor(left / this.cellWidth) * this.cellWidth); right = (Math.floor(right / this.cellWidth) * this.cellWidth); ej2_base_2.setStyleAttribute(moreIndicator, { 'width': this.cellWidth + 'px', 'left': left + 'px', 'right': right + 'px', 'top': top + 'px' }); if (!ej2_base_1.isNullOrUndefined(index)) { moreIndicator.setAttribute('data-group-index', index.toString()); } wrapper.appendChild(moreIndicator); ej2_base_2.EventHandler.add(moreIndicator, 'click', this.moreIndicatorClick, this); }; YearEvent.prototype.createEventElement = function (record) { var eventSubject = (record[this.fields.subject] || this.parent.eventSettings.fields.subject.default || this.parent.localeObj.getConstant('addTitle')); var eventWrapper = ej2_base_1.createElement('div', { className: cls.APPOINTMENT_CLASS, attrs: { 'data-id': 'Appointment_' + record[this.fields.id], 'data-guid': record.Guid, 'role': 'button', 'tabindex': '0', 'aria-disabled': this.parent.eventBase.getReadonlyAttribute(record), 'aria-label': this.parent.getAnnouncementString(record) } }); Iif (this.cssClass) { ej2_base_1.addClass([eventWrapper], this.cssClass); } Iif (record[this.fields.isReadonly]) { ej2_base_1.addClass([eventWrapper], cls.READ_ONLY); } if (this.parent.activeViewOptions.group.resources.length > 0) { var resIndex = this.getGroupIndexFromEvent(record); eventWrapper.setAttribute('data-group-index', resIndex.toString()); } var templateElement = []; var eventObj = ej2_base_1.extend({}, record, null, true); Iif (this.parent.activeViewOptions.eventTemplate) { var templateId = this.parent.element.id + '_' + this.parent.activeViewOptions.eventTemplateName + 'eventTemplate'; templateElement = this.parent.getAppointmentTemplate()(eventObj, this.parent, 'eventTemplate', templateId, false, undefined, undefined, this.parent.root); } else { var locationEle = (record[this.fields.location] || this.parent.eventSettings.fields.location.default || ''); var subjectEle = ej2_base_1.createElement('div', { className: cls.SUBJECT_CLASS, innerHTML: (eventSubject + (locationEle ? '; ' + locationEle : '')) }); var startTimeEle = ej2_base_1.createElement('div', { className: cls.APPOINTMENT_TIME + (this.parent.isAdaptive ? ' ' + cls.DISABLE_CLASS : ''), innerHTML: this.parent.getTimeString(eventObj[this.fields.startTime]) }); var endTimeEle = ej2_base_1.createElement('div', { className: cls.APPOINTMENT_TIME + (this.parent.isAdaptive ? ' ' + cls.DISABLE_CLASS : ''), innerHTML: this.parent.getTimeString(eventObj[this.fields.endTime]) }); ej2_base_1.addClass([subjectEle], 'e-text-center'); if (record[this.fields.isAllDay]) { templateElement = [subjectEle]; } else Eif (!eventObj.isLeft && !eventObj.isRight) { templateElement = [startTimeEle, subjectEle, endTimeEle]; } else { if (!eventObj.isLeft) { templateElement.push(startTimeEle); } templateElement.push(subjectEle); if (!eventObj.isRight) { templateElement.push(endTimeEle); } } } var appointmentDetails = ej2_base_1.createElement('div', { className: cls.APPOINTMENT_DETAILS }); ej2_base_1.append(templateElement, appointmentDetails); eventWrapper.appendChild(appointmentDetails); this.parent.eventBase.renderSpannedIcon(eventWrapper, record.isSpanned); this.renderResizeHandler(eventWrapper, record.data, record[this.fields.isReadonly]); this.applyResourceColor(eventWrapper, eventObj, 'backgroundColor', this.groupOrder); return eventWrapper; }; YearEvent.prototype.isSpannedEvent = function (eventObj, monthDate) { var monthStart = new Date(monthDate.getFullYear(), monthDate.getMonth(), 1); var monthEnd = util.addDays(new Date(monthDate.getFullYear(), monthDate.getMonth() + 1, 0), 1); var eventData = ej2_base_1.extend({}, eventObj, null, true); var eventStart = eventData[this.fields.startTime]; var eventEnd = eventData[this.fields.endTime]; var isSpanned = { isLeft: false, isRight: false, count: 1 }; var yearStart = new Date(this.parent.selectedDate.getFullYear(), this.parent.firstMonthOfYear, 1); var yearEnd = util.addMonths(yearStart, this.parent.monthsCount); if (this.isResource) { this.updateSpannedEvents(eventObj, monthStart, monthEnd); } if (this.parent.activeViewOptions.orientation === 'Vertical' && this.parent.activeViewOptions.group.resources.length > 0) { this.updateSpannedEventDetails(eventStart, eventEnd, yearStart, yearEnd, eventData, isSpanned); var originalStartTime = eventData[this.fields.startTime]; var originalEndTime = new Date(eventData[this.fields.endTime] - 1); isSpanned.count = (originalEndTime.getMonth() - originalStartTime.getMonth()) + (this.parent.monthsCount * (originalEndTime.getFullYear() - originalStartTime.getFullYear())) + 1; } else { this.updateSpannedEventDetails(eventStart, eventEnd, monthStart, monthEnd, eventData, isSpanned); if (this.parent.activeViewOptions.group.resources.length === 0 || this.parent.uiStateValues.isGroupAdaptive) { var end = util.resetTime(eventData[this.fields.endTime]).getTime(); var start = util.resetTime(eventData[this.fields.startTime]).getTime(); if (eventObj[this.fields.isAllDay] && end === eventObj[this.fields.endTime].getTime() || isSpanned.isRight) { end = util.addDays(new Date(end), -1).getTime(); } isSpanned.count = Math.round((end - start) / util.MS_PER_DAY) + 1; } } eventData.isSpanned = isSpanned; if (util.resetTime(eventStart).getTime() < util.resetTime(this.parent.minDate).getTime()) { eventData[this.fields.startTime] = this.parent.minDate; } Iif (util.resetTime(eventEnd).getTime() > util.resetTime(this.parent.maxDate).getTime()) { eventData[this.fields.endTime] = this.parent.maxDate; } return eventData; }; YearEvent.prototype.updateSpannedEventDetails = function (eventStart, eventEnd, viewStart, viewEnd, eventObj, isSpanned) { if (eventStart.getTime() < viewStart.getTime()) { eventObj[this.fields.startTime] = viewStart; isSpanned.isLeft = true; } if (eventEnd.getTime() > viewEnd.getTime()) { eventObj[this.fields.endTime] = viewEnd; isSpanned.isRight = true; } }; YearEvent.prototype.getOverlapEvents = function (date, appointments) { var appointmentsList = []; var dateStart; var dateEnd; if (this.parent.activeViewOptions.group.resources.length > 0 && !this.parent.uiStateValues.isGroupAdaptive) { var monthStart = this.parent.calendarUtil.getMonthStartDate(new Date(date.getTime())); var monthEnd = util.addDays(this.parent.calendarUtil.getMonthEndDate(new Date(date.getTime())), -1); dateStart = util.resetTime(new Date(monthStart.getTime())).getTime(); dateEnd = util.resetTime(new Date(monthEnd.getTime())).getTime(); } else { if (this.parent.rowAutoHeight) { dateStart = util.resetTime(new Date(date.getTime())).getTime(); dateEnd = util.addDays(util.resetTime(new Date(date.getTime())), 1).getTime(); } else { dateStart = dateEnd = util.resetTime(new Date(date.getTime())).getTime(); } } for (var _i = 0, appointments_1 = appointments; _i < appointments_1.length; _i++) { var app = appointments_1[_i]; var appStart = new Date(app[this.fields.startTime].getTime()); var appEnd = new Date(app[this.fields.endTime].getTime()); var timeCondition = app[this.fields.isAllDay] ? util.resetTime(appEnd).getTime() > dateStart : util.resetTime(appEnd).getTime() >= dateStart; if (((util.resetTime(appStart).getTime() <= dateStart) && (timeCondition)) || (util.resetTime(appStart).getTime() >= dateStart) && (util.resetTime(appEnd).getTime() <= dateEnd)) { appointmentsList.push(app); } else if (this.parent.activeViewOptions.orientation === 'Vertical') { if (util.resetTime(appStart).getTime() >= dateStart && util.resetTime(appEnd).getTime() >= dateEnd) { appointmentsList.push(app); } } } return appointmentsList; }; YearEvent.prototype.getMonths = function () { var _this = this; return Array.apply(null, { length: this.parent.monthsCount }).map(function (value, index) { return _this.parent.firstMonthOfYear + index; }); }; YearEvent.prototype.removeCellHeight = function () { var elementSelector = "." + cls.MONTH_HEADER_WRAPPER + " tbody tr,." + cls.RESOURCE_COLUMN_TABLE_CLASS + " tbody tr,." + cls.CONTENT_TABLE_CLASS + " tbody tr"; var rows = [].slice.call(this.element.querySelectorAll(elementSelector)); for (var _i = 0, rows_1 = rows; _i < rows_1.length; _i++) { var row = rows_1[_i]; row.firstElementChild.style.height = ''; } }; YearEvent.prototype.destroy = function () { _super.prototype.destroy.call(this); this.parent = null; }; return YearEvent; }(timeline_view_1.TimelineEvent)); exports.YearEvent = YearEvent; }); |