MDL-83123 AI: Course Assistance Placement Drawer compatibility.

This commit is contained in:
raortegar 2024-09-19 15:55:57 +02:00
parent cb4e621ce9
commit fa931c6885
7 changed files with 28 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,3 @@
define("aiplacement_courseassist/selectors",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={ELEMENTS:{AIDRAWER:"#ai-drawer",AIDRAWER_BODY:"#ai-drawer .ai-drawer-body",PAGE:"#page",MAIN_REGION:'[role="main"]'},ACTIONS:{SUMMARY:'[data-action="course-summarise"]',RETRY:'[data-action="course-summarise-retry"]',DECLINE:'[data-action="course-summarise-policy-decline"]',ACCEPT:'.ai-policy-block [data-action="accept"]',REGENERATE:'[data-action="course-summarise-regenerate"]',CANCEL:'.ai-policy-block [data-action="decline"]'}},_exports.default}));
define("aiplacement_courseassist/selectors",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={ELEMENTS:{AIDRAWER:"#ai-drawer",AIDRAWER_BODY:"#ai-drawer .ai-drawer-body",PAGE:"#page",MAIN_REGION:'[role="main"]',MESSAGE_DRAWER:'.message-app[data-region="message-drawer"]',MESSAGE_DRAWER_TOGGLE:'[id^="message-drawer-toggle"]'},ACTIONS:{SUMMARY:'[data-action="course-summarise"]',RETRY:'[data-action="course-summarise-retry"]',DECLINE:'[data-action="course-summarise-policy-decline"]',ACCEPT:'.ai-policy-block [data-action="accept"]',REGENERATE:'[data-action="course-summarise-regenerate"]',CANCEL:'.ai-policy-block [data-action="decline"]'}},_exports.default}));
//# sourceMappingURL=selectors.min.js.map

View File

@ -1 +1 @@
{"version":3,"file":"selectors.min.js","sources":["../src/selectors.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Define all of the selectors we will be using on the AI Course assistant.\n *\n * @module aiplacement_courseassist/selectors\n * @copyright 2024 Huong Nguyen <huongnv13@gmail.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n ELEMENTS: {\n AIDRAWER: '#ai-drawer',\n AIDRAWER_BODY: '#ai-drawer .ai-drawer-body',\n PAGE: '#page',\n MAIN_REGION: '[role=\"main\"]',\n },\n ACTIONS: {\n SUMMARY: '[data-action=\"course-summarise\"]',\n RETRY: '[data-action=\"course-summarise-retry\"]',\n DECLINE: '[data-action=\"course-summarise-policy-decline\"]',\n ACCEPT: '.ai-policy-block [data-action=\"accept\"]',\n REGENERATE: '[data-action=\"course-summarise-regenerate\"]',\n CANCEL: '.ai-policy-block [data-action=\"decline\"]',\n }\n};\n"],"names":["ELEMENTS","AIDRAWER","AIDRAWER_BODY","PAGE","MAIN_REGION","ACTIONS","SUMMARY","RETRY","DECLINE","ACCEPT","REGENERATE","CANCEL"],"mappings":"oLAsBe,CACXA,SAAU,CACNC,SAAU,aACVC,cAAe,6BACfC,KAAM,QACNC,YAAa,iBAEjBC,QAAS,CACLC,QAAS,mCACTC,MAAO,yCACPC,QAAS,kDACTC,OAAQ,0CACRC,WAAY,8CACZC,OAAQ"}
{"version":3,"file":"selectors.min.js","sources":["../src/selectors.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Define all of the selectors we will be using on the AI Course assistant.\n *\n * @module aiplacement_courseassist/selectors\n * @copyright 2024 Huong Nguyen <huongnv13@gmail.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n ELEMENTS: {\n AIDRAWER: '#ai-drawer',\n AIDRAWER_BODY: '#ai-drawer .ai-drawer-body',\n PAGE: '#page',\n MAIN_REGION: '[role=\"main\"]',\n MESSAGE_DRAWER: '.message-app[data-region=\"message-drawer\"]',\n MESSAGE_DRAWER_TOGGLE: '[id^=\"message-drawer-toggle\"]',\n },\n ACTIONS: {\n SUMMARY: '[data-action=\"course-summarise\"]',\n RETRY: '[data-action=\"course-summarise-retry\"]',\n DECLINE: '[data-action=\"course-summarise-policy-decline\"]',\n ACCEPT: '.ai-policy-block [data-action=\"accept\"]',\n REGENERATE: '[data-action=\"course-summarise-regenerate\"]',\n CANCEL: '.ai-policy-block [data-action=\"decline\"]',\n }\n};\n"],"names":["ELEMENTS","AIDRAWER","AIDRAWER_BODY","PAGE","MAIN_REGION","MESSAGE_DRAWER","MESSAGE_DRAWER_TOGGLE","ACTIONS","SUMMARY","RETRY","DECLINE","ACCEPT","REGENERATE","CANCEL"],"mappings":"oLAsBe,CACXA,SAAU,CACNC,SAAU,aACVC,cAAe,6BACfC,KAAM,QACNC,YAAa,gBACbC,eAAgB,6CAChBC,sBAAuB,iCAE3BC,QAAS,CACLC,QAAS,mCACTC,MAAO,yCACPC,QAAS,kDACTC,OAAQ,0CACRC,WAAY,8CACZC,OAAQ"}

