Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
{"version":3,"file":"overviewpage.min.js","sources":["../../../src/local/overview/overviewpage.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 * Controls the fragment overview loadings.\n *\n * @module     core_course/local/overview/overviewpage\n * @copyright  2025 Ferran Recio <ferran@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport CourseContent from 'core_courseformat/local/content';\nimport {eventTypes as collapsableSectionEventTypes} from 'core/local/collapsable_section/events';\nimport Fragment from 'core/fragment';\nimport {getCurrentCourseEditor} from 'core_courseformat/courseeditor';\nimport Pending from 'core/pending';\nimport Templates from 'core/templates';\n\n/**\n * Initialize the overview page.\n *\n * @param {String} selector The selector where the overview page is located.\n */\nexport const init = async(selector) => {\n    const pageElement = document.querySelector(selector);\n    if (!pageElement) {\n        throw new Error('No elements found with the selector: ' + selector);\n    }\n\n    pageElement.addEventListener(\n        collapsableSectionEventTypes.shown,\n        event => {\n            const fragmentElement = getFragmentContainer(event.target);\n            if (!fragmentElement) {\n                return;\n            }\n            loadFragmentContent(fragmentElement);\n        }\n    );\n\n    // The overview page is considered an alternative course view page so it must\n    // include the course content component to capture any possible action. For example,\n    // capturing manual completion toggles.\n    return new CourseContent({\n        element: pageElement,\n        reactive: getCurrentCourseEditor(),\n    });\n};\n\n/**\n * Load the fragment content.\n *\n * @private\n * @param {HTMLElement} element The element where the fragment content will be loaded.\n */\nconst loadFragmentContent = (element) => {\n    if (element.dataset.loaded) {\n        return;\n    }\n\n    const pendingReload = new Pending(`course_overviewtable_${element.dataset.modname}`);\n\n    const promise = Fragment.loadFragment(\n        'core_course',\n        'course_overview',\n        element.dataset.contextid,\n        {\n            courseid: element.dataset.courseid,\n            modname: element.dataset.modname,\n        }\n    );\n\n    promise.then(async(html, js) => {\n        Templates.runTemplateJS(js);\n        element.innerHTML = html;\n        // Templates.replaceNode(element, html, js);\n        element.dataset.loaded = true;\n        pendingReload.resolve();\n        return true;\n    }).catch(() => {\n        pendingReload.resolve();\n    });\n};\n\n/**\n * Get the fragment container.\n *\n * @private\n * @param {HTMLElement} element The element where the fragment container is located.\n * @return {HTMLElement|null} The fragment container.\n */\nconst getFragmentContainer = (element) => {\n    const result = element.querySelector('[data-region=\"loading-icon-container\"]');\n    if (!result) {\n        return null;\n    }\n    if (!result.dataset.contextid || !result.dataset.courseid || !result.dataset.modname) {\n        throw new Error('The element is missing required data attributes.');\n    }\n    return result;\n};\n"],"names":["async","pageElement","document","querySelector","selector","Error","addEventListener","collapsableSectionEventTypes","shown","event","fragmentElement","getFragmentContainer","target","loadFragmentContent","CourseContent","element","reactive","dataset","loaded","pendingReload","Pending","modname","Fragment","loadFragment","contextid","courseid","then","html","js","runTemplateJS","innerHTML","resolve","catch","result"],"mappings":";;;;;;;8QAmCoBA,MAAAA,iBACVC,YAAcC,SAASC,cAAcC,cACtCH,kBACK,IAAII,MAAM,wCAA0CD,iBAG9DH,YAAYK,iBACRC,mBAA6BC,OAC7BC,cACUC,gBAAkBC,qBAAqBF,MAAMG,QAC9CF,iBAGLG,oBAAoBH,oBAOrB,IAAII,iBAAc,CACrBC,QAASd,YACTe,UAAU,mDAUZH,oBAAuBE,aACrBA,QAAQE,QAAQC,oBAIdC,cAAgB,IAAIC,gDAAgCL,QAAQE,QAAQI,UAE1DC,kBAASC,aACrB,cACA,kBACAR,QAAQE,QAAQO,UAChB,CACIC,SAAUV,QAAQE,QAAQQ,SAC1BJ,QAASN,QAAQE,QAAQI,UAIzBK,MAAK1B,MAAM2B,KAAMC,yBACXC,cAAcD,IACxBb,QAAQe,UAAYH,KAEpBZ,QAAQE,QAAQC,QAAS,EACzBC,cAAcY,WACP,KACRC,OAAM,KACLb,cAAcY,cAWhBpB,qBAAwBI,gBACpBkB,OAASlB,QAAQZ,cAAc,8CAChC8B,cACM,SAENA,OAAOhB,QAAQO,YAAcS,OAAOhB,QAAQQ,WAAaQ,OAAOhB,QAAQI,cACnE,IAAIhB,MAAM,2DAEb4B"}