UNPKG

@syncfusion/ej2-vue-schedule

Version:

Flexible scheduling library with more built-in features and enhanced customization options similar to outlook and google calendar, allowing the users to plan and manage their appointments with efficient data-binding support. for Vue

683 lines (675 loc) 26.2 kB
import { Schedule, RecurrenceEditor } from '@syncfusion/ej2-schedule'; export * from '@syncfusion/ej2-schedule'; import { vueDefineComponent, isExecute, gh, getProps, ComponentBase } from '@syncfusion/ej2-vue-base'; import { isNullOrUndefined, isUndefined } from '@syncfusion/ej2-base'; let ViewsDirective = vueDefineComponent({ inject: { custom: { default: null } }, render(createElement) { if (!isExecute) { let h = !isExecute ? gh : createElement; let slots = null; if (!isNullOrUndefined(this.$slots.default)) { slots = !isExecute ? this.$slots.default() : this.$slots.default; } return h('div', { class: 'e-directive' }, slots); } return; }, updated() { if (!isExecute && this.custom) { this.custom(); } }, methods: { getTag() { return 'e-views'; } } }); const ViewsPlugin = { name: 'e-views', install(Vue) { Vue.component(ViewsPlugin.name, ViewsDirective); } }; /** * `e-views` directive represent a view of the VueJS Schedule. * It must be contained in a Schedule component(`ejs-schedule`). * ```vue * <ejs-schedule> * <e-views> * <e-view option='day' dateFormat='dd MMM'></e-view> * <e-view option='week'></e-view> * </e-views> * </ejs-schedule> * ``` */ let ViewDirective = vueDefineComponent({ render() { return; }, methods: { getTag() { return 'e-view'; } } }); const ViewPlugin = { name: 'e-view', install(Vue) { Vue.component(ViewPlugin.name, ViewDirective); } }; let ResourcesDirective = vueDefineComponent({ inject: { custom: { default: null } }, render(createElement) { if (!isExecute) { let h = !isExecute ? gh : createElement; let slots = null; if (!isNullOrUndefined(this.$slots.default)) { slots = !isExecute ? this.$slots.default() : this.$slots.default; } return h('div', { class: 'e-directive' }, slots); } return; }, updated() { if (!isExecute && this.custom) { this.custom(); } }, methods: { getTag() { return 'e-resources'; } } }); const ResourcesPlugin = { name: 'e-resources', install(Vue) { Vue.component(ResourcesPlugin.name, ResourcesDirective); } }; /** * `e-resources` directive represent a resources of the VueJS Schedule. * It must be contained in a Schedule component(`ejs-schedule`). * ```vue * <ejs-schedule> * <e-resources> * <e-resource field='RoomId' name='Rooms'></e-resource> * <e-resource field='OwnerId' name='Owners'></e-resource> * </e-resources> * </ejs-schedule> * ``` */ let ResourceDirective = vueDefineComponent({ render() { return; }, methods: { getTag() { return 'e-resource'; } } }); const ResourcePlugin = { name: 'e-resource', install(Vue) { Vue.component(ResourcePlugin.name, ResourceDirective); } }; let HeaderRowsDirective = vueDefineComponent({ inject: { custom: { default: null } }, render(createElement) { if (!isExecute) { let h = !isExecute ? gh : createElement; let slots = null; if (!isNullOrUndefined(this.$slots.default)) { slots = !isExecute ? this.$slots.default() : this.$slots.default; } return h('div', { class: 'e-directive' }, slots); } return; }, updated() { if (!isExecute && this.custom) { this.custom(); } }, methods: { getTag() { return 'e-header-rows'; } } }); const HeaderRowsPlugin = { name: 'e-header-rows', install(Vue) { Vue.component(HeaderRowsPlugin.name, HeaderRowsDirective); } }; /** * `e-header-rows` directive represent a header rows of the VueJS Schedule. * It must be contained in a Schedule component(`ejs-schedule`). * ```vue * <ejs-schedule> * <e-header-rows> * <e-header-row option='Week'></e-header-row> * <e-header-row option='Date'></e-header-row> * </e-header-rows> * </ejs-schedule> * ``` */ let HeaderRowDirective = vueDefineComponent({ render() { return; }, methods: { getTag() { return 'e-header-row'; } } }); const HeaderRowPlugin = { name: 'e-header-row', install(Vue) { Vue.component(HeaderRowPlugin.name, HeaderRowDirective); } }; let ToolbarItemsDirective = vueDefineComponent({ inject: { custom: { default: null } }, render(createElement) { if (!isExecute) { let h = !isExecute ? gh : createElement; let slots = null; if (!isNullOrUndefined(this.$slots.default)) { slots = !isExecute ? this.$slots.default() : this.$slots.default; } return h('div', { class: 'e-directive' }, slots); } return; }, updated() { if (!isExecute && this.custom) { this.custom(); } }, methods: { getTag() { return 'e-toolbaritems'; } } }); const ToolbarItemsPlugin = { name: 'e-toolbaritems', install(Vue) { Vue.component(ToolbarItemsPlugin.name, ToolbarItemsDirective); } }; /** * `e-toolbaritems` directive represent a custom toolbar items of the VueJS Schedule. * It must be contained in a Schedule component(`ejs-schedule`). * ```vue * <ejs-schedule> * <e-toolbaritems> * <e-toolbaritem name='Today'></<e-toolbaritem> * <e-toolbaritem name='DateRangeText'></e-toolbaritem> * <e-toolbaritem prefixIcon='e-icons e-cut' text='Cut'></e-toolbaritem> * <e-toolbaritems> * </ejs-schedule> * ``` */ let ToolbarItemDirective = vueDefineComponent({ render() { return; }, methods: { getTag() { return 'e-toolbaritem'; } } }); const ToolbarItemPlugin = { name: 'e-toolbaritem', install(Vue) { Vue.component(ToolbarItemPlugin.name, ToolbarItemDirective); } }; const properties = ['isLazyUpdate', 'plugins', 'agendaDaysCount', 'allowClipboard', 'allowDragAndDrop', 'allowInline', 'allowKeyboardInteraction', 'allowMultiCellSelection', 'allowMultiDrag', 'allowMultiRowSelection', 'allowOverlap', 'allowResizing', 'allowSwiping', 'calendarMode', 'cellHeaderTemplate', 'cellTemplate', 'cssClass', 'currentView', 'dateFormat', 'dateHeaderTemplate', 'dateRangeTemplate', 'dayHeaderTemplate', 'editorFooterTemplate', 'editorHeaderTemplate', 'editorTemplate', 'enableAdaptiveUI', 'enableAllDayScroll', 'enableHtmlSanitizer', 'enablePersistence', 'enableRecurrenceValidation', 'enableRtl', 'endHour', 'eventDragArea', 'eventSettings', 'firstDayOfWeek', 'firstMonthOfYear', 'group', 'headerIndentTemplate', 'headerRows', 'height', 'hideEmptyAgendaDays', 'locale', 'maxDate', 'minDate', 'monthHeaderTemplate', 'monthsCount', 'overscanCount', 'quickInfoOnSelectionEnd', 'quickInfoTemplates', 'readonly', 'resourceHeaderTemplate', 'resources', 'rowAutoHeight', 'selectedDate', 'showHeaderBar', 'showQuickInfo', 'showTimeIndicator', 'showWeekNumber', 'showWeekend', 'startHour', 'timeFormat', 'timeScale', 'timezone', 'timezoneDataSource', 'toolbarItems', 'views', 'weekRule', 'width', 'workDays', 'workHours', 'actionBegin', 'actionComplete', 'actionFailure', 'beforePaste', 'beforePrint', 'cellClick', 'cellDoubleClick', 'created', 'dataBinding', 'dataBound', 'destroyed', 'drag', 'dragStart', 'dragStop', 'eventClick', 'eventDoubleClick', 'eventRendered', 'excelExport', 'hover', 'moreEventsClick', 'navigating', 'popupClose', 'popupOpen', 'renderCell', 'resizeStart', 'resizeStop', 'resizing', 'select', 'tooltipOpen', 'virtualScrollStart', 'virtualScrollStop']; const modelProps = ['currentView', 'selectedDate']; const testProp = getProps({ props: properties }); const props = testProp[0], watch = testProp[1], emitProbs = Object.keys(watch); emitProbs.push('modelchanged', 'update:modelValue'); for (let props of modelProps) { emitProbs.push('update:' + props); } /** * `ej-schedule` represents the VueJS Schedule Component. * ```vue * <ejs-schedule></ejs-schedule> * ``` */ let ScheduleComponent = vueDefineComponent({ name: 'ScheduleComponent', mixins: [ComponentBase], props: props, watch: watch, emits: emitProbs, model: { event: 'modelchanged' }, provide() { return { custom: this.custom }; }, data() { return { ej2Instances: new Schedule({}), propKeys: properties, models: modelProps, hasChildDirective: true, hasInjectedModules: true, tagMapper: { "e-views": "e-view", "e-resources": "e-resource", "e-header-rows": "e-header-row", "e-toolbaritems": "e-toolbaritem" }, tagNameMapper: { "e-header-rows": "e-headerRows", "e-toolbaritems": "e-toolbarItems" }, isVue3: !isExecute, templateCollection: {}, }; }, created() { this.ej2Instances._trigger = this.ej2Instances.trigger; this.ej2Instances.trigger = this.trigger; this.bindProperties(); this.ej2Instances._setProperties = this.ej2Instances.setProperties; this.ej2Instances.setProperties = this.setProperties; this.ej2Instances.clearTemplate = this.clearTemplate; this.updated = this.updated; }, render(createElement) { let h = !isExecute ? gh : createElement; let slots = null; if (!isNullOrUndefined(this.$slots.default)) { slots = !isExecute ? this.$slots.default() : this.$slots.default; } return h('div', slots); }, methods: { clearTemplate(templateNames) { if (!templateNames) { templateNames = Object.keys(this.templateCollection || {}); } if (templateNames.length && this.templateCollection) { for (let tempName of templateNames) { let elementCollection = this.templateCollection[tempName]; if (elementCollection && elementCollection.length) { for (let ele of elementCollection) { this.destroyPortals(ele); } delete this.templateCollection[tempName]; } } } }, setProperties(prop, muteOnChange) { if (this.isVue3) { this.models = !this.models ? this.ej2Instances.referModels : this.models; } if (this.ej2Instances && this.ej2Instances._setProperties) { this.ej2Instances._setProperties(prop, muteOnChange); } if (prop && this.models && this.models.length) { Object.keys(prop).map((key) => { this.models.map((model) => { if ((key === model) && !(/datasource/i.test(key))) { if (this.isVue3) { this.ej2Instances.vueInstance.$emit('update:' + key, prop[key]); } else { this.$emit('update:' + key, prop[key]); this.$emit('modelchanged', prop[key]); } } }); }); } }, trigger(eventName, eventProp, successHandler) { if (!isExecute) { this.models = !this.models ? this.ej2Instances.referModels : this.models; } if ((eventName === 'change' || eventName === 'input') && this.models && (this.models.length !== 0)) { let key = this.models.toString().match(/checked|value/) || []; let propKey = key[0]; if (eventProp && key && !isUndefined(eventProp[propKey])) { if (!isExecute) { this.ej2Instances.vueInstance.$emit('update:' + propKey, eventProp[propKey]); this.ej2Instances.vueInstance.$emit('modelchanged', eventProp[propKey]); this.ej2Instances.vueInstance.$emit('update:modelValue', eventProp[propKey]); } else { if (eventName === 'change' || (this.$props && !this.$props.isLazyUpdate)) { this.$emit('update:' + propKey, eventProp[propKey]); this.$emit('modelchanged', eventProp[propKey]); } } } } else if ((eventName === 'actionBegin' && eventProp.requestType === 'dateNavigate') && this.models && (this.models.length !== 0)) { let key = this.models.toString().match(/currentView|selectedDate/) || []; let propKey = key[0]; if (eventProp && key && !isUndefined(eventProp[propKey])) { if (!isExecute) { this.ej2Instances.vueInstance.$emit('update:' + propKey, eventProp[propKey]); this.ej2Instances.vueInstance.$emit('modelchanged', eventProp[propKey]); } else { this.$emit('update:' + propKey, eventProp[propKey]); this.$emit('modelchanged', eventProp[propKey]); } } } if ((this.ej2Instances && this.ej2Instances._trigger)) { this.ej2Instances._trigger(eventName, eventProp, successHandler); } }, custom() { this.updated(); }, addEvent(data) { return this.ej2Instances.addEvent(data); }, addResource(resources, name, index) { return this.ej2Instances.addResource(resources, name, index); }, changeCurrentView(viewName, viewIndex) { return this.ej2Instances.changeCurrentView(viewName, viewIndex); }, closeEditor() { return this.ej2Instances.closeEditor(); }, closeOverlapAlert() { return this.ej2Instances.closeOverlapAlert(); }, closeQuickInfoPopup() { return this.ej2Instances.closeQuickInfoPopup(); }, closeTooltip() { return this.ej2Instances.closeTooltip(); }, collapseResource(resourceId, name) { return this.ej2Instances.collapseResource(resourceId, name); }, copy(elements) { return this.ej2Instances.copy(elements); }, cut(elements) { return this.ej2Instances.cut(elements); }, deleteEvent(id, currentAction) { return this.ej2Instances.deleteEvent(id, currentAction); }, destroy() { return this.ej2Instances.destroy(); }, expandResource(resourceId, name) { return this.ej2Instances.expandResource(resourceId, name); }, exportToExcel(excelExportOptions) { return this.ej2Instances.exportToExcel(excelExportOptions); }, exportToICalendar(fileName, customData) { return this.ej2Instances.exportToICalendar(fileName, customData); }, generateEventOccurrences(event, startDate) { return this.ej2Instances.generateEventOccurrences(event, startDate); }, getBlockEvents(startDate, endDate, includeOccurrences) { return this.ej2Instances.getBlockEvents(startDate, endDate, includeOccurrences); }, getCellDetails(tdCol) { return this.ej2Instances.getCellDetails(tdCol); }, getCurrentViewDates() { return this.ej2Instances.getCurrentViewDates(); }, getCurrentViewEvents() { return this.ej2Instances.getCurrentViewEvents(); }, getCurrentViewIndex() { return this.ej2Instances.getCurrentViewIndex(); }, getDateRangeText(dates) { return this.ej2Instances.getDateRangeText(dates); }, getDeletedOccurrences(recurrenceData) { return this.ej2Instances.getDeletedOccurrences(recurrenceData); }, getEventDetails(element) { return this.ej2Instances.getEventDetails(element); }, getEventMaxID() { return this.ej2Instances.getEventMaxID(); }, getEventTemplateName(resIndex) { return this.ej2Instances.getEventTemplateName(resIndex); }, getEvents(startDate, endDate, includeOccurrences) { return this.ej2Instances.getEvents(startDate, endDate, includeOccurrences); }, getIndexFromResourceId(id, name) { return this.ej2Instances.getIndexFromResourceId(id, name); }, getOccurrencesByID(eventID) { return this.ej2Instances.getOccurrencesByID(eventID); }, getOccurrencesByRange(startTime, endTime) { return this.ej2Instances.getOccurrencesByRange(startTime, endTime); }, getResourceCollections() { return this.ej2Instances.getResourceCollections(); }, getResourcesByIndex(index) { return this.ej2Instances.getResourcesByIndex(index); }, getSelectedElements() { return this.ej2Instances.getSelectedElements(); }, getViewDates(type) { return this.ej2Instances.getViewDates(type); }, hideSpinner() { return this.ej2Instances.hideSpinner(); }, importICalendar(fileContent) { return this.ej2Instances.importICalendar(fileContent); }, isSlotAvailable(startTime, endTime, groupIndex) { return this.ej2Instances.isSlotAvailable(startTime, endTime, groupIndex); }, openEditor(data, action, isEventData, repeatType) { return this.ej2Instances.openEditor(data, action, isEventData, repeatType); }, openOverlapAlert(args) { return this.ej2Instances.openOverlapAlert(args); }, openQuickInfoPopup(data) { return this.ej2Instances.openQuickInfoPopup(data); }, paste(targetElement) { return this.ej2Instances.paste(targetElement); }, print(printOptions) { return this.ej2Instances.print(printOptions); }, refreshEvents(isRemoteRefresh) { return this.ej2Instances.refreshEvents(isRemoteRefresh); }, refreshLayout() { return this.ej2Instances.refreshLayout(); }, refreshTemplates(templateName) { return this.ej2Instances.refreshTemplates(templateName); }, removeResource(resourceId, name) { return this.ej2Instances.removeResource(resourceId, name); }, resetWorkHours(dates, start, end, groupIndex) { return this.ej2Instances.resetWorkHours(dates, start, end, groupIndex); }, saveEvent(data, currentAction) { return this.ej2Instances.saveEvent(data, currentAction); }, scrollTo(hour, scrollDate) { return this.ej2Instances.scrollTo(hour, scrollDate); }, scrollToResource(resourceId, groupName) { return this.ej2Instances.scrollToResource(resourceId, groupName); }, selectResourceByIndex(groupIndex) { return this.ej2Instances.selectResourceByIndex(groupIndex); }, setRecurrenceEditor(recurrenceEditor) { return this.ej2Instances.setRecurrenceEditor(recurrenceEditor); }, setResourceCollections(resourceCol, isEventDataRefresh) { return this.ej2Instances.setResourceCollections(resourceCol, isEventDataRefresh); }, setWorkHours(dates, start, end, groupIndex) { return this.ej2Instances.setWorkHours(dates, start, end, groupIndex); }, showSpinner() { return this.ej2Instances.showSpinner(); }, } }); const SchedulePlugin = { name: 'ejs-schedule', install(Vue) { Vue.component(SchedulePlugin.name, ScheduleComponent); Vue.component(ViewPlugin.name, ViewDirective); Vue.component(ViewsPlugin.name, ViewsDirective); Vue.component(ResourcePlugin.name, ResourceDirective); Vue.component(ResourcesPlugin.name, ResourcesDirective); Vue.component(HeaderRowPlugin.name, HeaderRowDirective); Vue.component(HeaderRowsPlugin.name, HeaderRowsDirective); Vue.component(ToolbarItemPlugin.name, ToolbarItemDirective); Vue.component(ToolbarItemsPlugin.name, ToolbarItemsDirective); } }; const properties$1 = ['isLazyUpdate', 'plugins', 'calendarMode', 'cssClass', 'dateFormat', 'enablePersistence', 'enableRtl', 'endTypes', 'firstDayOfWeek', 'frequencies', 'locale', 'maxDate', 'minDate', 'selectedType', 'startDate', 'value', 'change', 'created', 'destroyed']; const modelProps$1 = []; const testProp$1 = getProps({ props: properties$1 }); const props$1 = testProp$1[0], watch$1 = testProp$1[1], emitProbs$1 = Object.keys(watch$1); emitProbs$1.push('modelchanged', 'update:modelValue'); for (let props of modelProps$1) { emitProbs$1.push('update:' + props); } /** * `ejs-recurrenceeditor` represents the VueJS RecurrenceEditor Component. * ```vue * <ejs-recurrenceeditor></ejs-recurrenceeditor> * ``` */ let RecurrenceEditorComponent = vueDefineComponent({ name: 'RecurrenceEditorComponent', mixins: [ComponentBase], props: props$1, watch: watch$1, emits: emitProbs$1, provide() { return { custom: this.custom }; }, data() { return { ej2Instances: new RecurrenceEditor({}), propKeys: properties$1, models: modelProps$1, hasChildDirective: false, hasInjectedModules: false, tagMapper: {}, tagNameMapper: {}, isVue3: !isExecute, templateCollection: {}, }; }, created() { this.bindProperties(); this.ej2Instances._setProperties = this.ej2Instances.setProperties; this.ej2Instances.setProperties = this.setProperties; this.ej2Instances.clearTemplate = this.clearTemplate; this.updated = this.updated; }, render(createElement) { let h = !isExecute ? gh : createElement; let slots = null; if (!isNullOrUndefined(this.$slots.default)) { slots = !isExecute ? this.$slots.default() : this.$slots.default; } return h('div', slots); }, methods: { clearTemplate(templateNames) { if (!templateNames) { templateNames = Object.keys(this.templateCollection || {}); } if (templateNames.length && this.templateCollection) { for (let tempName of templateNames) { let elementCollection = this.templateCollection[tempName]; if (elementCollection && elementCollection.length) { for (let ele of elementCollection) { this.destroyPortals(ele); } delete this.templateCollection[tempName]; } } } }, setProperties(prop, muteOnChange) { if (this.isVue3) { this.models = !this.models ? this.ej2Instances.referModels : this.models; } if (this.ej2Instances && this.ej2Instances._setProperties) { this.ej2Instances._setProperties(prop, muteOnChange); } if (prop && this.models && this.models.length) { Object.keys(prop).map((key) => { this.models.map((model) => { if ((key === model) && !(/datasource/i.test(key))) { if (this.isVue3) { this.ej2Instances.vueInstance.$emit('update:' + key, prop[key]); } else { this.$emit('update:' + key, prop[key]); this.$emit('modelchanged', prop[key]); } } }); }); } }, custom() { this.updated(); }, destroy() { return this.ej2Instances.destroy(); }, getRecurrenceDates(startDate, rule, excludeDate, maximumCount, viewDate) { return this.ej2Instances.getRecurrenceDates(startDate, rule, excludeDate, maximumCount, viewDate); }, getRecurrenceRule() { return this.ej2Instances.getRecurrenceRule(); }, getRuleSummary(rule) { return this.ej2Instances.getRuleSummary(rule); }, resetFields() { return this.ej2Instances.resetFields(); }, setRecurrenceRule(rule, startDate) { return this.ej2Instances.setRecurrenceRule(rule, startDate); }, updateRuleUntilDate(startDate) { return this.ej2Instances.updateRuleUntilDate(startDate); }, } }); const RecurrenceEditorPlugin = { name: 'ejs-recurrenceeditor', install(Vue) { Vue.component(RecurrenceEditorPlugin.name, RecurrenceEditorComponent); } }; export { HeaderRowDirective, HeaderRowPlugin, HeaderRowsDirective, HeaderRowsPlugin, RecurrenceEditorComponent, RecurrenceEditorPlugin, ResourceDirective, ResourcePlugin, ResourcesDirective, ResourcesPlugin, ScheduleComponent, SchedulePlugin, ToolbarItemDirective, ToolbarItemPlugin, ToolbarItemsDirective, ToolbarItemsPlugin, ViewDirective, ViewPlugin, ViewsDirective, ViewsPlugin }; //# sourceMappingURL=ej2-vue-schedule.es2015.js.map