Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ private static Map<String, Object> relationProperty(String ownerEntity, Relation
: relation.getSize()
.toString());
p.put("widgetLength", "20");
p.put("widgetIsMajor", "true");
p.put("widgetIsMajor", relation.isMajor() ? "true" : "false");
p.put("widgetDropDownKey", keyFieldName(target));
p.put("widgetDropDownValue", labelFieldName(target));
putLookupColumns(p, relation);
Expand Down Expand Up @@ -1157,7 +1157,7 @@ private static Map<String, Object> crossModelRelationProperty(String ownerEntity
: relation.getSize()
.toString());
p.put("widgetLength", "20");
p.put("widgetIsMajor", "true");
p.put("widgetIsMajor", relation.isMajor() ? "true" : "false");
p.put("widgetDropDownKey", info.keyField());
p.put("widgetDropDownValue", info.labelField());
putLookupColumns(p, relation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ public class RelationIntent {
* width). Use a small span (e.g. 4) to pack several short dropdowns onto one row.
*/
private Integer size;
/**
* Whether this to-one relation shows as a column in the entity's list / document-items table
* ({@code widgetIsMajor}). Defaults to {@code true} (relations are list columns). Set
* {@code major: false} to keep the dropdown in the create/edit form and detail pane but off the
* list table - the relation counterpart of a field's {@code major: false}.
*/
private boolean major = true;
/**
* Optional list of the target entity's field names to surface as extra <b>read-only</b> columns
* wherever this to-one relation shows as a lookup column (the master-detail / document allocation
Expand Down Expand Up @@ -231,6 +238,14 @@ public void setSize(Integer size) {
this.size = size;
}

public boolean isMajor() {
return major;
}

public void setMajor(boolean major) {
this.major = major;
}

public List<String> getShow() {
return show;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,36 @@ void dependsOnEmitsWidgetAttributesWithPrimaryKeyDefaults() {
assertNull(countryFk.get("widgetDependsOnProperty"));
}

@Test
void relationMajorFalseEmitsWidgetIsMajorFalseAndDefaultsTrue() {
String yaml = """
name: shop
uses:
- { model: products }
entities:
- name: Category
fields:
- { name: id, type: integer, primaryKey: true, generated: true }
- { name: name, type: string }
- name: OrderItem
fields:
- { name: id, type: integer, primaryKey: true, generated: true }
- { name: name, type: string }
relations:
- { name: Category, kind: manyToOne, to: Category } # default -> list column
- { name: Note, kind: manyToOne, to: Category, major: false } # local, off the list
- { name: Product, kind: manyToOne, to: Product, model: products, major: false } # cross-model, off the list
""";
IntentModel parsed = IntentParser.parse(yaml);
Map<String, Object> model = EdmIntentGenerator.buildModelJsonForTest(parsed, "shop");
Map<String, Object> item = entityByName(entities(model), "OrderItem");

assertEquals("true", propertyByName(item, "Category").get("widgetIsMajor"), "a relation is a list column by default");
assertEquals("false", propertyByName(item, "Note").get("widgetIsMajor"), "major:false keeps a local relation off the list table");
assertEquals("false", propertyByName(item, "Product").get("widgetIsMajor"),
"major:false keeps a cross-model relation off the list table");
}

@Test
void documentMasterWithACalendarViewStillCarriesThePrintFlag() {
// A document (header-items) master whose UI is overridden to a range calendar: the layout
Expand Down
Loading