v1.0.41 - fix routes.xml, use API for config
This commit is contained in:
@@ -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.35</version>
|
<version>1.0.41</version>
|
||||||
<licence>AGPL</licence>
|
<licence>AGPL</licence>
|
||||||
<author>Your Name</author>
|
<author>Your Name</author>
|
||||||
<namespace>MinimalProfile</namespace>
|
<namespace>MinimalProfile</namespace>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<routes>
|
<routes>
|
||||||
<route url="/apps/minimalprofile/api/v1/hidden-fields" method="GET" controller="OCA\MinimalProfile\Controller\ApiController:getHiddenFields"/>
|
<route url="/apps/minimalprofile/api/v1/hidden-fields" method="GET" controller="OCA\MinimalProfile\Controller\ApiController" action="getHiddenFields"/>
|
||||||
</routes>
|
</routes>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Minimal Profile v40 - NEW SCRIPT
|
* MinimalProfile v41 - API-based config
|
||||||
*/
|
*/
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
@@ -8,14 +8,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('MinimalProfile v40: HERE');
|
console.log('MinimalProfile v41: Starting');
|
||||||
|
|
||||||
var storageKey = 'minimalprofile_hidden';
|
|
||||||
var stored = localStorage.getItem(storageKey);
|
|
||||||
var hidden = stored ? JSON.parse(stored) : [];
|
|
||||||
var urlParam = new URLSearchParams(window.location.search).get('hide');
|
|
||||||
if (urlParam) hidden = urlParam.split(',');
|
|
||||||
if (!hidden.length) return;
|
|
||||||
|
|
||||||
var map = {
|
var map = {
|
||||||
'pronouns': '#account-property-pronouns',
|
'pronouns': '#account-property-pronouns',
|
||||||
@@ -23,17 +16,45 @@
|
|||||||
'headline': '#account-property-headline'
|
'headline': '#account-property-headline'
|
||||||
};
|
};
|
||||||
|
|
||||||
var css = '';
|
function hideFields(hidden) {
|
||||||
hidden.forEach(function(f) {
|
if (!hidden || !hidden.length) return;
|
||||||
if (map[f]) {
|
|
||||||
css += '.personal-settings-setting-box:has(' + map[f] + ') { display: none !important; }';
|
var css = '';
|
||||||
console.log('Hiding:', f);
|
hidden.forEach(function(f) {
|
||||||
|
if (map[f]) {
|
||||||
|
css += '.personal-settings-setting-box:has(' + map[f] + ') { display: none !important; }';
|
||||||
|
console.log('Hiding:', f);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (css) {
|
||||||
|
var s = document.createElement('style');
|
||||||
|
s.textContent = css;
|
||||||
|
document.head.appendChild(s);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (css) {
|
|
||||||
var s = document.createElement('style');
|
|
||||||
s.textContent = css;
|
|
||||||
document.head.appendChild(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadConfig() {
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('GET', '/apps/minimalprofile/api/v1/hidden-fields', true);
|
||||||
|
xhr.onload = function() {
|
||||||
|
if (xhr.status === 200) {
|
||||||
|
try {
|
||||||
|
var data = JSON.parse(xhr.responseText);
|
||||||
|
console.log('MinimalProfile v41: API returned', data.hiddenFields);
|
||||||
|
hideFields(data.hiddenFields);
|
||||||
|
} catch(e) {
|
||||||
|
console.error('MinimalProfile v41: JSON parse error', e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.error('MinimalProfile v41: API failed', xhr.status);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.onerror = function() {
|
||||||
|
console.error('MinimalProfile v41: Network error');
|
||||||
|
};
|
||||||
|
xhr.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
loadConfig();
|
||||||
})();
|
})();
|
||||||
Reference in New Issue
Block a user