users: fix avatar handling and various translations

This commit is contained in:
Girish Ramakrishnan
2025-09-16 12:05:47 +02:00
parent 0530a58530
commit 405302e2f0
7 changed files with 106 additions and 54 deletions

View File

@@ -31,7 +31,6 @@ const id = ref('');
const upstreamUri = ref('');
const label = ref('');
const tags = ref([]);
const iconFile = ref(null);
const iconUrl = ref('');
const accessRestrictionOption = ref('');
const accessRestriction = ref({
@@ -53,8 +52,9 @@ const isValid = computed(() => {
return true;
});
let iconFile = null;
function onIconChanged(file) {
iconFile.value = file;
iconFile = file;
}
async function onSubmit() {
@@ -73,10 +73,10 @@ async function onSubmit() {
data.accessRestriction.groups = accessRestriction.value.groups.map(function (g) { return g.id; });
}
if (iconFile.value === 'fallback') { // user reset the icon
if (iconFile === 'fallback') { // user reset the icon
data.icon = '';
} else if (iconFile.value !== 'src') { // user loaded custom icon
data.icon = (await getDataURLFromFile(iconFile.value)).replace(/^data:image\/[a-z]+;base64,/, '');
} else if (iconFile !== 'src') { // user loaded custom icon
data.icon = (await getDataURLFromFile(iconFile)).replace(/^data:image\/[a-z]+;base64,/, '');
}
let error;
@@ -118,7 +118,7 @@ defineExpose({
upstreamUri.value = applink ? applink.upstreamUri : '';
label.value = applink ? applink.label : '';
iconUrl.value = applink ? applink.iconUrl : 'fallback';
iconFile.value = applink?.iconUrl ? 'src' : 'fallback';
iconFile = applink?.iconUrl ? 'src' : 'fallback';
tags.value = applink ? applink.tags : [];
accessRestrictionOption.value = applink && applink.accessRestriction ? 'groups' : 'any';
accessRestriction.value = applink && applink.accessRestriction ? applink.accessRestriction : { users: [], groups: [] };