[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 /*+*********************************************************************************** 2 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 3 * ("License"); You may not use this file except in compliance with the License 4 * The Original Code is: vtiger CRM Open Source 5 * The Initial Developer of the Original Code is vtiger. 6 * Portions created by vtiger are Copyright (C) vtiger. 7 * All Rights Reserved. 8 *************************************************************************************/ 9 Reports_Edit3_Js("Reports_ChartEdit3_Js",{ 10 11 registerFieldForChosen : function() { 12 app.changeSelectElementView(jQuery('#groupbyfield'), 'select2'); 13 app.changeSelectElementView(jQuery('#datafields'), 'select2'); 14 }, 15 16 initSelectValues : function() { 17 var groupByField = jQuery('#groupbyfield'); 18 var dataFields = jQuery('#datafields'); 19 20 var groupByFieldValue = jQuery('input[name=groupbyfield]').val(); 21 var dataFieldsValue = jQuery('input[name=datafields]').val(); 22 23 var groupByHTML = jQuery('#groupbyfield_element').clone().html(); 24 var dataFieldsHTML = jQuery('#datafields_element').clone().html(); 25 26 groupByField.html(groupByHTML); 27 dataFields.html(dataFieldsHTML); 28 29 if(dataFieldsValue) 30 dataFieldsValue = JSON.parse(dataFieldsValue); 31 32 var selectedChartType = jQuery('input[name=charttype]').val(); 33 34 groupByField.select2().select2("val", groupByFieldValue); 35 36 if(selectedChartType == 'pieChart') { 37 dataFields.attr('multiple', false).select2().select2("val", dataFieldsValue); 38 } else if(dataFieldsValue && dataFieldsValue[0]) { 39 dataFields.attr('multiple', true).select2({maximumSelectionSize: 3, closeOnSelect: false}).select2("val", dataFieldsValue); 40 } 41 42 if(selectedChartType) { 43 jQuery('ul[name=charttab] li.active').removeClass('active'); 44 jQuery('ul[name=charttab] li a[data-type='+selectedChartType+']').addClass('active contentsBackground backgroundColor').trigger('click'); 45 } else { 46 jQuery('ul[name=charttab] li a[data-type=pieChart]').addClass('contentsBackground backgroundColor').trigger('click'); // by default piechart should be selected 47 } 48 } 49 50 },{ 51 initialize : function(container) { 52 if(typeof container == 'undefined') { 53 container = jQuery('#chart_report_step3'); 54 } 55 if(container.is('#chart_report_step3')) { 56 this.setContainer(container); 57 } else { 58 this.setContainer(jQuery('#chart_report_step3')); 59 } 60 }, 61 62 registerForChartTabClick : function() { 63 var dataFields = jQuery('#datafields'); 64 65 jQuery('ul[name=charttab] li a').on('click', function(e){ 66 var chartType = jQuery(e.currentTarget).data('type'); 67 if(chartType == 'pieChart') { 68 dataFields.attr('multiple', false).select2().select2("val", ""); 69 } else { 70 dataFields.attr('multiple', true).select2({maximumSelectionSize: 3}); 71 } 72 jQuery('input[name=charttype]').val(chartType); 73 jQuery('ul[name=charttab] li.active a').removeClass('contentsBackground backgroundColor'); 74 jQuery(this).addClass('contentsBackground backgroundColor'); 75 }); 76 }, 77 78 calculateValues : function(){ 79 //handled advanced filters saved values. 80 var advfilterlist = jQuery('#advanced_filter','#chart_report_step2').val();// value from step2 81 jQuery('#advanced_filter','#chart_report_step3').val(advfilterlist); 82 }, 83 84 registerSubmitEvent : function() { 85 var thisInstance = this; 86 jQuery('#generateReport').on('click', function(e) { 87 var legend = jQuery('#groupbyfield').val(); 88 var sector = jQuery('#datafields').val(); 89 var form = thisInstance.getContainer(); 90 if(sector != '' && legend != '') { 91 jQuery('#s2id_groupbyfield').validationEngine('hideAll'); 92 form.submit(); 93 } else { 94 jQuery('#s2id_groupbyfield').validationEngine('showPrompt',app.vtranslate('JS_PLEASE_SELECT_ATLEAST_ONE_OPTION'),'',"bottomRight",true); 95 e.preventDefault(); 96 } 97 }); 98 }, 99 100 registerEvents : function(){ 101 this._super(); 102 this.calculateValues(); 103 this.registerForChartTabClick(); 104 Reports_ChartEdit3_Js.registerFieldForChosen(); 105 Reports_ChartEdit3_Js.initSelectValues(); 106 } 107 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |