first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
define("tool_langimport/search",["exports","core/pending","core/utils"],(function(_exports,_pending,_utils){var obj;
/**
* Add search filtering of available language packs
*
* @module tool_langimport/search
* @copyright 2021 Paul Holden <paulh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_pending=(obj=_pending)&&obj.__esModule?obj:{default:obj};const SELECTORS_AVAILABLE_LANG_SELECT="select",SELECTORS_AVAILABLE_LANG_SEARCH='[data-action="search"]';_exports.init=form=>{const availableLangsElement=form.querySelector(SELECTORS_AVAILABLE_LANG_SELECT),availableLanguages={};availableLangsElement.querySelectorAll("option").forEach((option=>{availableLanguages[option.value]=option.text})),availableLangsElement.dataset.availableLanguages=JSON.stringify(availableLanguages);const availableLangsSearch=form.querySelector(SELECTORS_AVAILABLE_LANG_SEARCH);availableLangsSearch.addEventListener("keydown",(event=>{"Enter"===event.key&&event.preventDefault()}));const availableLangsSearchDebounce=(0,_utils.debounce)((event=>{const pendingPromise=new _pending.default("tool_langimport/search:filter");availableLangsElement.querySelectorAll("option").forEach((option=>{option.remove()}));const searchTerm=event.target.value.toLowerCase(),availableLanguages=JSON.parse(availableLangsElement.dataset.availableLanguages),filteredLanguages=Object.keys(availableLanguages).reduce(((matches,langcode)=>(availableLanguages[langcode].toLowerCase().includes(searchTerm)&&(matches[langcode]=availableLanguages[langcode]),matches)),[]);Object.entries(filteredLanguages).forEach((_ref=>{let[langcode,langname]=_ref;const option=document.createElement("option");option.value=langcode,option.innerText=langname,availableLangsElement.append(option)})),pendingPromise.resolve()}),250);availableLangsSearch.addEventListener("keyup",(event=>{const pendingPromise=new _pending.default("tool_langimport/search:keyup");availableLangsSearchDebounce(event),setTimeout((()=>{pendingPromise.resolve()}),250)}))}}));
//# sourceMappingURL=search.min.js.map
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
define("tool_langimport/uninstall",["exports","core/str","core/notification","core/config"],(function(_exports,_str,_notification,_config){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_config=(obj=_config)&&obj.__esModule?obj:{default:obj};_exports.init=form=>{null==form||form.addEventListener("submit",(async e=>{var _form$querySelector;e.preventDefault();const selectedOptions=null===(_form$querySelector=form.querySelector("#menuuninstalllang"))||void 0===_form$querySelector?void 0:_form$querySelector.selectedOptions;if(null==selectedOptions||!selectedOptions.length){const alertStrings=await(0,_str.getStrings)(["noenglishuninstalltitle","selectlangs"].map((key=>({key:key,component:"tool_langimport"}))));return void(0,_notification.alert)(...alertStrings)}if(-1!==[...selectedOptions].map((node=>node.value)).indexOf("en")){const alertStrings=await(0,_str.getStrings)(["noenglishuninstalltitle","noenglishuninstall"].map((key=>({key:key,component:"tool_langimport"}))));return void(0,_notification.alert)(...alertStrings)}const confirmationStrings=await(0,_str.getStrings)([{key:"uninstall",component:"tool_langimport"},{key:"uninstallconfirm",component:"tool_langimport",param:[...selectedOptions].map((node=>node.textContent)).join(", ")},{key:"yes",component:"core"}]);(0,_notification.saveCancelPromise)(...confirmationStrings).then((()=>{const url=new URL(form.action);return url.searchParams.append("sesskey",_config.default.sesskey),url.searchParams.append("confirmtouninstall",[...selectedOptions].map((node=>node.value)).join("/")),form.action=url.toString(),form.submit(),!0})).catch((()=>!1))}))}}));
//# sourceMappingURL=uninstall.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"uninstall.min.js","sources":["../src/uninstall.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\nimport {getStrings} from 'core/str';\nimport {saveCancelPromise, alert as displayAlert} from \"core/notification\";\nimport MoodleConfig from 'core/config';\n\nexport const init = (form) => {\n form?.addEventListener('submit', async(e) => {\n e.preventDefault();\n const selectedOptions = form.querySelector('#menuuninstalllang')?.selectedOptions;\n if (!selectedOptions?.length) {\n const alertStrings = await getStrings(\n ['noenglishuninstalltitle', 'selectlangs'].map((key) => ({key, component: 'tool_langimport'})\n ));\n displayAlert(...alertStrings);\n return;\n }\n\n if ([...selectedOptions].map((node) => node.value).indexOf('en') !== -1) {\n const alertStrings = await getStrings(\n ['noenglishuninstalltitle', 'noenglishuninstall'].map((key) => ({key, component: 'tool_langimport'})\n ));\n displayAlert(...alertStrings);\n return;\n }\n\n const confirmationStrings = await getStrings([\n {\n key: 'uninstall',\n component: 'tool_langimport',\n },\n {\n key: 'uninstallconfirm',\n component: 'tool_langimport',\n param: [...selectedOptions].map((node) => node.textContent).join(', '),\n },\n {\n key: 'yes',\n component: 'core',\n },\n ]);\n\n saveCancelPromise(...confirmationStrings).then(() => {\n const url = new URL(form.action);\n url.searchParams.append('sesskey', MoodleConfig.sesskey);\n url.searchParams.append('confirmtouninstall', [...selectedOptions].map((node) => node.value).join('/'));\n form.action = url.toString();\n form.submit();\n return true;\n })\n .catch(() => {\n return false;\n });\n });\n};\n"],"names":["form","addEventListener","async","e","preventDefault","selectedOptions","querySelector","_form$querySelector","length","alertStrings","map","key","component","node","value","indexOf","confirmationStrings","param","textContent","join","then","url","URL","action","searchParams","append","MoodleConfig","sesskey","toString","submit","catch"],"mappings":"sSAmBqBA,OACjBA,MAAAA,MAAAA,KAAMC,iBAAiB,UAAUC,MAAAA,4BAC7BC,EAAEC,uBACIC,4CAAkBL,KAAKM,cAAc,4DAAnBC,oBAA0CF,mBAC7DA,MAAAA,kBAAAA,gBAAiBG,OAAQ,OACpBC,mBAAqB,mBACvB,CAAC,0BAA2B,eAAeC,KAAKC,OAAUA,IAAAA,IAAKC,UAAW,6DAE9DH,kBAIkD,IAAlE,IAAIJ,iBAAiBK,KAAKG,MAASA,KAAKC,QAAOC,QAAQ,MAAc,OAC/DN,mBAAqB,mBACvB,CAAC,0BAA2B,sBAAsBC,KAAKC,OAAUA,IAAAA,IAAKC,UAAW,6DAErEH,oBAIdO,0BAA4B,mBAAW,CACzC,CACIL,IAAK,YACLC,UAAW,mBAEf,CACID,IAAK,mBACLC,UAAW,kBACXK,MAAO,IAAIZ,iBAAiBK,KAAKG,MAASA,KAAKK,cAAaC,KAAK,OAErE,CACIR,IAAK,MACLC,UAAW,iDAIEI,qBAAqBI,MAAK,WACrCC,IAAM,IAAIC,IAAItB,KAAKuB,eACzBF,IAAIG,aAAaC,OAAO,UAAWC,gBAAaC,SAChDN,IAAIG,aAAaC,OAAO,qBAAsB,IAAIpB,iBAAiBK,KAAKG,MAASA,KAAKC,QAAOK,KAAK,MAClGnB,KAAKuB,OAASF,IAAIO,WAClB5B,KAAK6B,UACE,KAEVC,OAAM,KACI"}
+96
View File
@@ -0,0 +1,96 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Add search filtering of available language packs
*
* @module tool_langimport/search
* @copyright 2021 Paul Holden <paulh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import Pending from 'core/pending';
import {debounce} from 'core/utils';
const SELECTORS = {
AVAILABLE_LANG_SELECT: 'select',
AVAILABLE_LANG_SEARCH: '[data-action="search"]',
};
const DEBOUNCE_TIMER = 250;
/**
* Initialize module
*
* @param {Element} form
*/
export const init = form => {
const availableLangsElement = form.querySelector(SELECTORS.AVAILABLE_LANG_SELECT);
const availableLangsFilter = (event) => {
const pendingPromise = new Pending('tool_langimport/search:filter');
// Remove existing options.
availableLangsElement.querySelectorAll('option').forEach((option) => {
option.remove();
});
// Filter for matching languages.
const searchTerm = event.target.value.toLowerCase();
const availableLanguages = JSON.parse(availableLangsElement.dataset.availableLanguages);
const filteredLanguages = Object.keys(availableLanguages).reduce((matches, langcode) => {
if (availableLanguages[langcode].toLowerCase().includes(searchTerm)) {
matches[langcode] = availableLanguages[langcode];
}
return matches;
}, []);
// Re-create filtered options.
Object.entries(filteredLanguages).forEach(([langcode, langname]) => {
const option = document.createElement('option');
option.value = langcode;
option.innerText = langname;
availableLangsElement.append(option);
});
pendingPromise.resolve();
};
// Cache initial available language options.
const availableLanguages = {};
availableLangsElement.querySelectorAll('option').forEach((option) => {
availableLanguages[option.value] = option.text;
});
availableLangsElement.dataset.availableLanguages = JSON.stringify(availableLanguages);
// Register event listeners on the search element.
const availableLangsSearch = form.querySelector(SELECTORS.AVAILABLE_LANG_SEARCH);
availableLangsSearch.addEventListener('keydown', (event) => {
if (event.key === 'Enter') {
event.preventDefault();
}
});
// Debounce the event listener to allow the user to finish typing.
const availableLangsSearchDebounce = debounce(availableLangsFilter, DEBOUNCE_TIMER);
availableLangsSearch.addEventListener('keyup', (event) => {
const pendingPromise = new Pending('tool_langimport/search:keyup');
availableLangsSearchDebounce(event);
setTimeout(() => {
pendingPromise.resolve();
}, DEBOUNCE_TIMER);
});
};
@@ -0,0 +1,68 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
import {getStrings} from 'core/str';
import {saveCancelPromise, alert as displayAlert} from "core/notification";
import MoodleConfig from 'core/config';
export const init = (form) => {
form?.addEventListener('submit', async(e) => {
e.preventDefault();
const selectedOptions = form.querySelector('#menuuninstalllang')?.selectedOptions;
if (!selectedOptions?.length) {
const alertStrings = await getStrings(
['noenglishuninstalltitle', 'selectlangs'].map((key) => ({key, component: 'tool_langimport'})
));
displayAlert(...alertStrings);
return;
}
if ([...selectedOptions].map((node) => node.value).indexOf('en') !== -1) {
const alertStrings = await getStrings(
['noenglishuninstalltitle', 'noenglishuninstall'].map((key) => ({key, component: 'tool_langimport'})
));
displayAlert(...alertStrings);
return;
}
const confirmationStrings = await getStrings([
{
key: 'uninstall',
component: 'tool_langimport',
},
{
key: 'uninstallconfirm',
component: 'tool_langimport',
param: [...selectedOptions].map((node) => node.textContent).join(', '),
},
{
key: 'yes',
component: 'core',
},
]);
saveCancelPromise(...confirmationStrings).then(() => {
const url = new URL(form.action);
url.searchParams.append('sesskey', MoodleConfig.sesskey);
url.searchParams.append('confirmtouninstall', [...selectedOptions].map((node) => node.value).join('/'));
form.action = url.toString();
form.submit();
return true;
})
.catch(() => {
return false;
});
});
};