fix: use i18n keys for user active and type options labels

This commit is contained in:
Dayv1dDev
2026-07-27 13:51:15 +02:00
parent d3a7862f14
commit c269e7d4d4
4 changed files with 32 additions and 21 deletions
+2 -4
View File
@@ -32,9 +32,7 @@
let tags: FilterTag[] = $state([]);
let subjects = $derived(getAllFilterSubjects(resource));
let subjectByParam = $derived(
new Map(subjects.map((s) => [s.param ?? s.key, s] as const)),
);
let subjectByParam = $derived(new Map(subjects.map((s) => [s.param ?? s.key, s] as const)));
function closeTag(tag: FilterTag) {
const result = { ...filters };
@@ -50,7 +48,7 @@
function formatSubjectValue(subject: FilterSubject, value: string): string {
if (subject.options) {
const option = subject.options.find((o) => o.value === value);
if (option) return option.label;
if (option) return $t(option.label);
}
return value;
}
@@ -55,7 +55,7 @@
}
dropdownOptions = subject.options.map((o) => ({
id: o.value,
label: o.label,
label: $t(o.label),
selected: false,
}));
dropdownSelected = [];
@@ -137,10 +137,9 @@
<div class="flex-1">
<Select
bind:value={subjectKey}
labelText={$t("pages.admin.filter.composer.subjectPlaceholder")}
>
<option value="">{$t("pages.admin.filter.composer.subjectPlaceholder")}</option
>
labelText={$t("pages.admin.filter.composer.subjectPlaceholder")}
>
<option value="">{$t("pages.admin.filter.composer.subjectPlaceholder")}</option>
{#each subjects as subject}
<option value={subject.key}>{subjectLabel(subject.key)}</option>
{/each}
@@ -153,9 +152,7 @@
disabled={!subjectKey}
labelText={$t("pages.admin.filter.composer.operatorPlaceholder")}
>
<option value=""
>{$t("pages.admin.filter.composer.operatorPlaceholder")}</option
>
<option value="">{$t("pages.admin.filter.composer.operatorPlaceholder")}</option>
{#each compatibleOperators as op}
<option value={op}>{operatorLabel(op)}</option>
{/each}
@@ -169,11 +166,9 @@
disabled={!operator}
labelText={$t("pages.admin.filter.composer.referentPlaceholder")}
>
<option value=""
>{$t("pages.admin.filter.composer.referentPlaceholder")}</option
>
<option value="">{$t("pages.admin.filter.composer.referentPlaceholder")}</option>
{#each currentSubject.options as opt}
<option value={opt.value}>{opt.label}</option>
<option value={opt.value}>{$t(opt.label)}</option>
{/each}
</Select>
{:else if currentSubject?.options && operator === "is_any_of" && subjectKey}
@@ -186,7 +181,9 @@
onkeydown={(e) => e.key === "Enter" && (showStaticDropdown = true)}
>
{#each dropdownSelected as item}
<span class="bg-tertiary/10 border-secondary inline-flex items-center gap-1 rounded-lg border px-3 py-1 text-sm">
<span
class="bg-tertiary/10 border-secondary inline-flex items-center gap-1 rounded-lg border px-3 py-1 text-sm"
>
{item.label}
<button
type="button"
+10
View File
@@ -1131,6 +1131,16 @@
"gt": "Mayor que",
"lte": "Menor o igual que",
"lt": "Menor que"
},
"subjectOption": {
"userType": {
"individual": "Persona física",
"organization": "Persona jurídica (empresas)"
},
"active": {
"true": "Activo",
"false": "Inactivo"
}
}
},
"btns": {
+10 -4
View File
@@ -237,8 +237,14 @@ const filterSubjects: Record<string, FilterSubject> = {
compatibleOperators: ["equals", "is_any_of"],
resources: ["users"],
options: [
{ value: "individual", label: "Individual" },
{ value: "organization", label: "Organization" },
{
value: "individual",
label: "pages.admin.filter.composer.subjectOption.userType.individual",
},
{
value: "organization",
label: "pages.admin.filter.composer.subjectOption.userType.organization",
},
],
},
active: {
@@ -247,8 +253,8 @@ const filterSubjects: Record<string, FilterSubject> = {
compatibleOperators: ["equals"],
resources: ["users"],
options: [
{ value: "true", label: "Active" },
{ value: "false", label: "Inactive" },
{ value: "true", label: "pages.admin.filter.composer.subjectOption.active.true" },
{ value: "false", label: "pages.admin.filter.composer.subjectOption.active.false" },
],
},
userRoles: {