public_html/layouts/basic/modules/Project/resources/GanttController.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("Project_Gantt_Js",{},{filterSelectElement:!1,getFilterSelectElement:function getFilterSelectElement(){return !1==this.filterSelectElement&&(this.filterSelectElement=jQuery("#customFilter")),this.filterSelectElement},getDefaultParams:function getDefaultParams(){var params={module:app.getModuleName(),action:"GanttData"};return app.getParentModuleName()&&(params.parent=app.getParentModuleName()),params},getCurrentCvId:function getCurrentCvId(){return jQuery("#customFilter").find("option:selected").data("id")},getGanttData:function getGanttData(urlParams){var aDeferred=$.Deferred();"undefined"==typeof urlParams&&(urlParams={});var defaultParams=this.getDefaultParams();urlParams=$.extend(defaultParams,urlParams);var progressInstance=jQuery.progressIndicator({blockInfo:{enabled:!0,onBlock:function onBlock(){AppConnector.request(urlParams).done(function(data){progressInstance.progressIndicator({mode:"hide"}),aDeferred.resolve(data),app.notifyPostAjaxReady();}).fail(function(textStatus,errorThrown){aDeferred.reject(textStatus,errorThrown);});}}});return aDeferred.promise()},/**
* load gantt
*/loadGantt:function loadGantt(){var container=0<arguments.length&&arguments[0]!==void 0?arguments[0]:".js-gantt__container",ganttData=!!(1<arguments.length&&arguments[1]!==void 0)&&arguments[1];container=$(container),this.gantt=new Gantt(container);var projectId=container.parent().find("input[name=\"projectId\"]").val();ganttData||this.gantt.loadProjectFromAjax({module:app.getModuleName(),action:"GanttData",projectId:projectId});},/**
* reload gantt with new data
* @param data
*/reloadData:function reloadData(data){this.gantt.reloadData(data);},/*
* Function to register the event for changing the custom Filter
*/registerChangeCustomFilterEvent:function registerChangeCustomFilterEvent(){var thisInstance=this;this.getFilterSelectElement().on("change",function(event){$(".nav-item[data-cvid='".concat(thisInstance.getCurrentCvId(),"'] .nav-link")).tab("show");var currentTarget=jQuery(event.currentTarget),selectOption=currentTarget.find(":selected");app.setMainParams("pageNumber","1"),app.setMainParams("pageToJump","1"),app.setMainParams("orderBy",selectOption.data("orderby")),app.setMainParams("sortOrder",selectOption.data("sortorder")),thisInstance.getGanttData({viewname:jQuery(this).val()}).done(function(data){thisInstance.reloadData(data.result);}),event.stopPropagation();});},getSelectOptionFromChosenOption:function getSelectOptionFromChosenOption(liElement){var id=liElement.attr("id"),idArr=id.split("-"),currentOptionId="";if(0<idArr.length)currentOptionId=idArr[idArr.length-1];else return !1;return jQuery("#filterOptionId_"+currentOptionId)},changeCustomFilterElementView:function changeCustomFilterElementView(){var self=this,filterSelectElement=this.getFilterSelectElement();if(0<filterSelectElement.length&&filterSelectElement.is("select")){App.Fields.Picklist.showSelect2ElementView(filterSelectElement,{templateSelection:function templateSelection(data){var resultContainer=document.createElement("span"),span=document.createElement("span"),image=$(".filterImage").clone();return image.removeAttr("style"),span.innerText=data.text,resultContainer.appendChild(image.get(0)),resultContainer.appendChild(span),resultContainer},customSortOptGroup:!0,closeOnSelect:!0});var select2Instance=filterSelectElement.data("select2");jQuery(".filterActionsDiv").appendTo(select2Instance.$dropdown.find(".select2-dropdown:last")).removeClass("d-none").on("click",function(e){self.registerCreateFilterClickEvent(e);});}},registerEvents:function registerEvents(){this.changeCustomFilterElementView(),this.registerChangeCustomFilterEvent(),Vtiger_Helper_Js.showHorizontalTopScrollBar(),this.loadGantt();}});
//# sourceMappingURL=GanttController.min.js.map