Skip to content

Commit

Permalink
Fix #9783 - Compose view quick search
Browse files Browse the repository at this point in the history
  • Loading branch information
ojs87 committed Oct 26, 2022
1 parent 7b6ac1b commit 13451c5
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/TemplateHandler/TemplateHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function buildTemplate($module, $view, $tpl, $ajaxSave, $metaDataDefs)
);
$contents = $this->ss->fetch($tpl);
// Insert validation and quick search stuff here
if ($view === 'EditView' || $ajaxSave || $view === 'ConvertLead' || strpos($view, 'QuickCreate')) {
if ($view === 'EditView' || $ajaxSave || $view === 'ConvertLead' || $view === 'ComposeView' || strpos($view, 'QuickCreate')) {
global $dictionary, $beanList, $app_strings, $mod_strings;
$mod = $beanList[$module];

Expand Down
4 changes: 2 additions & 2 deletions include/javascript/EmailsComposeViewModal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@
composeBox.on('hide.bs.modal', function () {
composeBox.remove();
});
$( "#emails_email_templates_name" ).change(function() {
$.fn.EmailsComposeView.onTemplateChange()
});
}).fail(function (data) {
composeBox.controls.modal.content.html(SUGAR.language.translate('', 'LBL_EMAIL_ERROR_GENERAL_TITLE'));
});
Expand Down Expand Up @@ -252,6 +255,9 @@
});
mb.show();
});
$( "#emails_email_templates_name" ).change(function() {
$.fn.EmailsComposeView.onTemplateChange()
});
}).fail(function (data) {
composeBox.controls.modal.content.html(SUGAR.language.translate('', 'LBL_EMAIL_ERROR_GENERAL_TITLE'));
});
Expand Down
3 changes: 3 additions & 0 deletions modules/Emails/include/ComposeView/ComposeView.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@
{rdelim}
{rdelim}{/if});
{rdelim});
$( "#emails_email_templates_name" ).change(function() {ldelim}
$.fn.EmailsComposeView.onTemplateChange()
{rdelim});
</script>
{/if}
</form>
35 changes: 35 additions & 0 deletions modules/Emails/include/ComposeView/EmailsComposeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,41 @@
});
};

$.fn.EmailsComposeView.onTemplateChange = function (args) {
var confirmed = function (args) {
var args = JSON.parse(args);
var form = $('[name="' + args.form_name + '"]');
$.post('index.php?entryPoint=emailTemplateData', {
emailTemplateId: args.name_to_value_array.emails_email_templates_idb
}, function (jsonResponse) {
var response = JSON.parse(jsonResponse);
$.fn.EmailsComposeView.loadAttachmentDataFromAjaxResponse(response);
$(form).find('[name="name"]').val(response.data.subject);
tinymce.activeEditor.setContent(response.data.body_from_html, {format: 'html'});
$.fn.EmailsComposeView.updateSignature();
});
set_return(args);
};
var mb = messageBox();
mb.setTitle(SUGAR.language.translate('Emails', 'LBL_CONFIRM_APPLY_EMAIL_TEMPLATE_TITLE'));
mb.setBody(SUGAR.language.translate('Emails', 'LBL_CONFIRM_APPLY_EMAIL_TEMPLATE_BODY'));
mb.show();

mb.on('ok', function () {
"use strict";
var id=$('#emails_email_templates_idb').val();
var name=$('#emails_email_templates_name').val();
args = JSON.stringify({"form_name":"ComposeView","name_to_value_array":{"emails_email_templates_idb": id,"emails_email_templates_name": name}})
confirmed(args);
mb.remove();
});

mb.on('cancel', function () {
"use strict";
mb.remove();
});
}

$.fn.EmailsComposeView.onParentSelect = function (args) {
set_return(args);
if (isValidEmail(args.name_to_value_array.email1)) {
Expand Down

0 comments on commit 13451c5

Please sign in to comment.