public_html/layouts/basic/modules/Vtiger/resources/BasicSearch.min.js
'use strict';
/*+***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*************************************************************************************/"use strict";jQuery.Class("Vtiger_BasicSearch_Js",{},{//stores the module that need to be searched
searchModule:!1,//stores the module that need to be searched which is selected by the user
currentSearchModule:!1,// reduce the number of results
reduceNumberResults:!1,// Should the result be in html
returnHtml:!0,// Main container with modules, value and buttons
mainContainer:!1,/**
* Function to get the search module
*/getSearchModule:function getSearchModule(){if(!1===this.searchModule){//default gives current module
var module=app.getModuleName();"undefined"!=typeof this.getCurrentSearchModule()&&(module=this.getCurrentSearchModule()),this.setSearchModule(module);}return this.searchModule},/**
* Function to set the search module
*/setSearchModule:function setSearchModule(moduleName){return this.searchModule=moduleName,this},/**
* Function to set main conatainer
*/setMainContainer:function setMainContainer(container){return this.mainContainer=container,this},/**
* Function to get the user selected search module
*/getCurrentSearchModule:function getCurrentSearchModule(){return !1===this.currentSearchModule&&this.mainContainer&&(this.currentSearchModule=this.mainContainer.find(".basicSearchModulesList").val()),this.currentSearchModule},/**
* Function which will perform the search
*/_search:function _search(params){var aDeferred=jQuery.Deferred();if("undefined"==typeof params&&(params={}),params.module=params.searchModule&&"-"!==params.searchModule?params.searchModule:app.getModuleName(),params.view="BasicAjax",params.mode="showSearchResults",params.limit=this.reduceNumberResults,params.html=this.returnHtml,app.getParentModuleName()&&(params.parent=app.getParentModuleName()),params.operator=CONFIG.globalSearchDefaultOperator,this.mainContainer){var operatorElement=this.mainContainer.find(".js-global-search-operator .active[data-operator]");operatorElement.length&&""!=operatorElement.data("operator")&&(params.operator=operatorElement.data("operator"));}return AppConnector.request(params).done(function(data){aDeferred.resolve(data);}).fail(function(error){aDeferred.reject(error);}),aDeferred.promise()},/**
* Helper function whicn invokes search
*/search:function search(value){var searchModule=this.getCurrentSearchModule(),params={};return params.value=value,"undefined"!=typeof searchModule&&!1!==searchModule?params.searchModule=searchModule:this.searchModule&&(params.searchModule=this.searchModule),this._search(params)},/**
* Function which shows the search results
*/showSearchResults:function showSearchResults(data){var aDeferred=jQuery.Deferred(),params={};return params.data=data,params.cb=function postLoad(data){aDeferred.resolve(data);},app.showModalWindow(params),aDeferred.promise()}});
//# sourceMappingURL=BasicSearch.min.js.map