but what i was doing was a compact view for multiple entities controlled by a user-defined toggle
at the time of posting, i think the user api endpoint on my host was stuck and was only showing the first user. After rebooting Docker, i found that it would serve the current logged-in user so i was able to use those details to turn on and off a style sheet via js
here is how i did it
<the call>
Code:
document.addEventListener('DOMContentLoaded', () => {
Espo.loader.require('hiden:User', async function (User) {
const myInstance = new User();
const isCompact = await myInstance.checkIsCompact();
if (isCompact) {
loadCSS('client/custom/css/compact.css');
}
});
});
Code:
define('hiden:User', [], function () {
class User {
async checkIsCompact() {
const response = await fetch('api/v1/App/user');
const data = await response.json();
return data.user.cCompactView;
}
}
return User;
});
function loadCSS(url) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = url;
document.head.appendChild(link);
}

Leave a comment: