Skip to content

Commit

Permalink
MBS-9498: Changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Garske committed Nov 14, 2024
1 parent 393c326 commit 374f258
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 96 deletions.
2 changes: 1 addition & 1 deletion amd/build/dialog.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/dialog.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/helper.min.js

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

2 changes: 1 addition & 1 deletion amd/build/helper.min.js.map

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

20 changes: 11 additions & 9 deletions amd/src/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const init = async(params) => {

// Add class for styling when modal is displayed.
modal.getRoot().on('modal:shown', function(e) {
e.target.classList.add("ai_chat_modal");
e.target.classList.add("block_ai_chat_modal");
});

// Conditionally prevent outside click event.
Expand Down Expand Up @@ -211,7 +211,9 @@ async function showModal() {
// Show userquota.
await renderUserQuota('#block_ai_chat_userquota', ['chat']);
// Show infobox.
await renderInfoBox('block_ai_chat', userid, '.ai_chat_modal_body [data-content="local_ai_manager_infobox"]', ['chat']);
await renderInfoBox(
'block_ai_chat', userid, '.block_ai_chat_modal_body [data-content="local_ai_manager_infobox"]', ['chat']
);

// Check if all permissions and settings are correct.
const message = await userAllowed();
Expand Down Expand Up @@ -332,7 +334,7 @@ const enterQuestion = async(question) => {
}

// Attach copy listener.
let copy = document.querySelector('.ai_chat_modal .awaitanswer .copy');
let copy = document.querySelector('.block_ai_chat_modal .awaitanswer .copy');
copy.addEventListener('mousedown', () => {
helper.copyToClipboard(copy);
});
Expand All @@ -358,14 +360,14 @@ const enterQuestion = async(question) => {
*/
const showReply = async(text) => {
// Get textblock.
let fields = document.querySelectorAll('.ai_chat_modal .awaitanswer .text');
let fields = document.querySelectorAll('.block_ai_chat_modal .awaitanswer .text');
const field = fields[fields.length - 1];
// Render the reply.
field.innerHTML = text;
field.classList.remove('small');

// Remove awaitanswer class.
let awaitdivs = document.querySelectorAll('.ai_chat_modal .awaitanswer');
let awaitdivs = document.querySelectorAll('.block_ai_chat_modal .awaitanswer');
const awaitdiv = awaitdivs[awaitdivs.length - 1];
awaitdiv.classList.remove('awaitanswer');
};
Expand Down Expand Up @@ -485,7 +487,7 @@ const showHistory = async() => {
});

// Set modal class to hide info about ratelimits and infobox.
let modal = document.querySelector('.ai_chat_modal');
let modal = document.querySelector('.block_ai_chat_modal');
modal.classList.add('onhistorypage');

// Iterate over conversations and group by date.
Expand Down Expand Up @@ -549,7 +551,7 @@ const showHistory = async() => {
"dates": convert.groups,
};
const {html, js} = await Templates.renderForPromise('block_ai_chat/history', templateData);
Templates.appendNodeContents('.ai_chat_modal .block_ai_chat-output', html, js);
Templates.appendNodeContents('.block_ai_chat_modal .block_ai_chat-output', html, js);

// Add a listener for the new dialog button.
const btnNewDialog = document.getElementById('ai_chat_history_new_dialog');
Expand Down Expand Up @@ -603,7 +605,7 @@ const clearMessages = (hideinput = false) => {
* @param {*} setTitle
*/
const setModalHeader = (setTitle = '') => {
let modalheader = document.querySelector('.ai_chat_modal .modal-title div');
let modalheader = document.querySelector('.block_ai_chat_modal .modal-title div');
let title = '';
if (modalheader !== null && (conversation.messages.length > 0 || setTitle.length)) {
if (!setTitle.length) {
Expand All @@ -614,7 +616,7 @@ const setModalHeader = (setTitle = '') => {
modalheader.innerHTML = title;
}
// Remove onhistorypage, since history page is setting it.
let modal = document.querySelector('.ai_chat_modal');
let modal = document.querySelector('.block_ai_chat_modal');
modal.classList.remove('onhistorypage');
};

Expand Down
4 changes: 2 additions & 2 deletions amd/src/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const copyToClipboard = (element) => {
* Attach copy listener to all elements.
*/
export const attachCopyListenerLast = () => {
const elements = document.querySelectorAll(".ai_chat_modal .copy");
const elements = document.querySelectorAll(".block_ai_chat_modal .copy");
const last = elements[elements.length - 1];
last.addEventListener('click', function() {
copyToClipboard(last);
Expand All @@ -47,7 +47,7 @@ export const focustextarea = () => {
* Scroll to bottom of modal body.
*/
export const scrollToBottom = () => {
const modalContent = document.querySelector('.ai_chat_modal .modal-body .block_ai_chat-output-wrapper');
const modalContent = document.querySelector('.block_ai_chat_modal .modal-body .block_ai_chat-output-wrapper');
modalContent.scrollTop = modalContent.scrollHeight;
};

Expand Down
2 changes: 1 addition & 1 deletion lang/de/block_ai_chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
$string['noticenewquestion'] = 'Aktuell können sie keine Frage mehr übermitteln';
$string['openfull'] = 'Vollflächig öffnen';
$string['pluginname'] = 'KI-Chat';
$string['privacy:metadata'] = 'Dieses Plugin speichert keine Daten, Konversationen werden im AI Manager gespeichert.';
$string['privacy:metadata'] = 'Konversationen werden im AI Manager gespeichert.';
$string['private'] = 'Privat';
$string['public'] = 'Öffentlich';
$string['replacehelp'] = 'Ai Chat-Button anstelle des Hilfe-Buttons anzeigen.';
Expand Down
2 changes: 1 addition & 1 deletion lang/en/block_ai_chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
$string['noticenewquestion'] = 'Currently you cant submit a new question';
$string['openfull'] = 'Use full width';
$string['pluginname'] = 'AI Chat';
$string['privacy:metadata'] = 'This plugin doesn\'t store personal data.';
$string['privacy:metadata'] = 'Conversations are saved by local_ai_manager.';
$string['private'] = 'Private';
$string['public'] = 'Public';
$string['replacehelp'] = 'Replace helpbutton with block_ai_chat button';
Expand Down
Loading

0 comments on commit 374f258

Please sign in to comment.