[ 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 10 jQuery.Class('Settings_MailConverter_Index_Js',{ 11 12 mailConverterInstance : false, 13 14 triggerRuleEdit : function(url){ 15 AppConnector.request(url).then(function(data){ 16 var callBackFunction = function(data) { 17 var mcInstance = Settings_MailConverter_Index_Js.mailConverterInstance; 18 mcInstance.saveRuleEvent(); 19 mcInstance.setAssignedTo(); 20 jQuery("#actions").change(); 21 jQuery('#ruleSave').validationEngine(app.validationEngineOptions); 22 } 23 app.showModalWindow(data,function(data){ 24 if(typeof callBackFunction == 'function'){ 25 callBackFunction(data); 26 } 27 }); 28 }); 29 }, 30 31 triggerDeleteRule : function(currentElement,url){ 32 var deleteElement = jQuery(currentElement); 33 var message = app.vtranslate('LBL_DELETE_CONFIRMATION'); 34 Vtiger_Helper_Js.showConfirmationBox({ 35 'message' : message 36 }).then( 37 function(e) { 38 AppConnector.request(url).then(function(data){ 39 if(data.result){ 40 var closestBlock = deleteElement.closest('[data-blockid]'); 41 var nextBlocks = closestBlock.nextAll('[data-blockid]'); 42 if(nextBlocks.length > 0){ 43 jQuery.each(nextBlocks,function(i,element) { 44 var currentSequenceElement = jQuery(element).find('.sequenceNumber'); 45 var updatedNumber = parseInt(currentSequenceElement.text())-1; 46 currentSequenceElement.text(updatedNumber); 47 }); 48 } 49 closestBlock.remove(); 50 var params = { 51 title : app.vtranslate('JS_MESSAGE'), 52 text: data.result, 53 animation: 'show', 54 type: 'success' 55 }; 56 Vtiger_Helper_Js.showPnotify(params); 57 } 58 59 }); 60 }); 61 } 62 },{ 63 64 registerSortableEvent : function() { 65 var thisInstance = this; 66 var sequenceList = {}; 67 var container = jQuery( "#rulesList"); 68 container.sortable({ 69 'revert' : true, 70 handle : '.blockHeader', 71 start: function (event, ui) { 72 ui.placeholder.height(ui.helper.height()); 73 }, 74 update: function(e, ui ) { 75 76 jQuery('[data-blockid]',container).each(function(i){ 77 sequenceList[++i] = jQuery(this).data('id'); 78 }); 79 var params = { 80 sequencesList : JSON.stringify(sequenceList), 81 module : app.getModuleName(), 82 parent : app.getParentModuleName(), 83 action : 'UpdateSequence', 84 scannerId : jQuery('#scannerId').val() 85 } 86 AppConnector.request(params).then(function(data) { 87 if(typeof data.result != 'undefined'){ 88 jQuery('[data-blockid]',container).each(function(i){ 89 jQuery(this).find('.sequenceNumber').text(++i); 90 }); 91 app.hideModalWindow(); 92 var params = { 93 title : app.vtranslate('JS_MESSAGE'), 94 text: data.result, 95 animation: 'show', 96 type: 'success' 97 }; 98 Vtiger_Helper_Js.showPnotify(params); 99 } 100 }); 101 } 102 }); 103 }, 104 105 saveRuleEvent : function() { 106 var thisInstance = this; 107 jQuery('#ruleSave').on('submit',function(e){ 108 var form = jQuery(e.currentTarget); 109 var validationResult = form.validationEngine('validate'); 110 var progressIndicatorElement = jQuery.progressIndicator({ 111 'position' : 'html', 112 'blockInfo' : { 113 'enabled' : true 114 } 115 }); 116 if(validationResult == true) { 117 var params = form.serializeFormData(); 118 app.hideModalWindow(); 119 AppConnector.request(params).then(function(data) { 120 progressIndicatorElement.progressIndicator({ 121 'mode' : 'hide' 122 }) 123 if(typeof data.result != 'undefined') { 124 var params = { 125 module : app.getModuleName(), 126 parent : app.getParentModuleName(), 127 scannerId : jQuery('[name="scannerId"]',form).val(), 128 record : data.result.id, 129 view : 'RuleAjax' 130 } 131 thisInstance.getRule(params); 132 133 var params = { 134 title : app.vtranslate('JS_MESSAGE'), 135 text: data.result.message, 136 animation: 'show', 137 type: 'success' 138 }; 139 Vtiger_Helper_Js.showPnotify(params); 140 } 141 }); 142 } 143 e.preventDefault(); 144 }); 145 }, 146 147 setAssignedTo : function() { 148 jQuery("#actions").change(function() { 149 var selectedAction = jQuery("#actions").val(); 150 if(!(selectedAction=="CREATE_HelpDesk_FROM" || selectedAction=="CREATE_Leads_SUBJECT" || selectedAction=="CREATE_Contacts_SUBJECT" || selectedAction=="CREATE_Accounts_SUBJECT")) { 151 jQuery("#assignedTo").val(""); 152 jQuery("#assignedToBlock").hide(); 153 } else { 154 jQuery("#assignedToBlock").show(); 155 } 156 }); 157 }, 158 159 openMailBox : function() { 160 jQuery(".mailBoxDropdown").change(function() { 161 var id = jQuery(".mailBoxDropdown option:selected").val(); 162 var path = "index.php?parent=" + app.getParentModuleName() + "&module=" + app.getModuleName() + "&view=List&record=" + id; 163 window.location.assign(path); 164 }); 165 }, 166 167 disableFolderSelection : function() { 168 var checked = jQuery("input[type=checkbox][name=folders]:checked").length >= 2; 169 jQuery("input[type=checkbox][name=folders]").not(":checked").attr("disabled", checked); 170 171 jQuery("input[type=checkbox][name=folders]").click(function() { 172 var checked = jQuery("input[type=checkbox][name=folders]:checked").length >= 2; 173 jQuery("input[type=checkbox][name=folders]").not(":checked").attr("disabled", checked); 174 }); 175 }, 176 177 getRule : function(params) { 178 var progressIndicatorElement = jQuery.progressIndicator({ 179 'position' : 'html', 180 'blockInfo' : { 181 'enabled' : true 182 } 183 }); 184 var ruleId = params.record; 185 AppConnector.request(params).then(function(data){ 186 progressIndicatorElement.progressIndicator({ 187 'mode' : 'hide' 188 }) 189 var currentBlock = jQuery('[data-blockid="block_'+ruleId+'"]') 190 if(currentBlock.length > 0){ 191 var previousValue = currentBlock.prevAll('[data-blockid]').first().find('.sequenceNumber').text(); 192 if(previousValue == '') { 193 previousValue = 0; 194 } 195 currentBlock.html(data); 196 currentBlock.find('.sequenceNumber').text(parseInt(previousValue)+1) 197 } else { 198 var lastBlockValue = jQuery('[data-blockid]').size(); 199 jQuery('#rulesList').append('<div class="row-fluid padding-bottom1per" data-blockid="block_'+ruleId+'">'+data+'</div>'); 200 jQuery('[data-blockid="block_'+ruleId+'"]').find('.sequenceNumber').text(parseInt(lastBlockValue)+1); 201 } 202 }); 203 }, 204 205 registerEvents : function() { 206 this.registerSortableEvent(); 207 this.openMailBox(); 208 this.setAssignedTo(); 209 this.disableFolderSelection(); 210 } 211 }); 212 213 //On Page Load 214 jQuery(document).ready(function() { 215 var mcInstance = Settings_MailConverter_Index_Js.mailConverterInstance = new Settings_MailConverter_Index_Js(); 216 mcInstance.registerEvents(); 217 });
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 |