v1.0.29 - JS reads config, hides only configured

This commit is contained in:
2026-04-16 16:44:04 +02:00
parent f538bafa82
commit adcf3e62ad
2 changed files with 55 additions and 10 deletions

View File

@@ -4,7 +4,7 @@
<name>Minimal Profile</name> <name>Minimal Profile</name>
<summary>Hides profile fields to create a minimal user profile</summary> <summary>Hides profile fields to create a minimal user profile</summary>
<description>Allows administrators to hide profile fields like pronouns, social links, etc.</description> <description>Allows administrators to hide profile fields like pronouns, social links, etc.</description>
<version>1.0.28</version> <version>1.0.29</version>
<licence>AGPL</licence> <licence>AGPL</licence>
<author>Your Name</author> <author>Your Name</author>
<namespace>MinimalProfile</namespace> <namespace>MinimalProfile</namespace>

View File

@@ -1,15 +1,60 @@
/** /**
* Minimal Profile - Test JS loading * Minimal Profile - Load and hide configured fields
*/ */
(function() { (function() {
'use strict'; 'use strict';
console.log('MinimalProfile JS: START'); console.log('MinimalProfile: START');
// Load CSS directly var fieldSelectors = {
var link = document.createElement('link'); 'pronouns': '#account-property-pronouns',
link.rel = 'stylesheet'; 'role': '#account-property-role',
link.href = OC.linkTo('minimalprofile', 'css/minimalprofile.css'); 'headline': '#account-property-headline',
document.head.appendChild(link); 'biography': '#account-property-biography',
'organisation': '#account-property-organisation',
console.log('MinimalProfile JS: CSS loaded from ' + link.href); 'phone': '#account-property-phone',
'address': '#account-property-address',
'birthdate': '#account-property-birthdate',
'website': '#account-property-website',
'twitter': '#account-property-twitter',
'fediverse': '#account-property-fediverse',
'location': '#account-property-location'
};
function applyCss(hiddenFields) {
if (!hiddenFields || hiddenFields.length === 0) {
console.log('MinimalProfile: No fields to hide');
return;
}
var css = '';
hiddenFields.forEach(function(field) {
var selector = fieldSelectors[field];
if (selector) {
css += '.personal-settings-setting-box:has(' + selector + ') { display: none !important; }';
console.log('MinimalProfile: Hiding ' + field);
}
});
if (css) {
var style = document.createElement('style');
style.textContent = css;
document.head.appendChild(style);
console.log('MinimalProfile: CSS applied');
}
}
// Fetch config
var req = new XMLHttpRequest();
req.onload = function() {
if (req.status === 200) {
try {
var data = JSON.parse(req.responseText);
applyCss(data.hiddenFields || []);
} catch (e) {
console.error('MinimalProfile: Parse error', e);
}
}
};
req.open('GET', OC.generateUrl('/apps/minimalprofile/api/v1/hidden-fields'));
req.send();
})(); })();