Skip to content

Commit

Permalink
Merge pull request #1322 from tsolucio/sendmailtemplates
Browse files Browse the repository at this point in the history
feat(Emails) add Preview functionality to Send Mail action
  • Loading branch information
joebordes committed Mar 19, 2023
2 parents 2880360 + be4d6b6 commit d5f25c7
Show file tree
Hide file tree
Showing 59 changed files with 989 additions and 437 deletions.
1 change: 1 addition & 0 deletions Smarty/templates/Components/ComponentsJS.tpl
@@ -1,6 +1,7 @@
<script src="./include/components/loadjs.js"></script>
<script src="./include/components/ldsmodal.js"></script>
<script src="./include/components/ldsprompt.js"></script>
<script src="./include/components/ldsmail.js"></script>
<script src="./include/components/ldsnotifications.js"></script>
<script src="./include/components/toast-ui/pagination/tui-pagination.js"></script>
<script src="./include/components/toast-ui/tui-time-picker/tui-time-picker.js"></script>
Expand Down
671 changes: 459 additions & 212 deletions Smarty/templates/ComposeEmail.tpl

Large diffs are not rendered by default.

129 changes: 0 additions & 129 deletions Smarty/templates/EmailDetailView.tpl

This file was deleted.

54 changes: 53 additions & 1 deletion Smarty/templates/EmailDetailViewInside.tpl
Expand Up @@ -8,6 +8,23 @@
* All Rights Reserved.
********************************************************************************/
-->*}
{if $smarty.request.action eq 'EmailsAjax'}
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset={$LBL_CHARSET}">
<title>{$MOD.TITLE_VTIGERCRM_MAIL}</title>
<link REL="SHORTCUT ICON" HREF="themes/images/favicon.ico">
<link rel="stylesheet" type="text/css" media="all" href="themes/{$THEME}/style.css">
<link rel="stylesheet" href="include/LD/assets/styles/salesforce-lightning-design-system.css" type="text/css" />
<link rel="stylesheet" href="include/LD/assets/styles/override_lds.css" type="text/css" />
<script type="text/javascript" src="include/jquery/jquery.js"></script>
{include file='BrowserVariables.tpl'}
<script type="text/javascript" src="include/js/vtlib.js"></script>
<script type="text/javascript" src="include/js/general.js"></script>
</head>
<body marginheight="0" marginwidth="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
{/if}
<style>
#adv_filter_div > table:first-child td,
#adv_filter_div > div:nth-child(3) > table:first-child tr:first-child td,
Expand All @@ -18,7 +35,25 @@
{assign var=CREATE_PERMISSION value='no'}
{assign var=DELETE value='no'}
{assign var=EDIT_PERMISSION value='no'}
{include file='Buttons_List.tpl' isDetailView=true}
<div class="slds-page-header">
<div class="slds-page-header__row">
<div class="slds-page-header__col-title">
<div class="slds-media">
<div class="slds-media__body">
<div class="slds-page-header__name">
<div class="slds-page-header__name-title">
<h1>
<span class="slds-page-header__title slds-truncate" title="{$MOD.LBL_EMAILS_TITLE}">
{$MOD.LBL_EMAILS_TITLE}
</span>
</h1>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<table class="slds-card" style="width:96%; margin:auto;">
<tbody>
{foreach item=row from=$BLOCKS}
Expand Down Expand Up @@ -112,6 +147,19 @@
'onclick' => "OpenCompose('{$ID}','edit')"
]}
{include file='Components/ButtonWithIcon.tpl'}
{if $smarty.request.action eq 'EmailsAjax'}
{assign var='BUTTONWITHICON' value=[
'variation' => 'text-destructive',
'title' => $APP.LBL_CANCEL_BUTTON_LABEL,
'id' => 'cancel',
'size' => 'small',
'position' => 'left',
'library' => 'utility',
'icon' => 'close',
'onclick' => 'window.close()'
]}
{include file='Components/ButtonWithIcon.tpl'}
{/if}
{assign var='BUTTONWITHICON' value=[
'variation' => 'outline-brand',
'title' => $MOD.LBL_PRINT_EMAIL,
Expand Down Expand Up @@ -146,3 +194,7 @@
<script>
document.getElementById('attach_cont').innerHTML = document.getElementById('attach_temp_cont').innerHTML;
</script>
{if $smarty.request.action eq 'EmailsAjax'}
</body>
</html>
{/if}
1 change: 1 addition & 0 deletions build/changeSets/DefineGlobalVariables.php
Expand Up @@ -338,6 +338,7 @@ public function applyChange() {
'Apache_Tika_URL',
'Application_MassAction_Multipage',
'Document_DefaultFolder',
'Email_Template_AutomaticMerge',
);
$delete_these = array(
'preload_prototype',
Expand Down
102 changes: 102 additions & 0 deletions include/components/ldsmail.js
@@ -0,0 +1,102 @@
const ldsMailClosing = new Event('closemail');
const ldsMail = {
show : (headText, content, footer = '', height = '35', width = '58') => {
ldsMail.height = height;
ldsMail.width = width;
let mail = `
<div class="slds-docked_container" style="z-index:100;">
<section class="slds-docked-composer slds-grid slds-grid_vertical slds-fade-in-open slds-is-open slds-has-focus" id="global-mail-box" role="dialog" style="height: ${height}rem; width: ${width}rem;">
<header class="slds-docked-composer__header slds-grid slds-shrink-none">
<div class="slds-media slds-media_center slds-no-space">
<div class="slds-media__figure slds-m-right_x-small">
<span class="slds-icon_container">
<svg class="slds-icon slds-icon_small slds-icon-text-default" aria-hidden="true">
<use xlink:href="include/LD/assets/icons/standard-sprite/svg/symbols.svg#email"></use>
</svg>
</span>
</div>
<div class="slds-media__body">
<h2 class="slds-truncate" id="global-mail-container__title" title="${headText}">${headText}</h2>
</div>
</div>
<div class="slds-col_bump-left slds-shrink-none">
<button class="slds-button slds-button_icon slds-button_icon" id="minimize-mail-btn" title="${alert_arr.LBL_MIN_PANEL}" onClick="javascript:ldsMail.minimize()">
<svg class="slds-button__icon" aria-hidden="true">
<use xlink:href="include/LD/assets/icons/utility-sprite/svg/symbols.svg#minimize_window"></use>
</svg>
<span class="slds-assistive-text">${alert_arr.LBL_MIN_PANEL}</span>
</button>
<button class="slds-button slds-button_icon slds-button_icon" id="expand-mail-btn" style="display:none;" title="${alert_arr.LBL_EXPAND_PANEL}" onClick="javascript:ldsMail.expand()">
<svg class="slds-button__icon" aria-hidden="true">
<use xlink:href="include/LD/assets/icons/utility-sprite/svg/symbols.svg#expand_alt"></use>
</svg>
<span class="slds-assistive-text">${alert_arr.LBL_EXPAND_PANEL}</span>
</button>
<button class="slds-button slds-button_icon slds-button_icon" title="${alert_arr.LBL_CLOSE_TITLE}" onClick="javascript:ldsMail.close()">
<svg class="slds-button__icon" aria-hidden="true">
<use xlink:href="include/LD/assets/icons/utility-sprite/svg/symbols.svg#close"></use>
</svg>
<span class="slds-assistive-text">${alert_arr.LBL_CLOSE_TITLE}</span>
</button>
</div>
</header>
<div class="slds-docked-composer__body" id="global-mail-content" style="overflow-y:auto;height:${ldsMail.height-10}rem">
${content}
</div>
<footer class="slds-docked-composer__footer slds-shrink-none" id="global-mail-footer">
${footer}
</footer>
</section>
</div>
`;
ldsMail.insert(mail);
},
insert : (html) => {
if (ldsMail.active === true) {
console.error('Can\'t show two mail components, close the first one first');
} else {
let mailContainer = document.createElement('DIV');
mailContainer.id = 'global-mail-container';
mailContainer.innerHTML = html;
document.body.appendChild(mailContainer);
ldsMail.active = true;
vtlib_executeJavascriptInElement(document.getElementById('global-mail-container'));
}
},
close : () => {
let mailContainer = document.getElementById('global-mail-container');
mailContainer.dispatchEvent(ldsMailClosing);
mailContainer.remove(mailContainer);
ldsMail.active = false;
},
minimize : () => {
let box = document.getElementById('global-mail-box');
box.style.height = '2.5rem';
box.style.width = '28rem';
box.classList.remove('slds-is-open');
box.classList.remove('slds-has-focus');
box.classList.add('slds-is-closed');
let btnExp = document.getElementById('expand-mail-btn');
let btnMin = document.getElementById('minimize-mail-btn');
btnMin.style.display = 'none';
btnExp.style.display = '';
},
expand : () => {
let box = document.getElementById('global-mail-box');
box.classList.remove('slds-is-closed');
box.classList.add('slds-is-open');
box.classList.add('slds-has-focus');
box.style.height = `${ldsMail.height}rem`;
box.style.width = `${ldsMail.width}rem`;
let btnExp = document.getElementById('expand-mail-btn');
let btnMin = document.getElementById('minimize-mail-btn');
btnMin.style.display = '';
btnExp.style.display = 'none';
},
updateTitle : (title) => {
document.getElementById('global-mail-container__title').innerHTML = title;
},
active: false,
height: 0,
width: 0
};

0 comments on commit d5f25c7

Please sign in to comment.