Skip to content
Snippets Groups Projects
Commit 0f0ccf8a authored by Jared Hancock's avatar Jared Hancock
Browse files

Implement typeahead context for canned responses

parent dae9fb2e
No related branches found
No related tags found
No related merge requests found
......@@ -208,12 +208,18 @@ class ContentAjaxAPI extends AjaxController {
if (!$_GET['root'])
Http::response(400, '`root` is required parameter');
// Get the template for this template
$tpl_info = EmailTemplateGroup::getTemplateDescription($_GET['root']);
if (!$tpl_info)
Http::response(422, 'No such context');
switch ($_GET['root']) {
case 'cannedresponse':
$roots = array('ticket');
break;
$global = osTicket::getVarScope();
default:
// Get the template for this template
$tpl_info = EmailTemplateGroup::getTemplateDescription($_GET['root']);
if (!$tpl_info)
Http::response(422, 'No such context');
$roots = $tpl_info['context'];
}
$contextTypes = array(
'assignee' => array('class' => 'Staff', 'desc' => 'Newly assigned agent'),
......@@ -229,9 +235,10 @@ class ContentAjaxAPI extends AjaxController {
'ticket' => array('class' => 'Ticket', 'desc' => 'The ticket'),
);
$context = array();
foreach ($tpl_info['context'] as $C) {
foreach ($roots as $C) {
$context[$C] = $contextTypes[$C];
}
$global = osTicket::getVarScope();
$items = VariableReplacer::compileScope($context + $global);
header('Content-Type: application/json');
......
......@@ -80,10 +80,15 @@ implements AuthenticatedUser, EmailContact, TemplateVariable {
static function getVarScope() {
return array(
'dept' => array('class' => 'Dept', 'desc' => 'Department'),
'email' => 'Email address',
'name' => array(
'class' => 'PersonsName', 'desc' => 'Name of the agent',
),
'phone' => 'Phone number',
'signature' => "Agent's signature",
'timezone' => "Agent's configured timezone",
'username' => 'Access username',
);
}
......
......@@ -80,13 +80,13 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
<font class="error">*&nbsp;<?php echo $errors['response']; ?></font>
&nbsp;&nbsp;&nbsp;(<a class="tip" href="#ticket_variables"><?php echo __('Supported Variables'); ?></a>)
</div>
<textarea name="response" class="richtext draft draft-delete" cols="21" rows="12"
style="width:98%;" class="richtext draft" <?php
<textarea name="response" cols="21" rows="12"
data-root-context="cannedresponse"
style="width:98%;" class="richtext draft draft-delete" <?php
list($draft, $attrs) = Draft::getDraftAndDataAttrs('canned',
is_object($canned) ? $canned->getId() : false, $info['response']);
echo $attrs; ?>><?php echo $draft ?: $info['response'];
?></textarea>
<br><br>
<div><h3><?php echo __('Canned Attachments'); ?> <?php echo __('(optional)'); ?>
&nbsp;<i class="help-tip icon-question-sign" href="#canned_attachments"></i></h3>
<div class="error"><?php echo $errors['files']; ?></div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment