first commit
This commit is contained in:
149
layouts/vlayout/modules/Settings/MailConverter/resources/Edit.js
Normal file
149
layouts/vlayout/modules/Settings/MailConverter/resources/Edit.js
Normal file
@@ -0,0 +1,149 @@
|
||||
/*+***********************************************************************************
|
||||
* 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.
|
||||
*************************************************************************************/
|
||||
jQuery.Class("Settings_MailConverter_Edit_Js",{
|
||||
|
||||
firstStep : function(e) {
|
||||
jQuery('form[name="step1"]').on('submit',function(e) {
|
||||
e.preventDefault();
|
||||
var validationEngineOptions = app.validationEngineOptions;
|
||||
validationEngineOptions['promptPosition'] = 'bottomRight',
|
||||
validationEngineOptions['onValidationComplete'] = function(form, isValid) {
|
||||
if(isValid){
|
||||
Settings_MailConverter_Edit_Js.saveMailBox();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var container = jQuery(e.currentTarget);
|
||||
container.validationEngine('attach',validationEngineOptions);
|
||||
});
|
||||
},
|
||||
|
||||
saveMailBox : function() {
|
||||
jQuery('form[name="step1"]').off('submit');
|
||||
var progressInstance = jQuery.progressIndicator({
|
||||
'position' : 'html',
|
||||
'blockInfo' : {
|
||||
'enabled' : true
|
||||
}
|
||||
});
|
||||
data = jQuery('form[name="step1"]').serialize();
|
||||
data.scannername = jQuery('input[name="scannername"]').val();
|
||||
data = data + '&module=' +app.getModuleName()+ '&parent=' + app.getParentModuleName()+ '&action=SaveMailBox';
|
||||
AppConnector.request(data).then(
|
||||
function(response){
|
||||
if(typeof response.result != 'undefined'){
|
||||
var create = jQuery("#create").val();
|
||||
window.location.href = "index.php?module="+app.getModuleName()+"&parent="+app.getParentModuleName()+"&view=Edit&mode=step2&create="+create+"&record="+response.result.id;
|
||||
} else {
|
||||
progressInstance.progressIndicator({
|
||||
'mode' : 'hide'
|
||||
});
|
||||
var params = {
|
||||
title : app.vtranslate('JS_MESSAGE'),
|
||||
text: response.error.message,
|
||||
animation: 'show',
|
||||
type: 'error'
|
||||
};
|
||||
Vtiger_Helper_Js.showPnotify(params);
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
secondStep : function(e) {
|
||||
jQuery('form[name="step2"]').submit(function(e) {
|
||||
e.preventDefault();
|
||||
var checked = jQuery("input[type=checkbox][name=folders]:checked").length;
|
||||
if(checked < 1) {
|
||||
var params = {
|
||||
title : app.vtranslate('JS_MESSAGE'),
|
||||
text: "You must select atleast one folder...",
|
||||
animation: 'show',
|
||||
type: 'error'
|
||||
};
|
||||
Vtiger_Helper_Js.showPnotify(params);
|
||||
return false;
|
||||
}
|
||||
var selectedFolders = jQuery('input[name=folders]:checked').map(function()
|
||||
{
|
||||
return jQuery(this).val();
|
||||
}).get();
|
||||
var response = Settings_MailConverter_Edit_Js.saveFolders(selectedFolders);
|
||||
});
|
||||
},
|
||||
|
||||
saveFolders : function(selectedFolders) {
|
||||
var progressIndicatorElement = jQuery.progressIndicator({
|
||||
'position' : 'html',
|
||||
'blockInfo' : {
|
||||
'enabled' : true
|
||||
}
|
||||
});
|
||||
var create = jQuery("#create").val();
|
||||
var id = jQuery("#recordId").val();
|
||||
var data = 'index.php?module='+app.getModuleName()+'&parent='+app.getParentModuleName()+'&action=SaveFolders&folders='+selectedFolders+'&create='+create+"&record="+id;
|
||||
AppConnector.request(data).then(
|
||||
function(response){
|
||||
progressIndicatorElement.progressIndicator({
|
||||
'mode' : 'hide'
|
||||
});
|
||||
if(typeof response.result != 'undefined'){
|
||||
if(create=="new")
|
||||
window.location.href = "index.php?module="+app.getModuleName()+"&parent="+app.getParentModuleName()+"&view=Edit&mode=step3&create="+create+"&record="+response.result.id;
|
||||
else
|
||||
window.location.href = "index.php?parent="+app.getParentModuleName()+"&module="+app.getModuleName()+"&view=List&record="+response.result.id;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
thirdStep : function(e) {
|
||||
jQuery('form[name="step3"]').submit(function(e) {
|
||||
e.preventDefault();
|
||||
Settings_MailConverter_Edit_Js.saveRule(e);
|
||||
});
|
||||
},
|
||||
|
||||
saveRule : function(e) {
|
||||
var form = jQuery(e.currentTarget);
|
||||
var progressIndicatorElement = jQuery.progressIndicator({
|
||||
'position' : 'html',
|
||||
'blockInfo' : {
|
||||
'enabled' : true
|
||||
}
|
||||
});
|
||||
var params = form.serializeFormData();
|
||||
params.record = "";
|
||||
AppConnector.request(params).then(function(data) {
|
||||
progressIndicatorElement.progressIndicator({
|
||||
'mode' : 'hide'
|
||||
});
|
||||
if(typeof data.result != 'undefined') {
|
||||
window.location.href = "index.php?parent="+app.getParentModuleName()+"&module="+app.getModuleName()+"&view=List&record="+data.result.scannerId;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/*
|
||||
* Function to activate the header based on the class
|
||||
* @params class name
|
||||
*/
|
||||
activateHeader : function() {
|
||||
var step = jQuery("#step").val();
|
||||
jQuery('#'+step).addClass('active');
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
registerEvents : function() {
|
||||
Settings_MailConverter_Edit_Js.firstStep();
|
||||
Settings_MailConverter_Edit_Js.activateHeader();
|
||||
jQuery('form[name="step1"]').validationEngine(app.validationEngineOptions);
|
||||
}
|
||||
});
|
||||
132
layouts/vlayout/modules/Settings/MailConverter/resources/List.js
Normal file
132
layouts/vlayout/modules/Settings/MailConverter/resources/List.js
Normal file
@@ -0,0 +1,132 @@
|
||||
/*+***********************************************************************************
|
||||
* 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.
|
||||
*************************************************************************************/
|
||||
|
||||
jQuery.Class('Settings_MailConverter_List_Js',{
|
||||
|
||||
checkMailBoxMaxLimit : function(url) {
|
||||
AppConnector.request(url).then(
|
||||
function(response) {
|
||||
if(typeof response.result != 'undefined'){
|
||||
window.location.href = 'index.php?module='+app.getModuleName()+'&parent='+app.getParentModuleName()+'&view=Edit&mode=step1&create=new';
|
||||
} else {
|
||||
var params = {
|
||||
title : app.vtranslate('JS_MESSAGE'),
|
||||
text: response.error.message,
|
||||
animation: 'show',
|
||||
type: 'info'
|
||||
};
|
||||
Vtiger_Helper_Js.showPnotify(params);
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
},
|
||||
|
||||
triggerScan : function(url) {
|
||||
var progressIndicatorElement = jQuery.progressIndicator({
|
||||
'position' : 'html',
|
||||
'blockInfo' : {
|
||||
'enabled' : true
|
||||
}
|
||||
});
|
||||
AppConnector.request(url).then(
|
||||
function(response) {
|
||||
if(typeof response.result != 'undefined'){
|
||||
var params = {};
|
||||
params.record = response.result.id;
|
||||
Settings_MailConverter_List_Js.loadMailBox(params);
|
||||
} else {
|
||||
var params = {
|
||||
title : app.vtranslate('JS_MESSAGE'),
|
||||
text: response.error.message,
|
||||
animation: 'show',
|
||||
type: 'error'
|
||||
};
|
||||
Vtiger_Helper_Js.showPnotify(params);
|
||||
}
|
||||
progressIndicatorElement.progressIndicator({
|
||||
'mode' : 'hide'
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
|
||||
triggerDelete : function(url) {
|
||||
|
||||
Vtiger_Helper_Js.showConfirmationBox({'message':app.vtranslate('LBL_DELETE_CONFIRMATION')}).then(function(){
|
||||
var progressIndicatorElement = jQuery.progressIndicator({
|
||||
'position' : 'html',
|
||||
'blockInfo' : {
|
||||
'enabled' : true
|
||||
}
|
||||
});
|
||||
AppConnector.request(url).then(function(data){
|
||||
progressIndicatorElement.progressIndicator({
|
||||
'mode' : 'hide'
|
||||
});
|
||||
var deletedRecordId = data.result.id;
|
||||
var deletedRecordContainerId = 'SCANNER_'+deletedRecordId;
|
||||
jQuery('#'+deletedRecordContainerId).remove();
|
||||
var params = {
|
||||
title : app.vtranslate('JS_MESSAGE'),
|
||||
text: app.vtranslate('JS_MAILBOX_DELETED_SUCCESSFULLY'),
|
||||
animation: 'show',
|
||||
type: 'success'
|
||||
};
|
||||
var url = window.location.href;
|
||||
var url1 = url.split('&');
|
||||
var path = url1[0]+"&"+url1[1]+"&"+url1[2];
|
||||
window.location.assign(path);
|
||||
Vtiger_Helper_Js.showPnotify(params);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
loadMailBox : function(data) {
|
||||
var progressIndicatorElement = jQuery.progressIndicator({
|
||||
'position' : 'html',
|
||||
'blockInfo' : {
|
||||
'enabled' : true
|
||||
}
|
||||
});
|
||||
data.module = app.getModuleName();
|
||||
data.parent = app.getParentModuleName();
|
||||
data.view = "ListAjax";
|
||||
data.mode = 'getMailBoxContentView'
|
||||
AppConnector.request(data).then(
|
||||
function(html) {
|
||||
var scannerContentdId = "SCANNER_"+data.record;
|
||||
if(jQuery('#'+scannerContentdId).length > 0) {
|
||||
jQuery('#'+scannerContentdId).html(html)
|
||||
}else{
|
||||
jQuery('#listViewContents').append('<br>'+html);
|
||||
}
|
||||
progressIndicatorElement.progressIndicator({
|
||||
'mode' : 'hide'
|
||||
});
|
||||
var params = {
|
||||
title : app.vtranslate('JS_MESSAGE'),
|
||||
text: app.vtranslate('JS_MAILBOX_LOADED_SUCCESSFULLY'),
|
||||
animation: 'show',
|
||||
type: 'success'
|
||||
};
|
||||
Vtiger_Helper_Js.showPnotify(params);
|
||||
if(typeof data.listViewUrl != 'undefined') {
|
||||
var path = data.listViewUrl+'&record='+data.record;
|
||||
window.location.assign(path);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
},{
|
||||
registerEvents : function(){
|
||||
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,217 @@
|
||||
/*+***********************************************************************************
|
||||
* 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.
|
||||
*************************************************************************************/
|
||||
|
||||
jQuery.Class('Settings_MailConverter_Index_Js',{
|
||||
|
||||
mailConverterInstance : false,
|
||||
|
||||
triggerRuleEdit : function(url){
|
||||
AppConnector.request(url).then(function(data){
|
||||
var callBackFunction = function(data) {
|
||||
var mcInstance = Settings_MailConverter_Index_Js.mailConverterInstance;
|
||||
mcInstance.saveRuleEvent();
|
||||
mcInstance.setAssignedTo();
|
||||
jQuery("#actions").change();
|
||||
jQuery('#ruleSave').validationEngine(app.validationEngineOptions);
|
||||
}
|
||||
app.showModalWindow(data,function(data){
|
||||
if(typeof callBackFunction == 'function'){
|
||||
callBackFunction(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
triggerDeleteRule : function(currentElement,url){
|
||||
var deleteElement = jQuery(currentElement);
|
||||
var message = app.vtranslate('LBL_DELETE_CONFIRMATION');
|
||||
Vtiger_Helper_Js.showConfirmationBox({
|
||||
'message' : message
|
||||
}).then(
|
||||
function(e) {
|
||||
AppConnector.request(url).then(function(data){
|
||||
if(data.result){
|
||||
var closestBlock = deleteElement.closest('[data-blockid]');
|
||||
var nextBlocks = closestBlock.nextAll('[data-blockid]');
|
||||
if(nextBlocks.length > 0){
|
||||
jQuery.each(nextBlocks,function(i,element) {
|
||||
var currentSequenceElement = jQuery(element).find('.sequenceNumber');
|
||||
var updatedNumber = parseInt(currentSequenceElement.text())-1;
|
||||
currentSequenceElement.text(updatedNumber);
|
||||
});
|
||||
}
|
||||
closestBlock.remove();
|
||||
var params = {
|
||||
title : app.vtranslate('JS_MESSAGE'),
|
||||
text: data.result,
|
||||
animation: 'show',
|
||||
type: 'success'
|
||||
};
|
||||
Vtiger_Helper_Js.showPnotify(params);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
},{
|
||||
|
||||
registerSortableEvent : function() {
|
||||
var thisInstance = this;
|
||||
var sequenceList = {};
|
||||
var container = jQuery( "#rulesList");
|
||||
container.sortable({
|
||||
'revert' : true,
|
||||
handle : '.blockHeader',
|
||||
start: function (event, ui) {
|
||||
ui.placeholder.height(ui.helper.height());
|
||||
},
|
||||
update: function(e, ui ) {
|
||||
|
||||
jQuery('[data-blockid]',container).each(function(i){
|
||||
sequenceList[++i] = jQuery(this).data('id');
|
||||
});
|
||||
var params = {
|
||||
sequencesList : JSON.stringify(sequenceList),
|
||||
module : app.getModuleName(),
|
||||
parent : app.getParentModuleName(),
|
||||
action : 'UpdateSequence',
|
||||
scannerId : jQuery('#scannerId').val()
|
||||
}
|
||||
AppConnector.request(params).then(function(data) {
|
||||
if(typeof data.result != 'undefined'){
|
||||
jQuery('[data-blockid]',container).each(function(i){
|
||||
jQuery(this).find('.sequenceNumber').text(++i);
|
||||
});
|
||||
app.hideModalWindow();
|
||||
var params = {
|
||||
title : app.vtranslate('JS_MESSAGE'),
|
||||
text: data.result,
|
||||
animation: 'show',
|
||||
type: 'success'
|
||||
};
|
||||
Vtiger_Helper_Js.showPnotify(params);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
saveRuleEvent : function() {
|
||||
var thisInstance = this;
|
||||
jQuery('#ruleSave').on('submit',function(e){
|
||||
var form = jQuery(e.currentTarget);
|
||||
var validationResult = form.validationEngine('validate');
|
||||
var progressIndicatorElement = jQuery.progressIndicator({
|
||||
'position' : 'html',
|
||||
'blockInfo' : {
|
||||
'enabled' : true
|
||||
}
|
||||
});
|
||||
if(validationResult == true) {
|
||||
var params = form.serializeFormData();
|
||||
app.hideModalWindow();
|
||||
AppConnector.request(params).then(function(data) {
|
||||
progressIndicatorElement.progressIndicator({
|
||||
'mode' : 'hide'
|
||||
})
|
||||
if(typeof data.result != 'undefined') {
|
||||
var params = {
|
||||
module : app.getModuleName(),
|
||||
parent : app.getParentModuleName(),
|
||||
scannerId : jQuery('[name="scannerId"]',form).val(),
|
||||
record : data.result.id,
|
||||
view : 'RuleAjax'
|
||||
}
|
||||
thisInstance.getRule(params);
|
||||
|
||||
var params = {
|
||||
title : app.vtranslate('JS_MESSAGE'),
|
||||
text: data.result.message,
|
||||
animation: 'show',
|
||||
type: 'success'
|
||||
};
|
||||
Vtiger_Helper_Js.showPnotify(params);
|
||||
}
|
||||
});
|
||||
}
|
||||
e.preventDefault();
|
||||
});
|
||||
},
|
||||
|
||||
setAssignedTo : function() {
|
||||
jQuery("#actions").change(function() {
|
||||
var selectedAction = jQuery("#actions").val();
|
||||
if(!(selectedAction=="CREATE_HelpDesk_FROM" || selectedAction=="CREATE_Leads_SUBJECT" || selectedAction=="CREATE_Contacts_SUBJECT" || selectedAction=="CREATE_Accounts_SUBJECT")) {
|
||||
jQuery("#assignedTo").val("");
|
||||
jQuery("#assignedToBlock").hide();
|
||||
} else {
|
||||
jQuery("#assignedToBlock").show();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
openMailBox : function() {
|
||||
jQuery(".mailBoxDropdown").change(function() {
|
||||
var id = jQuery(".mailBoxDropdown option:selected").val();
|
||||
var path = "index.php?parent=" + app.getParentModuleName() + "&module=" + app.getModuleName() + "&view=List&record=" + id;
|
||||
window.location.assign(path);
|
||||
});
|
||||
},
|
||||
|
||||
disableFolderSelection : function() {
|
||||
var checked = jQuery("input[type=checkbox][name=folders]:checked").length >= 2;
|
||||
jQuery("input[type=checkbox][name=folders]").not(":checked").attr("disabled", checked);
|
||||
|
||||
jQuery("input[type=checkbox][name=folders]").click(function() {
|
||||
var checked = jQuery("input[type=checkbox][name=folders]:checked").length >= 2;
|
||||
jQuery("input[type=checkbox][name=folders]").not(":checked").attr("disabled", checked);
|
||||
});
|
||||
},
|
||||
|
||||
getRule : function(params) {
|
||||
var progressIndicatorElement = jQuery.progressIndicator({
|
||||
'position' : 'html',
|
||||
'blockInfo' : {
|
||||
'enabled' : true
|
||||
}
|
||||
});
|
||||
var ruleId = params.record;
|
||||
AppConnector.request(params).then(function(data){
|
||||
progressIndicatorElement.progressIndicator({
|
||||
'mode' : 'hide'
|
||||
})
|
||||
var currentBlock = jQuery('[data-blockid="block_'+ruleId+'"]')
|
||||
if(currentBlock.length > 0){
|
||||
var previousValue = currentBlock.prevAll('[data-blockid]').first().find('.sequenceNumber').text();
|
||||
if(previousValue == '') {
|
||||
previousValue = 0;
|
||||
}
|
||||
currentBlock.html(data);
|
||||
currentBlock.find('.sequenceNumber').text(parseInt(previousValue)+1)
|
||||
} else {
|
||||
var lastBlockValue = jQuery('[data-blockid]').size();
|
||||
jQuery('#rulesList').append('<div class="row-fluid padding-bottom1per" data-blockid="block_'+ruleId+'">'+data+'</div>');
|
||||
jQuery('[data-blockid="block_'+ruleId+'"]').find('.sequenceNumber').text(parseInt(lastBlockValue)+1);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
registerEvents : function() {
|
||||
this.registerSortableEvent();
|
||||
this.openMailBox();
|
||||
this.setAssignedTo();
|
||||
this.disableFolderSelection();
|
||||
}
|
||||
});
|
||||
|
||||
//On Page Load
|
||||
jQuery(document).ready(function() {
|
||||
var mcInstance = Settings_MailConverter_Index_Js.mailConverterInstance = new Settings_MailConverter_Index_Js();
|
||||
mcInstance.registerEvents();
|
||||
});
|
||||
Reference in New Issue
Block a user