Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.37v #2092

Merged
merged 6 commits into from Apr 29, 2024
Merged

4.37v #2092

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lhc_web/design/defaulttheme/css/material_font.css
Expand Up @@ -7,7 +7,7 @@ div.message-row {
font-style: normal;
font-weight: 100 700;
font-display: block;
src: url('../fonts/MaterialSymbolsRounded2.woff2') format("woff2");
src: url('../fonts/MaterialSymbolsRounded3.woff2') format("woff2");
}

div.auto-responder-msg > div.msg-body::before,
Expand Down
Binary file not shown.

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

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

53 changes: 53 additions & 0 deletions lhc_web/design/defaulttheme/js/lhc.botcommand.js
@@ -0,0 +1,53 @@
$(document).ready(function() {
$('#add-field-row button[name="custom_field_add"]').click(function(){
botCommandFields.push({
'name': document.getElementById('custom_field_name').value,
'placeholder': document.getElementById('custom_field_placeholder').value,
'type': document.getElementById('custom_field_type').value,
'rows': document.getElementById('custom_field_rows').value,
'required': document.getElementById('custom_field_required').value,
});
renderPeriods()
});

var entityMap = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
'/': '&#x2F;',
'`': '&#x60;',
'=': '&#x3D;'
};

ee.addListener('delete_custom_command_field',function (index) {
botCommandFields.splice(index,1);
renderPeriods();
});

function escapeHtml (string) {
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
return entityMap[s];
});
}

function renderPeriods(){
let periodList = document.getElementById('field-rows-container');
periodList.innerHTML = '';
botCommandFields.forEach((item, index) => {
periodList.innerHTML += '<div class="row pt-1"><div class="col-3"><b>'+periodList.getAttribute('name-field')+'</b> - '+escapeHtml(item.name)+'<br><span class="text-muted fs12"> {args.arg_' + (index+1) +'} or {arg_' + (index+1) +'} in bot, in Rest API {{args.arg_' + (index+1) +'}}</span></div>'+
'<div class="col-2"><b>'+periodList.getAttribute('placeholder-field')+'</b> - '+escapeHtml(item.placeholder) + '</div>'+
'<div class="col-2"><b>'+periodList.getAttribute('type-field')+'</b> - '+escapeHtml(item.type) + '</div>'+
'<div class="col-2"><b>'+periodList.getAttribute('rows-field')+'</b> - '+escapeHtml(item.rows ? item.rows : 1) + '</div>'+
'<div class="col-2"><b>'+periodList.getAttribute('required-field')+'</b> - '+escapeHtml(item.required ? item.required : 'required') + '</div>'+
'<div class="col-1"><button class="btn btn-danger btn-sm w-100" type="button" onclick="ee.emitEvent(\'delete_custom_command_field\',['+index+'])">'+periodList.getAttribute('remove-action')+'</button></div>'+
'<input type="hidden" name="custom_field_name[]" value="'+escapeHtml(item.name)+'">' +
'<input type="hidden" name="custom_field_placeholder[]" value="'+escapeHtml(item.placeholder)+'">' +
'<input type="hidden" name="custom_field_type[]" value="'+escapeHtml(item.type)+'">' +
'<input type="hidden" name="custom_field_rows[]" value="'+escapeHtml(item.rows)+'"></div>'+
'<input type="hidden" name="custom_field_required[]" value="'+escapeHtml(item.required ? item.required : 'required')+'"></div>';
});
}
renderPeriods();
});
@@ -0,0 +1,16 @@
<?php if (erLhcoreClassUser::instance()->hasAccessTo('lhchatcommand','use')) : ?>
<?php $escalationCommands = erLhcoreClassModelGenericBotCommand::getList(['customfilter' => ['(dep_id = 0 OR dep_id = ' . (int)$chat->dep_id . ')'], 'filter' => ['enabled_display' => 1]]); ?>
<?php if (!empty($escalationCommands)): ?>
<div class="col-6 pb-1" id="escalation-<?php echo $chat->id?>">
<div class="dropdown">
<button class="btn btn-sm dropdown-toggle text-muted p-1 pt-0 pb-0 ps-0" type="button" data-bs-toggle="dropdown" aria-expanded="false">
<span class="material-icons">keyboard_command_key</span><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/adminchat','Bot commands')?>
</button>
<ul class="dropdown-menu pt-1 pb-1 fs13">
<?php foreach ($escalationCommands as $escalationCommand): ?>
<li><a class="dropdown-item text-muted action-icon pt-1 pb-1" onclick="lhc.revealModal({'url':WWW_DIR_JAVASCRIPT+'chatcommand/command/<?php echo $chat->id?>/<?php echo $escalationCommand->id?>'})" title="!<?php echo htmlspecialchars($escalationCommand->command)?>" ><?php echo htmlspecialchars($escalationCommand->name);?></a></li>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php endif;endif; ?>
Expand Up @@ -47,6 +47,8 @@

