public_html/layouts/basic/modules/Calendar/resources/CalendarView.min.js
'use strict';
/* {[The file is published on the basis of YetiForce Public License 6.5 that can be found in the following directory: licenses/LicenseEN.txt or yetiforce.com]} */"use strict";/**
* Class representing an extended calendar.
* @extends Calendar_Calendar_Js
*/function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}function _createClass(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),Object.defineProperty(Constructor,"prototype",{writable:!1}),Constructor}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return "symbol"===_typeof(key)?key:String(key)}function _toPrimitive(input,hint){if("object"!==_typeof(input)||null===input)return input;var prim=input[Symbol.toPrimitive];if(prim!==void 0){var res=prim.call(input,hint||"default");if("object"!==_typeof(res))return res;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===hint?String:Number)(input)}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(target,property,receiver){var base=_superPropBase(target,property);if(base){var desc=Object.getOwnPropertyDescriptor(base,property);return desc.get?desc.get.call(3>arguments.length?target:receiver):desc.value}},_get.apply(this,arguments)}function _superPropBase(object,property){for(;!Object.prototype.hasOwnProperty.call(object,property)&&(object=_getPrototypeOf(object),null!==object););return object}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function");subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:!0,configurable:!0}}),Object.defineProperty(subClass,"prototype",{writable:!1}),superClass&&_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,p){return o.__proto__=p,o},_setPrototypeOf(o,p)}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function(){var result,Super=_getPrototypeOf(Derived);if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else result=Super.apply(this,arguments);return _possibleConstructorReturn(this,result)}}function _possibleConstructorReturn(self,call){if(call&&("object"===_typeof(call)||"function"==typeof call))return call;if(void 0!==call)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(self)}function _assertThisInitialized(self){if(void 0===self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return self}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return !1}}function _getPrototypeOf(o){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},_getPrototypeOf(o)}//Global calendar flag needed for correct loading data from history browser in year view
window.calendarLoaded=!1,window.Calendar_Calendar_Js=/*#__PURE__*/function(_Vtiger_Calendar_Js){/**
* Create calendar's options.
* @param {jQuery} container
* @param {bool} readonly
* @param {boolean} browserHistory
*/function Calendar_Calendar_Js(container,readonly){var browserHistory=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];return _classCallCheck(this,Calendar_Calendar_Js),_super.call(this,container,readonly,browserHistory)}/**
* Set calendar module options.
* @returns {{allDaySlot: boolean, dayClick: object, selectable: boolean}}
*/_inherits(Calendar_Calendar_Js,_Vtiger_Calendar_Js);var _super=_createSuper(Calendar_Calendar_Js);return _createClass(Calendar_Calendar_Js,[{key:"setCalendarModuleOptions",value:function setCalendarModuleOptions(){var _this=this,self=this;return {allDaySlot:app.getMainParams("allDaySlot"),dateClick:function dateClick(args){1==_this.eventCreate&&_this.showCalendarCreateView().done(function(form){!1===_this.getSidebarView().find(".tab-pane.active").hasClass("js-right-panel-event")&&_this.getSidebarView().find(".js-right-panel-event-link").trigger("click"),_this.dayCallbackCreateModal(form,args);});},selectable:!1,eventClick:function eventClick(info){info.jsEvent.preventDefault();var element=$(info.el),link=element.attr("href");link||(link=element.find("a").attr("href")),!self.readonly&&self.eventEdit?self.showSidebarEvent(link):window.location.assign(link.replace("view=","xview=")+"&view=Detail");}}}/**
* Show sidebar event
* @param {*} params
* @returns {Promise}
*/},{key:"showSidebarEvent",value:function showSidebarEvent(params){var _this2=this,self=this,aDeferred=$.Deferred(),progressInstance=$.progressIndicator({blockInfo:{enabled:!0}});return "number"==typeof params&&(params={module:this.module,view:"EventForm",record:params}),AppConnector.request(params).done(function(data){progressInstance.progressIndicator({mode:"hide"}),self.openRightPanel(),_this2.updateSidebar(data);var sidebar=self.getSidebarView();sidebar.find("form").length?self.registerEditForm(sidebar):(app.showNewScrollbar(sidebar.find(".js-calendar__form__wrapper"),{suppressScrollX:!0}),sidebar.find(".js-activity-state .js-summary-close-edit").on("click",function(){self.showCalendarCreateView();}),sidebar.find(".js-activity-state .editRecord").on("click",function(){self.showSidebarEvent($(this).data("id"));})),aDeferred.resolve(sidebar.find(".js-qc-form"));}).fail(function(error){progressInstance.progressIndicator({mode:"hide"}),app.errorLog(error);}),aDeferred.promise()}/**
* Open sidebar right panel
*/},{key:"openRightPanel",value:function openRightPanel(){this.getSidebarView().hasClass("hideSiteBar")&&this.getSidebarView().find(".js-toggle-site-bar-right-button").trigger("click");}/**
* Update sidebar
* @param {html} data
*/},{key:"updateSidebar",value:function updateSidebar(data){this.getSidebarView().find(".js-qc-form").html(data),this.showRightPanelForm();}/**
* Show sidebar right panel form
*/},{key:"showRightPanelForm",value:function showRightPanelForm(){var calendarRightPanel=this.getSidebarView();calendarRightPanel.find(".js-right-panel-event").hasClass("active")||calendarRightPanel.find(".js-right-panel-event-link").trigger("click"),app.showNewScrollbar(calendarRightPanel.find(".js-calendar__form__wrapper"),{suppressScrollX:!0});}/**
* Register events to EditView
* @param {jQuery} sideBar
*/},{key:"registerEditForm",value:function registerEditForm(sideBar){var _this3=this,editViewInstance=Vtiger_Edit_Js.getInstanceByModuleName(sideBar.find("[name=\"module\"]").val()),rightFormCreate=sideBar.find("form.js-form");editViewInstance.registerBasicEvents(rightFormCreate),rightFormCreate.validationEngine(app.validationEngineOptions),App.Fields.Picklist.showSelect2ElementView(sideBar.find("select")),sideBar.find(".js-summary-close-edit").on("click",function(){_this3.showCalendarCreateView();}),App.Components.QuickCreate.registerPostLoadEvents(rightFormCreate,{callbackFunction:this.registerAfterSubmitForm(this)}),new App.Fields.Text.Editor(sideBar.find(".js-editor"),{height:"5em",toolbar:"Min"});}/**
* Register actions to do after save record
* @param {object} self
* @param {object} data
* @returns {function}
*/},{key:"registerAfterSubmitForm",value:function registerAfterSubmitForm(self){return function returnFunction(data){data.success&&(self.reloadCalendarData(),self.refreshDatesRowView(),self.getSidebarView().find(".js-qc-form").html(""),self.showCalendarCreateView(),window.popoverCache={});}}/**
* Load calendar data
*/},{key:"loadCalendarData",value:function loadCalendarData(){var self=this,progressInstance=$.progressIndicator({blockInfo:{enabled:!0}}),options=this.getDefaultParams();self.fullCalendar.removeAllEvents(),self.clearFilterButton(options.user),options.historyUrl="index.php?module=".concat(options.module,"&view=Calendar&history=true&viewType=").concat(this.fullCalendar.view.type,"&start=").concat(options.start,"&end=").concat(options.end,"&user=").concat(JSON.stringify(options.user),"&time=").concat(options.time,"&cvid=").concat(options.cvid,"&hiddenDays=").concat(this.fullCalendar.getOption("hiddenDays"));var connectorMethod=window.AppConnector.request;this.browserHistory&&window.calendarLoaded&&(connectorMethod=window.AppConnector.requestPjax),this.browserHistoryConfig&&Object.keys(this.browserHistoryConfig).length&&!window.calendarLoaded&&(options=Object.assign(options,{start:this.browserHistoryConfig.start,end:this.browserHistoryConfig.end,user:this.browserHistoryConfig.user,time:this.browserHistoryConfig.time,cvid:this.browserHistoryConfig.cvid}),connectorMethod=window.AppConnector.request,app.setMainParams("showType",this.browserHistoryConfig.time),app.setMainParams("usersId",this.browserHistoryConfig.user)),connectorMethod(options).done(function(events){self.fullCalendar.removeAllEvents(),self.fullCalendar.addEventSource(events.result),progressInstance.progressIndicator({mode:"hide"});}),window.calendarLoaded=!0;}/**
* Show create view
* @returns {Promise}
*/},{key:"showCalendarCreateView",value:function showCalendarCreateView(){var _this4=this,aDeferred=$.Deferred();if(1==this.eventCreate){var sideBar=this.getSidebarView(),qcForm=sideBar.find(".js-qc-form");if(0<qcForm.find("form").length&&0===qcForm.find("input[name=record]").length)aDeferred.resolve(qcForm);else {var progressInstance=$.progressIndicator({blockInfo:{enabled:!0}});this.showSidebarEvent({module:this.module,view:"EventForm"}).done(function(){progressInstance.progressIndicator({mode:"hide"}),_this4.registerAutofillTime(),aDeferred.resolve(qcForm);}).fail(function(error){progressInstance.progressIndicator({mode:"hide"}),app.errorLog(error);});}}else aDeferred.reject();return aDeferred.promise()}/**
* Auto select date in create view in extended calendar
*/},{key:"registerAutofillTime",value:function registerAutofillTime(){app.getMainParams("autofillTime")&&this.container.find(".js-autofill").prop("checked","checked").trigger("change");}/**
* Register cache settings
*/},{key:"registerCacheSettings",value:function registerCacheSettings(){var self=this;$(".siteBarRight .filterField").each(function(){var name=$(this).attr("id"),value=app.moduleCacheGet(name),element=$("#"+name);0<element.length&&null!=value&&"checkbox"==element.attr("type")&&element.prop("checked",value);}),this.getCalendarView().find(".fc-toolbar .fc-button").on("click",function(e){var element=$(e.currentTarget);element.hasClass("fc-"+self.fullCalendar.view.type+"-button")?app.moduleCacheSet("defaultView",self.fullCalendar.view.type):(element.hasClass("fc-prev-button")||element.hasClass("fc-next-button")||element.hasClass("fc-today-button"))&&(app.moduleCacheSet("start",App.Fields.Date.dateToUserFormat(self.fullCalendar.view.activeStart)),app.moduleCacheSet("end",App.Fields.Date.dateToUserFormat(self.fullCalendar.view.activeEnd)));});var keys=app.moduleCacheKeys();if(0<keys.length){var alert=$("#moduleCacheAlert");alert.find(".cacheClear").on("click",function(){app.moduleCacheClear(),alert.addClass("d-none"),location.reload();});}}/**
* Register site bar events
*/},{key:"registerSiteBarEvents",value:function registerSiteBarEvents(){var calendarRightPanel=$(".js-calendar-right-panel");calendarRightPanel.find(".js-show-sitebar").on("click",function(){calendarRightPanel.hasClass("hideSiteBar")&&calendarRightPanel.find(".js-toggle-site-bar-right-button").trigger("click");});}/**
* Register popover buttons' click
*/},{key:"registerPopoverButtonsClickEvent",value:function registerPopoverButtonsClickEvent(){$(document).on("click",".js-calendar-popover__button",this.showCalendarPopoverLinkInSidebar.bind(this));}/**
* Show popover link in sidebar
* @param {jQuery.Event} e click event
* @returns {boolean}
*/},{key:"showCalendarPopoverLinkInSidebar",value:function showCalendarPopoverLinkInSidebar(e){var href=e.currentTarget.href,hrefObject=app.convertUrlToObject(href);if("Calendar"!==hrefObject.module||"Edit"!==hrefObject.view&&"Detail"!==hrefObject.view)return !0;e.preventDefault();var sidebarView="Edit"===hrefObject.view?"EventForm":"ActivityState";href=href.replace(hrefObject.view,sidebarView),this.showSidebarEvent(href);}/**
* Register events
*/},{key:"registerEvents",value:function registerEvents(){_get(_getPrototypeOf(Calendar_Calendar_Js.prototype),"registerEvents",this).call(this),this.registerSiteBarEvents(),this.registerPopoverButtonsClickEvent(),ElementQueries.listen(),this.showCalendarCreateView();}}],[{key:"goToRecordsList",value:/**
* Go to records list
* @param {string} link
*/function goToRecordsList(link){var self=app.pageController,status=app.getMainParams("activityStateLabels",!0),options=self.getDefaultParams();link+=options.cvid?"&viewname="+options.cvid:"&viewname=All";var searchParams="[\"activitystatus\",\"e\",\""+status[app.getMainParams("showType")].join()+"\"]";searchParams+=",[\"date_start\",\"bw\",\""+options.start+" 00:00:00,"+options.end+" 23:59:59\"]",options.user&&(searchParams+=",[\"assigned_user_id\",\"e\",\""+options.user.selectedIds.join("##")+"\"]"),link+="&search_params=[["+encodeURIComponent(searchParams)+"]]",window.location.href=link;}}]),Calendar_Calendar_Js}(Vtiger_Calendar_Js);
//# sourceMappingURL=CalendarView.min.js.map