From 39260478a28b4fa2fad50ee5b8263be1d979e9ee Mon Sep 17 00:00:00 2001 From: Mariusz Krzaczkowski Date: Mon, 31 Jul 2017 15:18:04 +0200 Subject: [PATCH] Fixed integration actions with mail --- plugins/yetiforce/preview.js | 634 +++++++++++++++---------------- plugins/yetiforce/preview.min.js | 2 +- version.php | 4 +- 3 files changed, 320 insertions(+), 320 deletions(-) diff --git a/plugins/yetiforce/preview.js b/plugins/yetiforce/preview.js index a4c06ec7..01a6a1cc 100644 --- a/plugins/yetiforce/preview.js +++ b/plugins/yetiforce/preview.js @@ -1,317 +1,317 @@ -/* {[The file is published on the basis of YetiForce Public License that can be found in the following directory: licenses/License.html]} */ -window.rcmail && rcmail.addEventListener('init', function (evt) { - window.crm = getCrmWindow(); - loadActionBar(); - rcmail.env.message_commands.push('yetiforce.importICS'); - rcmail.register_command('yetiforce.importICS', function (ics, element, e) { - window.crm.AppConnector.request({ - async: true, - dataType: 'json', - data: { - module: 'Calendar', - action: 'ImportICS', - ics: ics - } - }).then(function (response) { - window.crm.Vtiger_Helper_Js.showPnotify({ - text: response['result'], - type: 'info', - animation: 'show' - }); - $(element).closest('.icalattachments').remove(); - }) - }, true); -} -); -function loadActionBar() { - var content = $('#ytActionBarContent'); - var params = { - module: 'OSSMail', - view: 'MailActionBar', - uid: rcmail.env.uid, - folder: rcmail.env.mailbox, - rcId: rcmail.env.user_id - }; - window.crm.AppConnector.request(params).then(function (response) { - content.find('.ytHeader').html(response); - $('#messagecontent').css('top', (content.outerHeight() + $('#messageheader').outerHeight()) + 'px'); - registerEvents(content); - }); -} -function registerEvents(content) { - registerAddRecord(content); - registerAddReletedRecord(content); - registerSelectRecord(content); - registerRemoveRecord(content); - registerImportMail(content); - - var block = content.find('.ytHeader .data'); - content.find('.hideBtn').click(function () { - var button = $(this); - var icon = button.find('.glyphicon'); - - if (button.data('type') == '0') { - button.data('type', '1'); - icon.removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down"); - } else { - button.data('type', '0'); - icon.removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up"); - } - block.toggle(); - $(window).trigger("resize"); - }); -} -function registerImportMail(content) { - content.find('.importMail').click(function (e) { - window.crm.Vtiger_Helper_Js.showPnotify({ - text: window.crm.app.vtranslate('StartedDownloadingEmail'), - type: 'info' - }); - window.crm.AppConnector.request({ - module: 'OSSMail', - action: 'ImportMail', - params: { - uid: rcmail.env.uid, - folder: rcmail.env.mailbox, - rcId: rcmail.env.user_id - } - }).then(function (data) { - loadActionBar(); - window.crm.Vtiger_Helper_Js.showPnotify({ - text: window.crm.app.vtranslate('AddFindEmailInRecord'), - type: 'success' - }); - }) - }); -} -function registerRemoveRecord(content) { - content.find('button.removeRecord').click(function (e) { - var row = $(e.currentTarget).closest('.rowReletedRecord'); - removeRecord(row.data('id')); - }); -} -function registerSelectRecord(content) { - var id = content.find('#mailActionBarID').val(); - content.find('button.selectRecord').click(function (e) { - var sourceFieldElement = jQuery('input[name="tempField"]'); - var relParams = { - mailId: id - }; - if ($(this).data('type') == 0) { - var module = $(this).closest('.col').find('.module').val(); - } else { - var module = $(this).data('module'); - relParams.crmid = $(this).closest('.rowReletedRecord').data('id'); - relParams.mod = $(this).closest('.rowReletedRecord').data('module'); - relParams.newModule = module; - } - var PopupParams = { - module: module, - src_module: module, - src_field: 'tempField', - src_record: '', - url: rcmail.env.site_URL + 'index.php?' - }; - showPopup(PopupParams, sourceFieldElement, relParams); - }); -} -function registerAddReletedRecord(content) { - var id = content.find('#mailActionBarID').val(); - content.find('button.addReletedRecord').click(function (e) { - var targetElement = $(e.currentTarget); - var row = targetElement.closest('.rowReletedRecord'); - var params = {sourceModule: row.data('module')}; - showQuickCreateForm(targetElement.data('module'), row.data('id'), params); - }); -} -function registerAddRecord(content) { - var id = content.find('#mailActionBarID').val(); - content.find('button.addRecord').click(function (e) { - var col = $(e.currentTarget).closest('.col'); - showQuickCreateForm(col.find('.module').val(), id); - }); -} -function removeRecord(crmid) { - var id = $('#mailActionBarID').val(); - var params = {} - params.data = { - module: 'OSSMail', - action: 'executeActions', - mode: 'removeRelated', - params: { - mailId: id, - crmid: crmid - } - } - params.async = false; - params.dataType = 'json'; - window.crm.AppConnector.request(params).then(function (data) { - var response = data['result']; - if (response['success']) { - var notifyParams = { - text: response['data'], - type: 'info', - animation: 'show' - }; - } else { - var notifyParams = { - text: response['data'], - animation: 'show' - }; - } - window.crm.Vtiger_Helper_Js.showPnotify(notifyParams); - loadActionBar(); - }); -} -function showPopup(params, sourceFieldElement, actionsParams) { - actionsParams['newModule'] = params['module']; - var prePopupOpenEvent = jQuery.Event(window.crm.Vtiger_Edit_Js.preReferencePopUpOpenEvent); - sourceFieldElement.trigger(prePopupOpenEvent); - var data = {}; - show(params, function (data) { - var responseData = JSON.parse(data); - for (var id in responseData) { - var data = { - name: responseData[id].name, - id: id - } - sourceFieldElement.val(data.id); - } - actionsParams['newCrmId'] = data.id; - var params = {} - params.data = { - module: 'OSSMail', - action: 'executeActions', - mode: 'addRelated', - params: actionsParams - } - params.async = false; - params.dataType = 'json'; - window.crm.AppConnector.request(params).then(function (data) { - var response = data['result']; - if (response['success']) { - var notifyParams = { - text: response['data'], - type: 'info', - animation: 'show' - }; - } else { - var notifyParams = { - text: response['data'], - animation: 'show' - }; - } - window.crm.Vtiger_Helper_Js.showPnotify(notifyParams); - loadActionBar(); - }); - }); -} -function showQuickCreateForm(moduleName, record, params) { - var content = $('#ytActionBarContent'); - if (params == undefined) { - var params = {}; - } - var relatedParams = {}; - if (params['sourceModule']) { - var sourceModule = params['sourceModule']; - } else { - var sourceModule = 'OSSMailView'; - } - var postShown = function (data) { - var index, queryParam, queryParamComponents; - $('').appendTo(data); - $('').appendTo(data); - $('').appendTo(data); - } - var ids = {link: 'modulesLevel0', process: 'modulesLevel1', subprocess: 'modulesLevel2'}; - for (var i in ids) { - var element = content.find('#' + ids[i]); - var value = element.length ? JSON.parse(element.val()) : []; - if ($.inArray(sourceModule, value) >= 0) { - relatedParams[i] = record; - } - } - if (moduleName == 'Leads') { - relatedParams['company'] = rcmail.env.fromName; - } - if (moduleName == 'Leads' || moduleName == 'Contacts') { - relatedParams['lastname'] = rcmail.env.fromName; - } - if (moduleName == 'Project') { - relatedParams['projectname'] = rcmail.env.subject; - } - if (moduleName == 'HelpDesk') { - relatedParams['ticket_title'] = rcmail.env.subject; - } - if (moduleName == 'Products') { - relatedParams['productname'] = rcmail.env.subject; - } - if (moduleName == 'Services') { - relatedParams['servicename'] = rcmail.env.subject; - } - relatedParams['email'] = rcmail.env.fromMail; - relatedParams['email1'] = rcmail.env.fromMail; - relatedParams['description'] = $('#messagebody').text(); - //relatedParams['related_to'] = record; - var postQuickCreate = function (data) { - loadActionBar(); - } - - relatedParams['sourceModule'] = sourceModule; - relatedParams['sourceRecord'] = record; - relatedParams['relationOperation'] = true; - var quickCreateParams = { - callbackFunction: postQuickCreate, - callbackPostShown: postShown, - data: relatedParams, - noCache: true - }; - var headerInstance = new window.crm.Vtiger_Header_Js(); - headerInstance.quickCreateModule(moduleName, quickCreateParams); -} -function show(urlOrParams, cb, windowName, eventName, onLoadCb) { - var thisInstance = window.crm.Vtiger_Popup_Js.getInstance(); - if (typeof urlOrParams == 'undefined') { - urlOrParams = {}; - } - if (typeof urlOrParams == 'object' && (typeof urlOrParams['view'] == "undefined")) { - urlOrParams['view'] = 'Popup'; - } - if (typeof eventName == 'undefined') { - eventName = 'postSelection' + Math.floor(Math.random() * 10000); - } - if (typeof windowName == 'undefined') { - windowName = 'test'; - } - if (typeof urlOrParams == 'object') { - urlOrParams['triggerEventName'] = eventName; - } else { - urlOrParams += '&triggerEventName=' + eventName; - } - var urlString = (typeof urlOrParams == 'string') ? urlOrParams : window.crm.jQuery.param(urlOrParams); - var url = urlOrParams['url'] + urlString; - var popupWinRef = window.crm.window.open(url, windowName, 'width=800,height=650,resizable=0,scrollbars=1'); - if (typeof thisInstance.destroy == 'function') { - thisInstance.destroy(); - } - window.crm.jQuery.initWindowMsg(); - if (typeof cb != 'undefined') { - thisInstance.retrieveSelectedRecords(cb, eventName); - } - if (typeof onLoadCb == 'function') { - window.crm.jQuery.windowMsg('Vtiger.OnPopupWindowLoad.Event', function (data) { - onLoadCb(data); - }) - } - return popupWinRef; -} -function getCrmWindow() { - if (opener !== null) { - return opener.parent; - } else if (typeof parent.app == "object") { - return parent; - } else if (typeof parent.parent.app == "object") { - return parent.parent; - } - return false; -} +/* {[The file is published on the basis of YetiForce Public License that can be found in the following directory: licenses/License.html]} */ +window.rcmail && rcmail.addEventListener('init', function (evt) { + window.crm = getCrmWindow(); + loadActionBar(); + rcmail.env.message_commands.push('yetiforce.importICS'); + rcmail.register_command('yetiforce.importICS', function (ics, element, e) { + window.crm.AppConnector.request({ + async: true, + dataType: 'json', + data: { + module: 'Calendar', + action: 'ImportICS', + ics: ics + } + }).then(function (response) { + window.crm.Vtiger_Helper_Js.showPnotify({ + text: response['result'], + type: 'info', + animation: 'show' + }); + $(element).closest('.icalattachments').remove(); + }) + }, true); +} +); +function loadActionBar() { + var content = $('#ytActionBarContent'); + var params = { + module: 'OSSMail', + view: 'MailActionBar', + uid: rcmail.env.uid, + folder: rcmail.env.mailbox, + rcId: rcmail.env.user_id + }; + window.crm.AppConnector.request(params).then(function (response) { + content.find('.ytHeader').html(response); + $('#messagecontent').css('top', (content.outerHeight() + $('#messageheader').outerHeight()) + 'px'); + registerEvents(content); + }); +} +function registerEvents(content) { + registerAddRecord(content); + registerAddReletedRecord(content); + registerSelectRecord(content); + registerRemoveRecord(content); + registerImportMail(content); + + var block = content.find('.ytHeader .data'); + content.find('.hideBtn').click(function () { + var button = $(this); + var icon = button.find('.glyphicon'); + + if (button.data('type') == '0') { + button.data('type', '1'); + icon.removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down"); + } else { + button.data('type', '0'); + icon.removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up"); + } + block.toggle(); + $(window).trigger("resize"); + }); +} +function registerImportMail(content) { + content.find('.importMail').click(function (e) { + window.crm.Vtiger_Helper_Js.showPnotify({ + text: window.crm.app.vtranslate('StartedDownloadingEmail'), + type: 'info' + }); + window.crm.AppConnector.request({ + module: 'OSSMail', + action: 'ImportMail', + params: { + uid: rcmail.env.uid, + folder: rcmail.env.mailbox, + rcId: rcmail.env.user_id + } + }).then(function (data) { + loadActionBar(); + window.crm.Vtiger_Helper_Js.showPnotify({ + text: window.crm.app.vtranslate('AddFindEmailInRecord'), + type: 'success' + }); + }) + }); +} +function registerRemoveRecord(content) { + content.find('button.removeRecord').click(function (e) { + var row = $(e.currentTarget).closest('.rowRelatedRecord'); + removeRecord(row.data('id')); + }); +} +function registerSelectRecord(content) { + var id = content.find('#mailActionBarID').val(); + content.find('button.selectRecord').click(function (e) { + var sourceFieldElement = jQuery('input[name="tempField"]'); + var relParams = { + mailId: id + }; + if ($(this).data('type') == 0) { + var module = $(this).closest('.col').find('.module').val(); + } else { + var module = $(this).data('module'); + relParams.crmid = $(this).closest('.rowRelatedRecord').data('id'); + relParams.mod = $(this).closest('.rowRelatedRecord').data('module'); + relParams.newModule = module; + } + var PopupParams = { + module: module, + src_module: module, + src_field: 'tempField', + src_record: '', + url: rcmail.env.site_URL + 'index.php?' + }; + showPopup(PopupParams, sourceFieldElement, relParams); + }); +} +function registerAddReletedRecord(content) { + var id = content.find('#mailActionBarID').val(); + content.find('button.addRelatedRecord').click(function (e) { + var targetElement = $(e.currentTarget); + var row = targetElement.closest('.rowRelatedRecord'); + var params = {sourceModule: row.data('module')}; + showQuickCreateForm(targetElement.data('module'), row.data('id'), params); + }); +} +function registerAddRecord(content) { + var id = content.find('#mailActionBarID').val(); + content.find('button.addRecord').click(function (e) { + var col = $(e.currentTarget).closest('.col'); + showQuickCreateForm(col.find('.module').val(), id); + }); +} +function removeRecord(crmid) { + var id = $('#mailActionBarID').val(); + var params = {} + params.data = { + module: 'OSSMail', + action: 'executeActions', + mode: 'removeRelated', + params: { + mailId: id, + crmid: crmid + } + } + params.async = false; + params.dataType = 'json'; + window.crm.AppConnector.request(params).then(function (data) { + var response = data['result']; + if (response['success']) { + var notifyParams = { + text: response['data'], + type: 'info', + animation: 'show' + }; + } else { + var notifyParams = { + text: response['data'], + animation: 'show' + }; + } + window.crm.Vtiger_Helper_Js.showPnotify(notifyParams); + loadActionBar(); + }); +} +function showPopup(params, sourceFieldElement, actionsParams) { + actionsParams['newModule'] = params['module']; + var prePopupOpenEvent = jQuery.Event(window.crm.Vtiger_Edit_Js.preReferencePopUpOpenEvent); + sourceFieldElement.trigger(prePopupOpenEvent); + var data = {}; + show(params, function (data) { + var responseData = JSON.parse(data); + for (var id in responseData) { + var data = { + name: responseData[id].name, + id: id + } + sourceFieldElement.val(data.id); + } + actionsParams['newCrmId'] = data.id; + var params = {} + params.data = { + module: 'OSSMail', + action: 'executeActions', + mode: 'addRelated', + params: actionsParams + } + params.async = false; + params.dataType = 'json'; + window.crm.AppConnector.request(params).then(function (data) { + var response = data['result']; + if (response['success']) { + var notifyParams = { + text: response['data'], + type: 'info', + animation: 'show' + }; + } else { + var notifyParams = { + text: response['data'], + animation: 'show' + }; + } + window.crm.Vtiger_Helper_Js.showPnotify(notifyParams); + loadActionBar(); + }); + }); +} +function showQuickCreateForm(moduleName, record, params) { + var content = $('#ytActionBarContent'); + if (params == undefined) { + var params = {}; + } + var relatedParams = {}; + if (params['sourceModule']) { + var sourceModule = params['sourceModule']; + } else { + var sourceModule = 'OSSMailView'; + } + var postShown = function (data) { + var index, queryParam, queryParamComponents; + $('').appendTo(data); + $('').appendTo(data); + $('').appendTo(data); + } + var ids = {link: 'modulesLevel0', process: 'modulesLevel1', subprocess: 'modulesLevel2'}; + for (var i in ids) { + var element = content.find('#' + ids[i]); + var value = element.length ? JSON.parse(element.val()) : []; + if ($.inArray(sourceModule, value) >= 0) { + relatedParams[i] = record; + } + } + if (moduleName == 'Leads') { + relatedParams['company'] = rcmail.env.fromName; + } + if (moduleName == 'Leads' || moduleName == 'Contacts') { + relatedParams['lastname'] = rcmail.env.fromName; + } + if (moduleName == 'Project') { + relatedParams['projectname'] = rcmail.env.subject; + } + if (moduleName == 'HelpDesk') { + relatedParams['ticket_title'] = rcmail.env.subject; + } + if (moduleName == 'Products') { + relatedParams['productname'] = rcmail.env.subject; + } + if (moduleName == 'Services') { + relatedParams['servicename'] = rcmail.env.subject; + } + relatedParams['email'] = rcmail.env.fromMail; + relatedParams['email1'] = rcmail.env.fromMail; + relatedParams['description'] = $('#messagebody').text(); + //relatedParams['related_to'] = record; + var postQuickCreate = function (data) { + loadActionBar(); + } + + relatedParams['sourceModule'] = sourceModule; + relatedParams['sourceRecord'] = record; + relatedParams['relationOperation'] = true; + var quickCreateParams = { + callbackFunction: postQuickCreate, + callbackPostShown: postShown, + data: relatedParams, + noCache: true + }; + var headerInstance = new window.crm.Vtiger_Header_Js(); + headerInstance.quickCreateModule(moduleName, quickCreateParams); +} +function show(urlOrParams, cb, windowName, eventName, onLoadCb) { + var thisInstance = window.crm.Vtiger_Popup_Js.getInstance(); + if (typeof urlOrParams == 'undefined') { + urlOrParams = {}; + } + if (typeof urlOrParams == 'object' && (typeof urlOrParams['view'] == "undefined")) { + urlOrParams['view'] = 'Popup'; + } + if (typeof eventName == 'undefined') { + eventName = 'postSelection' + Math.floor(Math.random() * 10000); + } + if (typeof windowName == 'undefined') { + windowName = 'test'; + } + if (typeof urlOrParams == 'object') { + urlOrParams['triggerEventName'] = eventName; + } else { + urlOrParams += '&triggerEventName=' + eventName; + } + var urlString = (typeof urlOrParams == 'string') ? urlOrParams : window.crm.jQuery.param(urlOrParams); + var url = urlOrParams['url'] + urlString; + var popupWinRef = window.crm.window.open(url, windowName, 'width=800,height=650,resizable=0,scrollbars=1'); + if (typeof thisInstance.destroy == 'function') { + thisInstance.destroy(); + } + window.crm.jQuery.initWindowMsg(); + if (typeof cb != 'undefined') { + thisInstance.retrieveSelectedRecords(cb, eventName); + } + if (typeof onLoadCb == 'function') { + window.crm.jQuery.windowMsg('Vtiger.OnPopupWindowLoad.Event', function (data) { + onLoadCb(data); + }) + } + return popupWinRef; +} +function getCrmWindow() { + if (opener !== null) { + return opener.parent; + } else if (typeof parent.app == "object") { + return parent; + } else if (typeof parent.parent.app == "object") { + return parent.parent; + } + return false; +} diff --git a/plugins/yetiforce/preview.min.js b/plugins/yetiforce/preview.min.js index 6904547c..53dcee13 100644 --- a/plugins/yetiforce/preview.min.js +++ b/plugins/yetiforce/preview.min.js @@ -1,2 +1,2 @@ -window.rcmail&&rcmail.addEventListener("init",function(a){window.crm=getCrmWindow();loadActionBar();rcmail.env.message_commands.push("yetiforce.importICS");rcmail.register_command("yetiforce.importICS",function(b,c,d){window.crm.AppConnector.request({async:true,dataType:"json",data:{module:"Calendar",action:"ImportICS",ics:b}}).then(function(e){window.crm.Vtiger_Helper_Js.showPnotify({text:e.result,type:"info",animation:"show"});$(c).closest(".icalattachments").remove()})},true)});function loadActionBar(){var a=$("#ytActionBarContent");var b={module:"OSSMail",view:"MailActionBar",uid:rcmail.env.uid,folder:rcmail.env.mailbox,rcId:rcmail.env.user_id};window.crm.AppConnector.request(b).then(function(c){a.find(".ytHeader").html(c);$("#messagecontent").css("top",(a.outerHeight()+$("#messageheader").outerHeight())+"px");registerEvents(a)})}function registerEvents(a){registerAddRecord(a);registerAddReletedRecord(a);registerSelectRecord(a);registerRemoveRecord(a);registerImportMail(a);var b=a.find(".ytHeader .data");a.find(".hideBtn").click(function(){var c=$(this);var d=c.find(".glyphicon");if(c.data("type")=="0"){c.data("type","1");d.removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down")}else{c.data("type","0");d.removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up")}b.toggle();$(window).trigger("resize")})}function registerImportMail(a){a.find(".importMail").click(function(b){window.crm.Vtiger_Helper_Js.showPnotify({text:window.crm.app.vtranslate("StartedDownloadingEmail"),type:"info"});window.crm.AppConnector.request({module:"OSSMail",action:"ImportMail",params:{uid:rcmail.env.uid,folder:rcmail.env.mailbox,rcId:rcmail.env.user_id}}).then(function(c){loadActionBar();window.crm.Vtiger_Helper_Js.showPnotify({text:window.crm.app.vtranslate("AddFindEmailInRecord"),type:"success"})})})}function registerRemoveRecord(a){a.find("button.removeRecord").click(function(b){var c=$(b.currentTarget).closest(".rowReletedRecord");removeRecord(c.data("id"))})}function registerSelectRecord(a){var b=a.find("#mailActionBarID").val();a.find("button.selectRecord").click(function(f){var d=jQuery('input[name="tempField"]');var h={mailId:b};if($(this).data("type")==0){var c=$(this).closest(".col").find(".module").val()}else{var c=$(this).data("module");h.crmid=$(this).closest(".rowReletedRecord").data("id");h.mod=$(this).closest(".rowReletedRecord").data("module");h.newModule=c}var g={module:c,src_module:c,src_field:"tempField",src_record:"",url:rcmail.env.site_URL+"index.php?"};showPopup(g,d,h)})}function registerAddReletedRecord(a){var b=a.find("#mailActionBarID").val();a.find("button.addReletedRecord").click(function(d){var c=$(d.currentTarget);var g=c.closest(".rowReletedRecord");var f={sourceModule:g.data("module")};showQuickCreateForm(c.data("module"),g.data("id"),f)})}function registerAddRecord(a){var b=a.find("#mailActionBarID").val();a.find("button.addRecord").click(function(d){var c=$(d.currentTarget).closest(".col");showQuickCreateForm(c.find(".module").val(),b)})}function removeRecord(a){var c=$("#mailActionBarID").val();var b={};b.data={module:"OSSMail",action:"executeActions",mode:"removeRelated",params:{mailId:c,crmid:a}};b.async=false;b.dataType="json";window.crm.AppConnector.request(b).then(function(f){var e=f.result;if(e.success){var d={text:e.data,type:"info",animation:"show"}}else{var d={text:e.data,animation:"show"}}window.crm.Vtiger_Helper_Js.showPnotify(d);loadActionBar()})}function showPopup(e,c,d){d.newModule=e.module;var a=jQuery.Event(window.crm.Vtiger_Edit_Js.preReferencePopUpOpenEvent);c.trigger(a);var b={};show(e,function(g){var f=JSON.parse(g);for(var i in f){var g={name:f[i].name,id:i};c.val(g.id)}d.newCrmId=g.id;var h={};h.data={module:"OSSMail",action:"executeActions",mode:"addRelated",params:d};h.async=false;h.dataType="json";window.crm.AppConnector.request(h).then(function(l){var k=l.result;if(k.success){var j={text:k.data,type:"info",animation:"show"}}else{var j={text:k.data,animation:"show"}}window.crm.Vtiger_Helper_Js.showPnotify(j);loadActionBar()})})}function showQuickCreateForm(b,h,d){var k=$("#ytActionBarContent");if(d==undefined){var d={}}var e={};if(d.sourceModule){var j=d.sourceModule}else{var j="OSSMailView"}var o=function(q){var i,p,r;$('').appendTo(q);$('').appendTo(q);$('').appendTo(q)};var a={link:"modulesLevel0",process:"modulesLevel1",subprocess:"modulesLevel2"};for(var g in a){var f=k.find("#"+a[g]);var n=f.length?JSON.parse(f.val()):[];if($.inArray(j,n)>=0){e[g]=h}}if(b=="Leads"){e.company=rcmail.env.fromName}if(b=="Leads"||b=="Contacts"){e.lastname=rcmail.env.fromName}if(b=="Project"){e.projectname=rcmail.env.subject}if(b=="HelpDesk"){e.ticket_title=rcmail.env.subject}if(b=="Products"){e.productname=rcmail.env.subject}if(b=="Services"){e.servicename=rcmail.env.subject}e.email=rcmail.env.fromMail;e.email1=rcmail.env.fromMail;e.description=$("#messagebody").text();var m=function(i){loadActionBar()};e.sourceModule=j;e.sourceRecord=h;e.relationOperation=true;var c={callbackFunction:m,callbackPostShown:o,data:e,noCache:true};var l=new window.crm.Vtiger_Header_Js();l.quickCreateModule(b,c)}function show(c,d,i,f,b){var h=window.crm.Vtiger_Popup_Js.getInstance();if(typeof c=="undefined"){c={}}if(typeof c=="object"&&(typeof c.view=="undefined")){c.view="Popup"}if(typeof f=="undefined"){f="postSelection"+Math.floor(Math.random()*10000)}if(typeof i=="undefined"){i="test"}if(typeof c=="object"){c.triggerEventName=f}else{c+="&triggerEventName="+f}var e=(typeof c=="string")?c:window.crm.jQuery.param(c);var a=c.url+e;var g=window.crm.window.open(a,i,"width=800,height=650,resizable=0,scrollbars=1");if(typeof h.destroy=="function"){h.destroy()}window.crm.jQuery.initWindowMsg();if(typeof d!="undefined"){h.retrieveSelectedRecords(d,f)}if(typeof b=="function"){window.crm.jQuery.windowMsg("Vtiger.OnPopupWindowLoad.Event",function(j){b(j)})}return g}function getCrmWindow(){if(opener!==null){return opener.parent}else{if(typeof parent.app=="object"){return parent}else{if(typeof parent.parent.app=="object"){return parent.parent}}}return false}; \ No newline at end of file +window.rcmail&&rcmail.addEventListener("init",function(a){window.crm=getCrmWindow();loadActionBar();rcmail.env.message_commands.push("yetiforce.importICS");rcmail.register_command("yetiforce.importICS",function(b,c,d){window.crm.AppConnector.request({async:true,dataType:"json",data:{module:"Calendar",action:"ImportICS",ics:b}}).then(function(e){window.crm.Vtiger_Helper_Js.showPnotify({text:e.result,type:"info",animation:"show"});$(c).closest(".icalattachments").remove()})},true)});function loadActionBar(){var a=$("#ytActionBarContent");var b={module:"OSSMail",view:"MailActionBar",uid:rcmail.env.uid,folder:rcmail.env.mailbox,rcId:rcmail.env.user_id};window.crm.AppConnector.request(b).then(function(c){a.find(".ytHeader").html(c);$("#messagecontent").css("top",(a.outerHeight()+$("#messageheader").outerHeight())+"px");registerEvents(a)})}function registerEvents(a){registerAddRecord(a);registerAddReletedRecord(a);registerSelectRecord(a);registerRemoveRecord(a);registerImportMail(a);var b=a.find(".ytHeader .data");a.find(".hideBtn").click(function(){var c=$(this);var d=c.find(".glyphicon");if(c.data("type")=="0"){c.data("type","1");d.removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down")}else{c.data("type","0");d.removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up")}b.toggle();$(window).trigger("resize")})}function registerImportMail(a){a.find(".importMail").click(function(b){window.crm.Vtiger_Helper_Js.showPnotify({text:window.crm.app.vtranslate("StartedDownloadingEmail"),type:"info"});window.crm.AppConnector.request({module:"OSSMail",action:"ImportMail",params:{uid:rcmail.env.uid,folder:rcmail.env.mailbox,rcId:rcmail.env.user_id}}).then(function(c){loadActionBar();window.crm.Vtiger_Helper_Js.showPnotify({text:window.crm.app.vtranslate("AddFindEmailInRecord"),type:"success"})})})}function registerRemoveRecord(a){a.find("button.removeRecord").click(function(b){var c=$(b.currentTarget).closest(".rowRelatedRecord");removeRecord(c.data("id"))})}function registerSelectRecord(a){var b=a.find("#mailActionBarID").val();a.find("button.selectRecord").click(function(f){var d=jQuery('input[name="tempField"]');var h={mailId:b};if($(this).data("type")==0){var c=$(this).closest(".col").find(".module").val()}else{var c=$(this).data("module");h.crmid=$(this).closest(".rowRelatedRecord").data("id");h.mod=$(this).closest(".rowRelatedRecord").data("module");h.newModule=c}var g={module:c,src_module:c,src_field:"tempField",src_record:"",url:rcmail.env.site_URL+"index.php?"};showPopup(g,d,h)})}function registerAddReletedRecord(a){var b=a.find("#mailActionBarID").val();a.find("button.addRelatedRecord").click(function(d){var c=$(d.currentTarget);var g=c.closest(".rowRelatedRecord");var f={sourceModule:g.data("module")};showQuickCreateForm(c.data("module"),g.data("id"),f)})}function registerAddRecord(a){var b=a.find("#mailActionBarID").val();a.find("button.addRecord").click(function(d){var c=$(d.currentTarget).closest(".col");showQuickCreateForm(c.find(".module").val(),b)})}function removeRecord(a){var c=$("#mailActionBarID").val();var b={};b.data={module:"OSSMail",action:"executeActions",mode:"removeRelated",params:{mailId:c,crmid:a}};b.async=false;b.dataType="json";window.crm.AppConnector.request(b).then(function(f){var e=f.result;if(e.success){var d={text:e.data,type:"info",animation:"show"}}else{var d={text:e.data,animation:"show"}}window.crm.Vtiger_Helper_Js.showPnotify(d);loadActionBar()})}function showPopup(e,c,d){d.newModule=e.module;var a=jQuery.Event(window.crm.Vtiger_Edit_Js.preReferencePopUpOpenEvent);c.trigger(a);var b={};show(e,function(g){var f=JSON.parse(g);for(var i in f){var g={name:f[i].name,id:i};c.val(g.id)}d.newCrmId=g.id;var h={};h.data={module:"OSSMail",action:"executeActions",mode:"addRelated",params:d};h.async=false;h.dataType="json";window.crm.AppConnector.request(h).then(function(l){var k=l.result;if(k.success){var j={text:k.data,type:"info",animation:"show"}}else{var j={text:k.data,animation:"show"}}window.crm.Vtiger_Helper_Js.showPnotify(j);loadActionBar()})})}function showQuickCreateForm(b,h,d){var k=$("#ytActionBarContent");if(d==undefined){var d={}}var e={};if(d.sourceModule){var j=d.sourceModule}else{var j="OSSMailView"}var o=function(q){var i,p,r;$('').appendTo(q);$('').appendTo(q);$('').appendTo(q)};var a={link:"modulesLevel0",process:"modulesLevel1",subprocess:"modulesLevel2"};for(var g in a){var f=k.find("#"+a[g]);var n=f.length?JSON.parse(f.val()):[];if($.inArray(j,n)>=0){e[g]=h}}if(b=="Leads"){e.company=rcmail.env.fromName}if(b=="Leads"||b=="Contacts"){e.lastname=rcmail.env.fromName}if(b=="Project"){e.projectname=rcmail.env.subject}if(b=="HelpDesk"){e.ticket_title=rcmail.env.subject}if(b=="Products"){e.productname=rcmail.env.subject}if(b=="Services"){e.servicename=rcmail.env.subject}e.email=rcmail.env.fromMail;e.email1=rcmail.env.fromMail;e.description=$("#messagebody").text();var m=function(i){loadActionBar()};e.sourceModule=j;e.sourceRecord=h;e.relationOperation=true;var c={callbackFunction:m,callbackPostShown:o,data:e,noCache:true};var l=new window.crm.Vtiger_Header_Js();l.quickCreateModule(b,c)}function show(c,d,i,f,b){var h=window.crm.Vtiger_Popup_Js.getInstance();if(typeof c=="undefined"){c={}}if(typeof c=="object"&&(typeof c.view=="undefined")){c.view="Popup"}if(typeof f=="undefined"){f="postSelection"+Math.floor(Math.random()*10000)}if(typeof i=="undefined"){i="test"}if(typeof c=="object"){c.triggerEventName=f}else{c+="&triggerEventName="+f}var e=(typeof c=="string")?c:window.crm.jQuery.param(c);var a=c.url+e;var g=window.crm.window.open(a,i,"width=800,height=650,resizable=0,scrollbars=1");if(typeof h.destroy=="function"){h.destroy()}window.crm.jQuery.initWindowMsg();if(typeof d!="undefined"){h.retrieveSelectedRecords(d,f)}if(typeof b=="function"){window.crm.jQuery.windowMsg("Vtiger.OnPopupWindowLoad.Event",function(j){b(j)})}return g}function getCrmWindow(){if(opener!==null){return opener.parent}else{if(typeof parent.app=="object"){return parent}else{if(typeof parent.parent.app=="object"){return parent.parent}}}return false}; \ No newline at end of file diff --git a/version.php b/version.php index 854dd1e1..784793ea 100644 --- a/version.php +++ b/version.php @@ -1,5 +1,5 @@ '2017.05.17', - 'version' => '0.0.30' + 'patch' => '2017.07.31', + 'version' => '0.0.31' ];