schedule.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. "use strict";
  2. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  3. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  4. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  5. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  6. return c > 3 && r && Object.defineProperty(target, key, r), r;
  7. };
  8. var __metadata = (this && this.__metadata) || function (k, v) {
  9. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  10. };
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. var core_1 = require("@angular/core");
  13. var common_1 = require("@angular/common");
  14. var Schedule = /** @class */ (function () {
  15. function Schedule(el, differs) {
  16. this.el = el;
  17. this.aspectRatio = 1.35;
  18. this.defaultView = 'month';
  19. this.allDaySlot = true;
  20. this.allDayText = 'all-day';
  21. this.slotDuration = '00:30:00';
  22. this.scrollTime = '06:00:00';
  23. this.minTime = '00:00:00';
  24. this.maxTime = '24:00:00';
  25. this.slotEventOverlap = true;
  26. this.dragRevertDuration = 500;
  27. this.dragOpacity = .75;
  28. this.dragScroll = true;
  29. this.timezone = false;
  30. this.timeFormat = null;
  31. this.onDayClick = new core_1.EventEmitter();
  32. this.onDrop = new core_1.EventEmitter();
  33. this.onEventClick = new core_1.EventEmitter();
  34. this.onEventMouseover = new core_1.EventEmitter();
  35. this.onEventMouseout = new core_1.EventEmitter();
  36. this.onEventDragStart = new core_1.EventEmitter();
  37. this.onEventDragStop = new core_1.EventEmitter();
  38. this.onEventDrop = new core_1.EventEmitter();
  39. this.onEventResizeStart = new core_1.EventEmitter();
  40. this.onEventResizeStop = new core_1.EventEmitter();
  41. this.onEventResize = new core_1.EventEmitter();
  42. this.onViewRender = new core_1.EventEmitter();
  43. this.onViewDestroy = new core_1.EventEmitter();
  44. this.onNavLinkDayClick = new core_1.EventEmitter();
  45. this.onNavLinkWeekClick = new core_1.EventEmitter();
  46. this.differ = differs.find([]).create(null);
  47. this.initialized = false;
  48. }
  49. Schedule.prototype.ngOnInit = function () {
  50. var _this = this;
  51. this.config = {
  52. theme: true,
  53. header: this.header,
  54. isRTL: this.rtl,
  55. weekends: this.weekends,
  56. hiddenDays: this.hiddenDays,
  57. fixedWeekCount: this.fixedWeekCount,
  58. weekNumbers: this.weekNumbers,
  59. businessHours: this.businessHours,
  60. height: this.height,
  61. contentHeight: this.contentHeight,
  62. aspectRatio: this.aspectRatio,
  63. eventLimit: this.eventLimit,
  64. defaultDate: this.defaultDate,
  65. locale: this.locale,
  66. timezone: this.timezone,
  67. timeFormat: this.timeFormat,
  68. editable: this.editable,
  69. droppable: this.droppable,
  70. eventStartEditable: this.eventStartEditable,
  71. eventDurationEditable: this.eventDurationEditable,
  72. defaultView: this.defaultView,
  73. allDaySlot: this.allDaySlot,
  74. allDayText: this.allDayText,
  75. slotDuration: this.slotDuration,
  76. slotLabelInterval: this.slotLabelInterval,
  77. snapDuration: this.snapDuration,
  78. scrollTime: this.scrollTime,
  79. minTime: this.minTime,
  80. maxTime: this.maxTime,
  81. slotEventOverlap: this.slotEventOverlap,
  82. nowIndicator: this.nowIndicator,
  83. dragRevertDuration: this.dragRevertDuration,
  84. dragOpacity: this.dragOpacity,
  85. dragScroll: this.dragScroll,
  86. eventOverlap: this.eventOverlap,
  87. eventConstraint: this.eventConstraint,
  88. eventRender: this.eventRender,
  89. dayRender: this.dayRender,
  90. navLinks: this.navLinks,
  91. dayClick: function (date, jsEvent, view) {
  92. _this.onDayClick.emit({
  93. 'date': date,
  94. 'jsEvent': jsEvent,
  95. 'view': view
  96. });
  97. },
  98. drop: function (date, jsEvent, ui, resourceId) {
  99. _this.onDrop.emit({
  100. 'date': date,
  101. 'jsEvent': jsEvent,
  102. 'ui': ui,
  103. 'resourceId': resourceId
  104. });
  105. },
  106. eventClick: function (calEvent, jsEvent, view) {
  107. _this.onEventClick.emit({
  108. 'calEvent': calEvent,
  109. 'jsEvent': jsEvent,
  110. 'view': view
  111. });
  112. },
  113. eventMouseover: function (calEvent, jsEvent, view) {
  114. _this.onEventMouseover.emit({
  115. 'calEvent': calEvent,
  116. 'jsEvent': jsEvent,
  117. 'view': view
  118. });
  119. },
  120. eventMouseout: function (calEvent, jsEvent, view) {
  121. _this.onEventMouseout.emit({
  122. 'calEvent': calEvent,
  123. 'jsEvent': jsEvent,
  124. 'view': view
  125. });
  126. },
  127. eventDragStart: function (event, jsEvent, ui, view) {
  128. _this.onEventDragStart.emit({
  129. 'event': event,
  130. 'jsEvent': jsEvent,
  131. 'view': view
  132. });
  133. },
  134. eventDragStop: function (event, jsEvent, ui, view) {
  135. _this.onEventDragStop.emit({
  136. 'event': event,
  137. 'jsEvent': jsEvent,
  138. 'view': view
  139. });
  140. },
  141. eventDrop: function (event, delta, revertFunc, jsEvent, ui, view) {
  142. _this._updateEvent(event);
  143. _this.onEventDrop.emit({
  144. 'event': event,
  145. 'delta': delta,
  146. 'revertFunc': revertFunc,
  147. 'jsEvent': jsEvent,
  148. 'view': view
  149. });
  150. },
  151. eventResizeStart: function (event, jsEvent, ui, view) {
  152. _this.onEventResizeStart.emit({
  153. 'event': event,
  154. 'jsEvent': jsEvent,
  155. 'view': view
  156. });
  157. },
  158. eventResizeStop: function (event, jsEvent, ui, view) {
  159. _this.onEventResizeStop.emit({
  160. 'event': event,
  161. 'jsEvent': jsEvent,
  162. 'view': view
  163. });
  164. },
  165. eventResize: function (event, delta, revertFunc, jsEvent, ui, view) {
  166. _this._updateEvent(event);
  167. _this.onEventResize.emit({
  168. 'event': event,
  169. 'delta': delta,
  170. 'revertFunc': revertFunc,
  171. 'jsEvent': jsEvent,
  172. 'view': view
  173. });
  174. },
  175. viewRender: function (view, element) {
  176. _this.onViewRender.emit({
  177. 'view': view,
  178. 'element': element
  179. });
  180. },
  181. viewDestroy: function (view, element) {
  182. _this.onViewDestroy.emit({
  183. 'view': view,
  184. 'element': element
  185. });
  186. },
  187. navLinkDayClick: function (weekStart, jsEvent) {
  188. _this.onNavLinkDayClick.emit({
  189. 'weekStart': weekStart,
  190. 'event': jsEvent
  191. });
  192. },
  193. navLinkWeekClick: function (weekStart, jsEvent) {
  194. _this.onNavLinkWeekClick.emit({
  195. 'weekStart': weekStart,
  196. 'event': jsEvent
  197. });
  198. }
  199. };
  200. if (this.options) {
  201. for (var prop in this.options) {
  202. this.config[prop] = this.options[prop];
  203. }
  204. }
  205. };
  206. Schedule.prototype.ngAfterViewChecked = function () {
  207. if (!this.initialized && this.el.nativeElement.offsetParent) {
  208. this.initialize();
  209. }
  210. };
  211. Schedule.prototype.ngOnChanges = function (changes) {
  212. if (this.calendar) {
  213. for (var propName in changes) {
  214. if (propName !== 'options' && propName !== 'events') {
  215. this.calendar.option(propName, changes[propName].currentValue);
  216. }
  217. }
  218. }
  219. };
  220. Object.defineProperty(Schedule.prototype, "options", {
  221. get: function () {
  222. return this._options;
  223. },
  224. set: function (value) {
  225. this._options = value;
  226. if (this._options && this.calendar) {
  227. for (var prop in this._options) {
  228. var optionValue = this._options[prop];
  229. this.config[prop] = optionValue;
  230. this.calendar.option(prop, optionValue);
  231. }
  232. }
  233. },
  234. enumerable: true,
  235. configurable: true
  236. });
  237. Schedule.prototype.initialize = function () {
  238. this.calendar = new FullCalendar.Calendar(this.el.nativeElement.children[0], this.config);
  239. this.calendar.render();
  240. this.initialized = true;
  241. if (this.events) {
  242. this.calendar.addEventSource(this.events);
  243. }
  244. };
  245. Schedule.prototype.ngDoCheck = function () {
  246. var changes = this.differ.diff(this.events);
  247. if (this.calendar && changes) {
  248. this.calendar.removeEventSources();
  249. if (this.events) {
  250. this.calendar.addEventSource(this.events);
  251. }
  252. }
  253. };
  254. Schedule.prototype.ngOnDestroy = function () {
  255. if (this.calendar) {
  256. this.calendar.destroy;
  257. this.initialized = false;
  258. this.calendar = null;
  259. }
  260. };
  261. Schedule.prototype.gotoDate = function (date) {
  262. this.calendar.gotoDate(date);
  263. };
  264. Schedule.prototype.prev = function () {
  265. this.calendar.prev();
  266. };
  267. Schedule.prototype.next = function () {
  268. this.calendar.next();
  269. };
  270. Schedule.prototype.prevYear = function () {
  271. this.calendar.prevYear();
  272. };
  273. Schedule.prototype.nextYear = function () {
  274. this.calendar.nextYear();
  275. };
  276. Schedule.prototype.today = function () {
  277. this.calendar.today();
  278. };
  279. Schedule.prototype.incrementDate = function (duration) {
  280. this.calendar.incrementDate(duration);
  281. };
  282. Schedule.prototype.changeView = function (viewName, dateOrRange) {
  283. this.calendar.changeView(viewName, dateOrRange);
  284. };
  285. Schedule.prototype.getDate = function () {
  286. return this.calendar.getDate();
  287. };
  288. Schedule.prototype.updateEvent = function (event) {
  289. this.calendar.updateEvent(event);
  290. };
  291. Schedule.prototype._findEvent = function (id) {
  292. var event;
  293. if (this.events) {
  294. for (var _i = 0, _a = this.events; _i < _a.length; _i++) {
  295. var e = _a[_i];
  296. if (e.id === id) {
  297. event = e;
  298. break;
  299. }
  300. }
  301. }
  302. return event;
  303. };
  304. Schedule.prototype._updateEvent = function (event) {
  305. var sourceEvent = this._findEvent(event.id);
  306. if (sourceEvent) {
  307. sourceEvent.start = event.start.format();
  308. if (event.end) {
  309. sourceEvent.end = event.end.format();
  310. }
  311. }
  312. };
  313. __decorate([
  314. core_1.Input(),
  315. __metadata("design:type", Array)
  316. ], Schedule.prototype, "events", void 0);
  317. __decorate([
  318. core_1.Input(),
  319. __metadata("design:type", Object)
  320. ], Schedule.prototype, "header", void 0);
  321. __decorate([
  322. core_1.Input(),
  323. __metadata("design:type", Object)
  324. ], Schedule.prototype, "style", void 0);
  325. __decorate([
  326. core_1.Input(),
  327. __metadata("design:type", String)
  328. ], Schedule.prototype, "styleClass", void 0);
  329. __decorate([
  330. core_1.Input(),
  331. __metadata("design:type", Boolean)
  332. ], Schedule.prototype, "rtl", void 0);
  333. __decorate([
  334. core_1.Input(),
  335. __metadata("design:type", Boolean)
  336. ], Schedule.prototype, "weekends", void 0);
  337. __decorate([
  338. core_1.Input(),
  339. __metadata("design:type", Array)
  340. ], Schedule.prototype, "hiddenDays", void 0);
  341. __decorate([
  342. core_1.Input(),
  343. __metadata("design:type", Boolean)
  344. ], Schedule.prototype, "fixedWeekCount", void 0);
  345. __decorate([
  346. core_1.Input(),
  347. __metadata("design:type", Boolean)
  348. ], Schedule.prototype, "weekNumbers", void 0);
  349. __decorate([
  350. core_1.Input(),
  351. __metadata("design:type", Object)
  352. ], Schedule.prototype, "businessHours", void 0);
  353. __decorate([
  354. core_1.Input(),
  355. __metadata("design:type", Object)
  356. ], Schedule.prototype, "height", void 0);
  357. __decorate([
  358. core_1.Input(),
  359. __metadata("design:type", Object)
  360. ], Schedule.prototype, "contentHeight", void 0);
  361. __decorate([
  362. core_1.Input(),
  363. __metadata("design:type", Number)
  364. ], Schedule.prototype, "aspectRatio", void 0);
  365. __decorate([
  366. core_1.Input(),
  367. __metadata("design:type", Object)
  368. ], Schedule.prototype, "eventLimit", void 0);
  369. __decorate([
  370. core_1.Input(),
  371. __metadata("design:type", Object)
  372. ], Schedule.prototype, "defaultDate", void 0);
  373. __decorate([
  374. core_1.Input(),
  375. __metadata("design:type", Boolean)
  376. ], Schedule.prototype, "editable", void 0);
  377. __decorate([
  378. core_1.Input(),
  379. __metadata("design:type", Boolean)
  380. ], Schedule.prototype, "droppable", void 0);
  381. __decorate([
  382. core_1.Input(),
  383. __metadata("design:type", Boolean)
  384. ], Schedule.prototype, "eventStartEditable", void 0);
  385. __decorate([
  386. core_1.Input(),
  387. __metadata("design:type", Boolean)
  388. ], Schedule.prototype, "eventDurationEditable", void 0);
  389. __decorate([
  390. core_1.Input(),
  391. __metadata("design:type", String)
  392. ], Schedule.prototype, "defaultView", void 0);
  393. __decorate([
  394. core_1.Input(),
  395. __metadata("design:type", Boolean)
  396. ], Schedule.prototype, "allDaySlot", void 0);
  397. __decorate([
  398. core_1.Input(),
  399. __metadata("design:type", String)
  400. ], Schedule.prototype, "allDayText", void 0);
  401. __decorate([
  402. core_1.Input(),
  403. __metadata("design:type", Object)
  404. ], Schedule.prototype, "slotDuration", void 0);
  405. __decorate([
  406. core_1.Input(),
  407. __metadata("design:type", Object)
  408. ], Schedule.prototype, "slotLabelInterval", void 0);
  409. __decorate([
  410. core_1.Input(),
  411. __metadata("design:type", Object)
  412. ], Schedule.prototype, "snapDuration", void 0);
  413. __decorate([
  414. core_1.Input(),
  415. __metadata("design:type", Object)
  416. ], Schedule.prototype, "scrollTime", void 0);
  417. __decorate([
  418. core_1.Input(),
  419. __metadata("design:type", Object)
  420. ], Schedule.prototype, "minTime", void 0);
  421. __decorate([
  422. core_1.Input(),
  423. __metadata("design:type", Object)
  424. ], Schedule.prototype, "maxTime", void 0);
  425. __decorate([
  426. core_1.Input(),
  427. __metadata("design:type", Boolean)
  428. ], Schedule.prototype, "slotEventOverlap", void 0);
  429. __decorate([
  430. core_1.Input(),
  431. __metadata("design:type", Boolean)
  432. ], Schedule.prototype, "nowIndicator", void 0);
  433. __decorate([
  434. core_1.Input(),
  435. __metadata("design:type", Number)
  436. ], Schedule.prototype, "dragRevertDuration", void 0);
  437. __decorate([
  438. core_1.Input(),
  439. __metadata("design:type", Number)
  440. ], Schedule.prototype, "dragOpacity", void 0);
  441. __decorate([
  442. core_1.Input(),
  443. __metadata("design:type", Boolean)
  444. ], Schedule.prototype, "dragScroll", void 0);
  445. __decorate([
  446. core_1.Input(),
  447. __metadata("design:type", Object)
  448. ], Schedule.prototype, "eventOverlap", void 0);
  449. __decorate([
  450. core_1.Input(),
  451. __metadata("design:type", Object)
  452. ], Schedule.prototype, "eventConstraint", void 0);
  453. __decorate([
  454. core_1.Input(),
  455. __metadata("design:type", String)
  456. ], Schedule.prototype, "locale", void 0);
  457. __decorate([
  458. core_1.Input(),
  459. __metadata("design:type", Object)
  460. ], Schedule.prototype, "timezone", void 0);
  461. __decorate([
  462. core_1.Input(),
  463. __metadata("design:type", String)
  464. ], Schedule.prototype, "timeFormat", void 0);
  465. __decorate([
  466. core_1.Input(),
  467. __metadata("design:type", Function)
  468. ], Schedule.prototype, "eventRender", void 0);
  469. __decorate([
  470. core_1.Input(),
  471. __metadata("design:type", Function)
  472. ], Schedule.prototype, "dayRender", void 0);
  473. __decorate([
  474. core_1.Input(),
  475. __metadata("design:type", Boolean)
  476. ], Schedule.prototype, "navLinks", void 0);
  477. __decorate([
  478. core_1.Output(),
  479. __metadata("design:type", core_1.EventEmitter)
  480. ], Schedule.prototype, "onDayClick", void 0);
  481. __decorate([
  482. core_1.Output(),
  483. __metadata("design:type", core_1.EventEmitter)
  484. ], Schedule.prototype, "onDrop", void 0);
  485. __decorate([
  486. core_1.Output(),
  487. __metadata("design:type", core_1.EventEmitter)
  488. ], Schedule.prototype, "onEventClick", void 0);
  489. __decorate([
  490. core_1.Output(),
  491. __metadata("design:type", core_1.EventEmitter)
  492. ], Schedule.prototype, "onEventMouseover", void 0);
  493. __decorate([
  494. core_1.Output(),
  495. __metadata("design:type", core_1.EventEmitter)
  496. ], Schedule.prototype, "onEventMouseout", void 0);
  497. __decorate([
  498. core_1.Output(),
  499. __metadata("design:type", core_1.EventEmitter)
  500. ], Schedule.prototype, "onEventDragStart", void 0);
  501. __decorate([
  502. core_1.Output(),
  503. __metadata("design:type", core_1.EventEmitter)
  504. ], Schedule.prototype, "onEventDragStop", void 0);
  505. __decorate([
  506. core_1.Output(),
  507. __metadata("design:type", core_1.EventEmitter)
  508. ], Schedule.prototype, "onEventDrop", void 0);
  509. __decorate([
  510. core_1.Output(),
  511. __metadata("design:type", core_1.EventEmitter)
  512. ], Schedule.prototype, "onEventResizeStart", void 0);
  513. __decorate([
  514. core_1.Output(),
  515. __metadata("design:type", core_1.EventEmitter)
  516. ], Schedule.prototype, "onEventResizeStop", void 0);
  517. __decorate([
  518. core_1.Output(),
  519. __metadata("design:type", core_1.EventEmitter)
  520. ], Schedule.prototype, "onEventResize", void 0);
  521. __decorate([
  522. core_1.Output(),
  523. __metadata("design:type", core_1.EventEmitter)
  524. ], Schedule.prototype, "onViewRender", void 0);
  525. __decorate([
  526. core_1.Output(),
  527. __metadata("design:type", core_1.EventEmitter)
  528. ], Schedule.prototype, "onViewDestroy", void 0);
  529. __decorate([
  530. core_1.Output(),
  531. __metadata("design:type", core_1.EventEmitter)
  532. ], Schedule.prototype, "onNavLinkDayClick", void 0);
  533. __decorate([
  534. core_1.Output(),
  535. __metadata("design:type", core_1.EventEmitter)
  536. ], Schedule.prototype, "onNavLinkWeekClick", void 0);
  537. __decorate([
  538. core_1.Input(),
  539. __metadata("design:type", Object),
  540. __metadata("design:paramtypes", [Object])
  541. ], Schedule.prototype, "options", null);
  542. Schedule = __decorate([
  543. core_1.Component({
  544. selector: 'p-schedule',
  545. template: '<div [ngStyle]="style" [class]="styleClass"></div>'
  546. }),
  547. __metadata("design:paramtypes", [core_1.ElementRef, core_1.IterableDiffers])
  548. ], Schedule);
  549. return Schedule;
  550. }());
  551. exports.Schedule = Schedule;
  552. var ScheduleModule = /** @class */ (function () {
  553. function ScheduleModule() {
  554. }
  555. ScheduleModule = __decorate([
  556. core_1.NgModule({
  557. imports: [common_1.CommonModule],
  558. exports: [Schedule],
  559. declarations: [Schedule]
  560. })
  561. ], ScheduleModule);
  562. return ScheduleModule;
  563. }());
  564. exports.ScheduleModule = ScheduleModule;
  565. //# sourceMappingURL=schedule.js.map