[ 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 jQuery.Class('Settings_Module_Manager_Js', { 10 }, { 11 12 /* 13 * function to update the module status for the module 14 * @params: currentTarget - checkbox related to module. 15 */ 16 updateModuleStatus : function(currentTarget) { 17 var aDeferred = jQuery.Deferred(); 18 var forModule = currentTarget.data('module'); 19 var status = currentTarget.is(':checked'); 20 21 var progressIndicatorElement = jQuery.progressIndicator({ 22 'position' : 'html', 23 'blockInfo' : { 24 'enabled' : true 25 } 26 }); 27 28 var params = {} 29 params['module'] = app.getModuleName(); 30 params['parent'] = app.getParentModuleName(); 31 params['updateStatus'] = status; 32 params['forModule'] = forModule 33 params['action'] = 'Basic'; 34 params['mode'] = 'updateModuleStatus'; 35 36 AppConnector.request(params).then( 37 function(data) { 38 progressIndicatorElement.progressIndicator({'mode' : 'hide'}); 39 aDeferred.resolve(data); 40 }, 41 function(error) { 42 progressIndicatorElement.progressIndicator({'mode' : 'hide'}); 43 //TODO : Handle error 44 aDeferred.reject(error); 45 } 46 ); 47 return aDeferred.promise(); 48 }, 49 50 //This will show the notification message using pnotify 51 showNotify : function(customParams) { 52 var params = { 53 title : app.vtranslate('JS_MESSAGE'), 54 text: customParams.text, 55 animation: 'show', 56 type: 'info' 57 }; 58 Vtiger_Helper_Js.showPnotify(params); 59 }, 60 61 62 registerEventsForImportFromZip : function(container) { 63 container.on('change','[ name="acceptDisclaimer"]', function(e){ 64 var element = jQuery(e.currentTarget); 65 var importFromZip = container.find('[name="importFromZip"]'); 66 var uploadedFile = jQuery('#moduleZip').val(); 67 var disabledStatus = importFromZip.attr('disabled'); 68 if((element.is(':checked')) && (uploadedFile != '')){ 69 if(typeof disabledStatus != "undefined"){ 70 importFromZip.removeAttr('disabled'); 71 } 72 } else { 73 if(typeof disabledStatus == "undefined"){ 74 importFromZip.attr('disabled', "disabled"); 75 } 76 } 77 }); 78 79 container.on('change','[name="moduleZip"]', function(){ 80 container.find('[ name="acceptDisclaimer"]').trigger('click'); 81 }); 82 83 container.on('click','.importModule,.updateModule',function(e){ 84 var element = jQuery(e.currentTarget); 85 var params = {}; 86 if(element.hasClass('updateModule')){ 87 params = { 88 'module' : app.getModuleName(), 89 'parent' : app.getParentModuleName(), 90 'action' : 'Basic', 91 'mode' : 'updateUserModuleStep3' 92 }; 93 } else if(element.hasClass('importModule')){ 94 params = { 95 'module' : app.getModuleName(), 96 'parent' : app.getParentModuleName(), 97 'action' : 'Basic', 98 'mode' : 'importUserModuleStep3' 99 }; 100 } 101 params['module_import_file'] = container.find('[name="module_import_file"]').val(); 102 params['module_import_type'] = container.find('[name="module_import_type"]').val(); 103 params['module_import_name'] = container.find('[name="module_import_name"]').val(); 104 105 var progressIndicatorElement = jQuery.progressIndicator({ 106 'position' : 'html', 107 'blockInfo' : { 108 'enabled' : true 109 } 110 }); 111 112 AppConnector.request(params).then( 113 function(data) { 114 progressIndicatorElement.progressIndicator({'mode' : 'hide'}); 115 element.addClass('hide'); 116 var importModuleName = data.result.importModuleName; 117 var importStatusModal = jQuery(container).find('.importStatusModal').clone(true, true); 118 importStatusModal.removeClass('hide'); 119 var headerMessage, containerMessage; 120 121 if(element.hasClass('updateModule')){ 122 headerMessage = app.vtranslate('JS_UPDATE_SUCCESSFULL'); 123 containerMessage = app.vtranslate('JS_UPDATED_MODULE'); 124 } else if(element.hasClass('importModule')){ 125 headerMessage = app.vtranslate('JS_IMPORT_SUCCESSFULL'); 126 containerMessage = app.vtranslate('JS_IMPORTED_MODULE'); 127 } 128 129 var callBackFunction = function(data) { 130 data.find('.statusHeader').html(headerMessage); 131 data.find('.statusContainer').html(importModuleName + ' ' + containerMessage); 132 }; 133 134 app.showModalWindow(importStatusModal,function(data) { 135 if(typeof callBackFunction == 'function') { 136 callBackFunction(data); 137 }}, {'width':'1000px'}); 138 }, 139 function(error) { 140 progressIndicatorElement.progressIndicator({'mode' : 'hide'}); 141 } 142 ); 143 144 }); 145 146 container.on('click','.acceptLicense', function(e){ 147 var element = jQuery(e.currentTarget); 148 var saveButton = container.find('[name="saveButton"]') 149 if(element.is(':checked')){ 150 saveButton.removeAttr("disabled"); 151 } else { 152 if(typeof saveButton.attr('disabled') == 'undefined'){ 153 saveButton.attr('disabled',"disabled"); 154 } 155 } 156 }); 157 }, 158 159 registerEvents : function(e){ 160 var thisInstance = this; 161 var container = jQuery('#moduleManagerContents'); 162 var importFromZipContainer = jQuery('#importModules'); 163 if(importFromZipContainer.length > 0){ 164 thisInstance.registerEventsForImportFromZip(importFromZipContainer); 165 } 166 167 //register click event for check box to update the module status 168 container.on('click', '[name="moduleStatus"]', function(e){ 169 var currentTarget = jQuery(e.currentTarget); 170 var moduleBlock = currentTarget.closest('.moduleManagerBlock'); 171 var actionButtons = moduleBlock.find('.actions'); 172 var forModule = currentTarget.data('moduleTranslation'); 173 var moduleDetails = moduleBlock.find('.moduleImage, .moduleName'); 174 175 if(currentTarget.is(':checked')){ 176 //show the settings button for the module. 177 actionButtons.removeClass('hide'); 178 179 //changing opacity of the block if the module is enabled 180 moduleDetails.removeClass('dull'); 181 182 //update the module status as enabled 183 thisInstance.updateModuleStatus(currentTarget).then( 184 function(data) { 185 var params = { 186 text: forModule+' '+app.vtranslate('JS_MODULE_ENABLED') 187 } 188 thisInstance.showNotify(params); 189 }, 190 function(error){ 191 //TODO: Handle Error 192 } 193 ); 194 195 } else { 196 //hide the settings button for the module. 197 actionButtons.addClass('hide'); 198 199 //changing opacity of the block if the module is disabled 200 moduleDetails.addClass('dull'); 201 202 //update the module status as disabled 203 thisInstance.updateModuleStatus(currentTarget).then( 204 function(data) { 205 var params = { 206 text: forModule+' '+app.vtranslate('JS_MODULE_DISABLED') 207 } 208 thisInstance.showNotify(params); 209 }, 210 function(error){ 211 //TODO: Handle Error 212 } 213 ); 214 } 215 216 }); 217 } 218 }); 219 220 221 jQuery(document).ready(function(){ 222 var settingModuleManagerInstance = new Settings_Module_Manager_Js(); 223 settingModuleManagerInstance.registerEvents(); 224 })
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 |