View File

@ -28,6 +28,7 @@ import Notification from 'core/notification';
import Selectors from 'aiplacement_courseassist/selectors';
import Policy from 'core_ai/policy';
import AIHelper from 'core_ai/helper';
import Drawer from 'core/drawer';
const AICourseAssist = class {
@ -76,6 +77,15 @@ const AICourseAssist = class {
// Display summary.
this.displaySummary();
}
// Close AI drawer if message drawer is open.
const messageDrawerToggle = e.target.closest(Selectors.ELEMENTS.MESSAGE_DRAWER_TOGGLE);
if (messageDrawerToggle && this.isAIDrawerOpen()) {
const messageDrawer = document.querySelector(Selectors.ELEMENTS.MESSAGE_DRAWER);
if (messageDrawer && !messageDrawer.classList.contains('hidden')) {
this.closeAIDrawer();
messageDrawerToggle.focus();
}
}
});
}
@ -164,6 +174,7 @@ const AICourseAssist = class {
* Open the AI drawer.
*/
openAIDrawer() {
this.closeMessageDrawer();
this.aiDrawerElement.classList.add('show');
this.aiDrawerBodyElement.setAttribute('aria-live', 'polite');
if (!this.pageElement.classList.contains('show-drawer-right')) {
@ -173,6 +184,16 @@ const AICourseAssist = class {
this.disableSummaryButton();
}
/**
* Close message drawer.
*/
closeMessageDrawer() {
var messageElement = document.querySelector(Selectors.ELEMENTS.MESSAGE_DRAWER).parentElement;
if (!messageElement.classList.contains('hidden')) {
Drawer.hide(messageElement);
}
}
/**
* Close the AI drawer.
*/

View File

@ -26,6 +26,8 @@ export default {
AIDRAWER_BODY: '#ai-drawer .ai-drawer-body',
PAGE: '#page',
MAIN_REGION: '[role="main"]',
MESSAGE_DRAWER: '.message-app[data-region="message-drawer"]',
MESSAGE_DRAWER_TOGGLE: '[id^="message-drawer-toggle"]',
},
ACTIONS: {
SUMMARY: '[data-action="course-summarise"]',

View File

@ -5,7 +5,7 @@
right: calc(-315px + -10px);
width: 315px;
background-color: #f8f9fa;
z-index: 2001;
z-index: 1016;
transition: right 0.2s ease, top 0.2s ease, bottom 0.2s ease, visibility 0.2s ease, transform 0.5s ease;
visibility: hidden;
}