Skip to content
Snippets Groups Projects
Commit 6039e0ba authored by Marcus Johansson's avatar Marcus Johansson
Browse files

Issue #3487155: Remove voting for the user message

parent 30fa3079
No related branches found
No related tags found
1 merge request!2Issue #3487155: Remove voting for the user message
......@@ -31,40 +31,46 @@ function ai_evaluations_cron() {
}
}
/**
* Implements hook_preprocess_HOOK() for ai_chatbot.
*/
function ai_evaluations_preprocess_ai_chatbot(&$variables) {
$variables['#attached'] = [
'library' => [
'core/drupal.ajax',
'ai_evaluations/evaluations',
],
];
}
/**
* Implements hook_preprocess_HOOK() for ai_chatbot_message.
*/
function ai_evaluations_preprocess_ai_chatbot_message(&$variables) {
$variables['evaluation'] = [
'downvote' => Link::fromTextAndUrl([
'#theme' => 'image',
'#uri' => \Drupal::moduleHandler()->getModule('ai_evaluations')->getPath() . '/assets/dislike-button-icon.svg',
'#alt' => new TranslatableMarkup('Downvote'),
], Url::fromRoute('ai_evaluations.vote', [
'assistant_id' => $variables['assistant_id'] ?? NULL,
'thread_id' => $variables['thread_id'] ?? NULL,
'vote' => 0,
]))->toRenderable()
+ [
'#attributes' => ['class' => ['use-ajax', 'ai-evaluation-vote', 'ai-evaluation-vote--downvote']],
],
'upvote' => Link::fromTextAndUrl([
'#theme' => 'image',
'#uri' => \Drupal::moduleHandler()->getModule('ai_evaluations')->getPath() . '/assets/dislike-button-icon.svg',
'#alt' => new TranslatableMarkup('Downvote'),
'#uri' => \Drupal::moduleHandler()->getModule('ai_evaluations')->getPath() . '/assets/like-button-icon.svg',
'#alt' => new TranslatableMarkup('Upvote'),
], Url::fromRoute('ai_evaluations.vote', [
'assistant_id' => $variables['assistant_id'] ?? NULL,
'thread_id' => $variables['thread_id'] ?? NULL,
'vote' => 0,
]))->toRenderable()
+ [
'#attributes' => ['class' => ['use-ajax', 'ai-evaluation-vote', 'ai-evaluation-vote--downvote']],
],
'upvote' => Link::fromTextAndUrl([
'#theme' => 'image',
'#uri' => \Drupal::moduleHandler()->getModule('ai_evaluations')->getPath() . '/assets/like-button-icon.svg',
'#alt' => new TranslatableMarkup('Upvote'),
], Url::fromRoute('ai_evaluations.vote', [
'assistant_id' => $variables['assistant_id'] ?? NULL,
'thread_id' => $variables['thread_id'] ?? NULL,
'vote' => 1,
]))->toRenderable()
+ [
'#attributes' => ['class' => ['use-ajax', 'ai-evaluation-vote', 'ai-evaluation-vote--upvote']],
],
'#attached' => [
'library' => [
'core/drupal.ajax',
'ai_evaluations/evaluations',
],
'assistant_id' => $variables['assistant_id'] ?? NULL,
'thread_id' => $variables['thread_id'] ?? NULL,
'vote' => 1,
]))->toRenderable()
+ [
'#attributes' => ['class' => ['use-ajax', 'ai-evaluation-vote', 'ai-evaluation-vote--upvote']],
],
];
}
......
......@@ -19,7 +19,7 @@
</div>
{% if evaluation %}
{% if evaluation and user == 'assistant' %}
<div class="chat-message-evaluation">
{{ evaluation }}
</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