Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)
This commit is contained in:
@@ -58,6 +58,20 @@ export default class KimaiPlugin {
|
||||
return this.getContainer().getConfiguration().get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {KimaiConfiguration}
|
||||
*/
|
||||
getConfigurations() {
|
||||
return this.getContainer().getConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {KimaiDateUtils}
|
||||
*/
|
||||
getDateUtils() {
|
||||
return this.getPlugin('date');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns {KimaiPlugin}
|
||||
@@ -66,11 +80,82 @@ export default class KimaiPlugin {
|
||||
return this.getContainer().getPlugin(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {KimaiTranslation}
|
||||
*/
|
||||
getTranslation() {
|
||||
return this.getContainer().getTranslation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns {string}
|
||||
*/
|
||||
translate(name) {
|
||||
return this.getTranslation().get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} title
|
||||
* @returns {string}
|
||||
*/
|
||||
escape(title) {
|
||||
return this.getPlugin('escape').escapeForHtml(title);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {string|null} details
|
||||
*/
|
||||
trigger(name, details = null) {
|
||||
this.getPlugin('event').trigger(name, details);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} url
|
||||
* @param {object} options
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
fetch(url, options = {}) {
|
||||
return this.getPlugin('fetch').fetch(url, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HTMLFormElement} form
|
||||
* @param {object} options
|
||||
* @param {string|null} url
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
fetchForm(form, options = {}, url = null) {
|
||||
url = url || form.getAttribute('action');
|
||||
const method = form.getAttribute('method').toUpperCase();
|
||||
|
||||
if (method === 'GET') {
|
||||
const data = this.getPlugin('form').convertFormDataToQueryString(form, {}, true);
|
||||
// TODO const data = new URLSearchParams(new FormData(form)).toString();
|
||||
url = url + (url.includes('?') ? '&' : '?') + data;
|
||||
options = {...{method: 'GET'}, ...options};
|
||||
} else if (method === 'POST') {
|
||||
options = {...{
|
||||
method: 'POST',
|
||||
body: new FormData(form)
|
||||
}, ...options};
|
||||
}
|
||||
|
||||
return this.fetch(url, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current device is a mobile device (targeting the bootstrip xs breakpoint size).
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isMobile() {
|
||||
const width = Math.max(
|
||||
document.documentElement.clientWidth,
|
||||
window.innerWidth || 0
|
||||
)
|
||||
|
||||
return width < 576;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user