<?php include(erLhcoreClassDesign::designtpl('lhchat/chat_tabs/actions/cobrowse.tpl.php'));?>

<?php include(erLhcoreClassDesign::designtpl('lhchat/chat_tabs/actions/escalations.tpl.php'));?>

<?php endif; ?>

<?php include(erLhcoreClassDesign::designtpl('lhchat/chat_tabs/chat_translation_tab_pre.tpl.php')); ?>
Expand Down
38 changes: 38 additions & 0 deletions lhc_web/design/defaulttheme/tpl/lhchatcommand/command.tpl.php
@@ -0,0 +1,38 @@
<?php $modalHeaderTitle = htmlspecialchars($command->name);$modalSize = 'xs';$modalHeaderClass = 'p-1';?>
<?php include(erLhcoreClassDesign::designtpl('lhkernel/modal_header.tpl.php'));?>

<form action="<?php echo erLhcoreClassDesign::baseurl('chatcommand/command')?>/<?php echo $chat->id?>/<?php echo $command->id?>" method="post" onsubmit="return lhinst.submitModalForm($(this))">

<?php if (isset($commandExecution)) : $msg = erTranslationClassLhTranslation::getInstance()->getTranslation('user/account','Processed!');$hideSuccessButton = true; ?>
<?php include(erLhcoreClassDesign::designtpl('lhkernel/alert_success.tpl.php'));?>
<?php endif; ?>

<?php if (isset($errors)) : $hideErrorButton = true;?>
<?php include(erLhcoreClassDesign::designtpl('lhkernel/validation_error.tpl.php'));?>
<?php endif; ?>

<?php foreach ($command->fields_array as $fieldIndex => $field) : ?>
<div class="form-group">
<label><?php echo htmlspecialchars($field['name'])?><?php if ((isset($field['required']) && $field['required'] == 'required') || !isset($field['required'])) : ?>*<?php endif;?></label>
<?php if ($field['type'] == 'textarea') : ?>
<textarea class="form-control form-control-sm<?php if (isset($errors['field_'.$fieldIndex])) : ?> is-invalid<?php endif;?>" name="field_<?php echo $fieldIndex?>" placeholder="<?php echo htmlspecialchars($field['placeholder'] ?? '')?>" rows="<?php echo isset($field['rows']) && (int)$field['rows'] > 0 ? (int)$field['rows'] : 2?>"><?php if (isset($commandArguments['field_' . $fieldIndex])) : ?><?php echo htmlspecialchars($commandArguments['field_' . $fieldIndex])?><?php endif;?></textarea>
<?php else : ?>
<input type="text" name="field_<?php echo $fieldIndex?>" placeholder="<?php echo htmlspecialchars($field['placeholder'] ?? '')?>" class="form-control form-control-sm<?php if (isset($errors['field_'.$fieldIndex])) : ?> is-invalid<?php endif;?>" value="<?php if (isset($commandArguments['field_' . $fieldIndex])) : ?><?php echo htmlspecialchars($commandArguments['field_' . $fieldIndex])?><?php endif;?>" />
<?php endif; ?>
</div>
<?php endforeach; ?>

<?php if (isset($commandExecution)) : ?>
<script>
lhinst.addmsgadmin(<?php echo $chat->id?>,<?php echo json_encode($commandExecution)?>);
setTimeout(function(){$('#myModal').modal('hide');},2000);
</script>
<?php endif;?>

<div class="d-flex align-items-center justify-content-center">
<button type="submit" name="ProcessCommand" <?php if (isset($commandExecution)) : ?>disabled="disabled"<?php endif;?> class="btn btn-primary btn-sm modal-submit-disable"><i class="material-icons">done</i><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/adminchat','Accept')?></button>
</div>

</form>

<?php include(erLhcoreClassDesign::designtpl('lhkernel/modal_footer.tpl.php'));?>
Expand Up @@ -16,7 +16,8 @@
<?php foreach ($items as $item) : ?>
<tr>
<td>
<a href="<?php echo erLhcoreClassDesign::baseurl('genericbot/editcommand')?>/<?php echo $item->id?>">!<?php echo htmlspecialchars($item->command)?></a>
<?php if ($item->enabled_display == 1) : ?><span title="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Visible in the chat dropdown menu');?>" class="material-icons">visibility</span><?php endif;?>
<a href="<?php echo erLhcoreClassDesign::baseurl('genericbot/editcommand')?>/<?php echo $item->id?>">!<?php echo htmlspecialchars($item->command)?></a><?php if ($item->name != '') : ?> <span class="text-muted fs14">(<?php echo htmlspecialchars($item->name);?>)</span><?php endif;?>
</td>
<td><?php echo htmlspecialchars($item->bot)?></td>
<td><?php echo htmlspecialchars($item->trigger)?></td>
Expand Down