Skip to content

Commit 9825410

Browse files
authored
fix(harmonia): the personal (my) list resolves relation columns to labels, like the power list (#6347)
The my list page loaded a lookup only for the EntityStatus badge - every other relation column rendered its raw FK id (the personal-template parity class). Port the power list's label-lookup loop: one lookup per rendered DROPDOWN relation (the personal owner and sensitive/non-major fields are not rendered and get no lookup), the column marked fk and resolved in display() with a raw-id fallback for dangling FKs. Lookups load after the rows so the list paints immediately. IntentEmissionCoverageIT: the personal fixture gains a plain dropdown relation and asserts the my list page loads its label lookup while fetching none for the owner relation.
1 parent c4bdc6a commit 9825410

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

  • components/template/template-application-ui-harmonia-java/src/main/resources/META-INF/dirigible/template-application-ui-harmonia-java/ui/my
  • tests/tests-integrations/src/main/java/org/eclipse/dirigible/integration/tests/api

components/template/template-application-ui-harmonia-java/src/main/resources/META-INF/dirigible/template-application-ui-harmonia-java/ui/my/my-list-page.js.template

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,28 @@ document.addEventListener('alpine:init', () => {
4040
} catch (e) { this.statusOptions = []; }
4141
#end
4242
await this.load();
43+
this.loadLookups();
44+
},
45+
46+
lookups: {}, // relationship column name -> { fkValue: label }
47+
// Resolve every rendered relation column to its label, exactly like the power list - the
48+
// personal-owner relation and sensitive fields are not rendered, so no lookup is fetched for
49+
// them. Loaded after the rows so the list paints immediately; cells re-render as maps arrive.
50+
async loadLookups() {
51+
const all = {};
52+
#foreach($property in $properties)
53+
#if($property.widgetType == "DROPDOWN" && $property.name != "$!{personalProperty}" && !$property.sensitiveProperty && (!$property.auditType || $property.auditType == "NONE") && $property.widgetIsMajor != "false")
54+
try {
55+
const opt${property.name} = await App.services.api.getAll('${property.widgetDropdownControllerUrl}', { baseUrl: '' });
56+
const map${property.name} = {};
57+
(opt${property.name} || []).forEach((e) => { map${property.name}[e.${property.widgetDropDownKey}] = e.${property.widgetDropDownValue}; });
58+
all['${property.name}'] = map${property.name};
59+
} catch (e) {
60+
console.error('[${name}MyListPage] failed to load lookup for ${property.name}', e);
61+
}
62+
#end
63+
#end
64+
this.lookups = all;
4365
},
4466

4567
async load() {
@@ -56,6 +78,12 @@ document.addEventListener('alpine:init', () => {
5678
display(row, col) {
5779
const v = row[col.name];
5880
if (v == null || v === '') return '—';
81+
if (col.fk) {
82+
// a relation column shows its referenced label; a dangling/unloaded FK falls back to the id
83+
const map = this.lookups[col.name];
84+
const text = map ? map[v] : undefined;
85+
if (text !== undefined && text !== null && text !== '') return String(text);
86+
}
5987
if (col.date) return window.HarmoniaFormat ? window.HarmoniaFormat.date(v) : String(v);
6088
if (col.number) return window.HarmoniaFormat ? window.HarmoniaFormat.number(v) : String(v);
6189
return String(v);
@@ -81,7 +109,7 @@ document.addEventListener('alpine:init', () => {
81109
columns: [
82110
#foreach($property in $properties)
83111
#if(!$property.dataAutoIncrement && !$property.sensitiveProperty && $property.name != "$!{personalProperty}" && $property.name != "ProcessId" && (!$property.auditType || $property.auditType == "NONE") && $property.widgetIsMajor != "false")
84-
{ name: '${property.name}', label: '#if($property.widgetLabel)${property.widgetLabel}#else${property.name}#end', tkey: '$projectName:${tprefix}.t.${property.dataName}'#if($property.widgetType == "DOCUMENT_STATUS"), status: true#elseif($property.isNumberType), number: true#end#if($property.isDateType), date: true#end },
112+
{ name: '${property.name}', label: '#if($property.widgetLabel)${property.widgetLabel}#else${property.name}#end', tkey: '$projectName:${tprefix}.t.${property.dataName}'#if($property.widgetType == "DOCUMENT_STATUS"), status: true#elseif($property.widgetType == "DROPDOWN"), fk: true#elseif($property.isNumberType), number: true#end#if($property.isDateType), date: true#end },
85113
#end
86114
#end
87115
],

tests/tests-integrations/src/main/java/org/eclipse/dirigible/integration/tests/api/IntentEmissionCoverageIT.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ class IntentEmissionCoverageIT extends IntegrationTest {
178178
- { name: rate, type: decimal, sensitive: true }
179179
relations:
180180
- { name: Person, kind: manyToOne, to: Person, required: true, personal: true }
181+
# a plain dropdown relation: the personal LIST must resolve it to a label (the
182+
# my-list FK-lookup emission), while the owner relation gets no lookup at all
183+
- { name: Unit, kind: manyToOne, to: Unit }
181184
182185
- name: ClaimLine
183186
fields:
@@ -522,6 +525,11 @@ private void assertEmission() {
522525
// and the SPA routes + sidebar carry the personal surface.
523526
String myList = contentOf("gen/emission/js/components/pages/my/ClaimMyListPage.js");
524527
assertTrue(myList.contains("ClaimMyController"), "the my list page must talk to the scoped controller only");
528+
// The personal list must resolve relation columns to labels exactly like the power list
529+
// (the raw-FK-id regression class) - and never fetch a lookup for the owner relation,
530+
// which is not rendered on the personal surface at all.
531+
assertTrue(myList.contains("all['Unit']"), "the my list must load the label lookup for a rendered relation column");
532+
assertTrue(!myList.contains("all['Person']"), "the my list must not fetch a lookup for the personal-owner relation");
525533
String myForm = contentOf("gen/emission/views/my/Claim-form.html");
526534
assertTrue(!myForm.contains("form.Rate"), "the personal form must not render the sensitive field at all");
527535
assertTrue(!myForm.contains("form.Person"), "the personal form must not render the owner FK control");

0 commit comments

Comments
 (0)