Skip to content

Commit

Permalink
JNG-5853 refactors and additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg committed Jul 22, 2024
1 parent 8fe41dc commit 0b92de8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,3 @@ operation JSL!ActorDeclaration getExposedTransferObjects() : Set {

return collected;
}

@cached
operation JSL!ActorDeclaration getExposedVisibleDeclarations() : Set {
var transfers = self.getExposedTransferObjects();

return transfers.select(t | t.isTypeOf(JSL!ViewDeclaration) or t.isTypeOf(JSL!RowDeclaration)).asSet();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ operation UI!ui::NamedElement getRootApplication() : UI!ui::Application {
if (self.eContainer.isTypeOf(UI!ui::Application)) {
return self.eContainer;
} else {
if (self.eContainer.isUndefined()) {
log.info("AAAAA >>>>>>>>>> " + self.getFqName());
}
return self.eContainer.getRootApplication();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ pre {
}
}
}
for (visible : JSL!VisibleDeclaration in JSL!VisibleDeclaration.all()) {
if (visible.isTypeOf(JSL!ViewDeclaration) or visible.isTypeOf(JSL!RowDeclaration)) {
for (member in visible.members) {
member.~pos = visible.members.indexOf(member) + 1;
}
}
}
}

post {
Expand All @@ -48,7 +55,7 @@ post {
group.items = group.items.sortBy(e | e.~pos);
}

/*for (container : UI!ui::Container in UI!ui::Container.all().select(a | a.getRootApplication() == application)) {
for (container : UI!ui::Container in UI!ui::Container.all().select(a | a.getRootApplication() == application)) {
var missingPos = false;
for (child in container.children) {
if (child.~pos.isUndefined()) {
Expand All @@ -57,8 +64,8 @@ post {
}
}
if (missingPos) {
throw "Missing position parameter(s) under Container: " + container;
throw "Missing position parameter(s) under Container: " + container.name;
}
container.children = container.children.sortBy(e | e.~pos);
}*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,25 @@ enum MyEnum {
view UserView(User u) {
group level1 label:"Yo" icon:"text" {
group level2 width:12 frame:true icon:"unicorn" label:"Level 2" stretch:true {
field String email <= u.email bind required;
field Binary binaryDerived <= u.binary;
field String stringDerived <= u.string;
field String email <= u.email bind required icon:"text" label: "My Email";
field Binary binaryDerived <= u.binary icon:"binary" label:"Binary Derived";
field String stringDerived <= u.string icon:"string" label:"String Derived";
}
group level22 width:6 frame:true icon:"dog" label:"Level 2 - 2" orientation:horizontal {
field Boolean booleanDerived <= u.boolean;
field Date dateDerived <= u.date;
field Numeric numericDerived <= u.numeric;
field Boolean booleanDerived <= u.boolean icon:"boolean" label:"Boolean Derived";
field Date dateDerived <= u.date icon:"date" label:"Date Derived";
field Numeric numericDerived <= u.numeric icon:"numeric" label:"Numeric Derived";
}
tabs tabs0 orientation:horizontal width:6 {
group tab1 label:"Tab1" icon:"numbers" h-align:left {
field Time timeDerived <= u.time;
field Time timeDerived <= u.time icon:"time" label:"Time Derived";
}
group tab2 label:"Tab2" icon:"numbers" h-align:right {
field Timestamp timestampDerived <= u.timestamp;
field MyEnum mappedEnum <= u.`enum` bind default:MyEnum#Crazy;
field Timestamp timestampDerived <= u.timestamp icon:"timestamp" label:"Timestamp Derived";
field MyEnum mappedEnum <= u.`enum` bind default:MyEnum#Crazy icon:"enum" label:"Mapped Enum";
}
}
}
Expand Down Expand Up @@ -164,20 +164,26 @@ view UserView(User u) {
TextInput email = (TextInput) level2.getChildren().stream().filter(c -> c.getName().equals("email")).findFirst().orElseThrow();

assertEquals("email", email.getName());
assertEquals("My Email", email.getLabel());
assertEquals("text", email.getIcon().getIconName());
assertEquals("String", email.getAttributeType().getDataType().getName());
assertTrue(email.getAttributeType().isIsRequired());
assertFalse(email.getAttributeType().isIsReadOnly());

BinaryTypeInput binaryDerived = (BinaryTypeInput) level2.getChildren().stream().filter(c -> c.getName().equals("binaryDerived")).findFirst().orElseThrow();

assertEquals("binaryDerived", binaryDerived.getName());
assertEquals("Binary Derived", binaryDerived.getLabel());
assertEquals("binary", binaryDerived.getIcon().getIconName());
assertEquals("Binary", binaryDerived.getAttributeType().getDataType().getName());
assertFalse(binaryDerived.getAttributeType().isIsRequired());
assertTrue(binaryDerived.getAttributeType().isIsReadOnly());

TextInput stringDerived = (TextInput) level2.getChildren().stream().filter(c -> c.getName().equals("stringDerived")).findFirst().orElseThrow();

assertEquals("stringDerived", stringDerived.getName());
assertEquals("String Derived", stringDerived.getLabel());
assertEquals("string", stringDerived.getIcon().getIconName());
assertEquals("String", stringDerived.getAttributeType().getDataType().getName());
assertFalse(stringDerived.getAttributeType().isIsRequired());
assertTrue(stringDerived.getAttributeType().isIsReadOnly());
Expand All @@ -198,20 +204,26 @@ view UserView(User u) {
TrinaryLogicCombo booleanDerived = (TrinaryLogicCombo) level22.getChildren().stream().filter(c -> c.getName().equals("booleanDerived")).findFirst().orElseThrow();

assertEquals("booleanDerived", booleanDerived.getName());
assertEquals("Boolean Derived", booleanDerived.getLabel());
assertEquals("boolean", booleanDerived.getIcon().getIconName());
assertEquals("Boolean", booleanDerived.getAttributeType().getDataType().getName());
assertFalse(booleanDerived.getAttributeType().isIsRequired());
assertTrue(booleanDerived.getAttributeType().isIsReadOnly());

DateInput dateDerived = (DateInput) level22.getChildren().stream().filter(c -> c.getName().equals("dateDerived")).findFirst().orElseThrow();

assertEquals("dateDerived", dateDerived.getName());
assertEquals("Date Derived", dateDerived.getLabel());
assertEquals("date", dateDerived.getIcon().getIconName());
assertEquals("Date", dateDerived.getAttributeType().getDataType().getName());
assertFalse(dateDerived.getAttributeType().isIsRequired());
assertTrue(dateDerived.getAttributeType().isIsReadOnly());

NumericInput numericDerived = (NumericInput) level22.getChildren().stream().filter(c -> c.getName().equals("numericDerived")).findFirst().orElseThrow();

assertEquals("numericDerived", numericDerived.getName());
assertEquals("Numeric Derived", numericDerived.getLabel());
assertEquals("numeric", numericDerived.getIcon().getIconName());
assertEquals("Numeric", numericDerived.getAttributeType().getDataType().getName());
assertFalse(numericDerived.getAttributeType().isIsRequired());
assertTrue(numericDerived.getAttributeType().isIsReadOnly());
Expand Down Expand Up @@ -243,6 +255,8 @@ view UserView(User u) {
TimeInput timeDerived = (TimeInput) tab1Element.getChildren().stream().filter(c -> c.getName().equals("timeDerived")).findFirst().orElseThrow();

assertEquals("timeDerived", timeDerived.getName());
assertEquals("Time Derived", timeDerived.getLabel());
assertEquals("time", timeDerived.getIcon().getIconName());
assertEquals("Time", timeDerived.getAttributeType().getDataType().getName());
assertFalse(timeDerived.getAttributeType().isIsRequired());
assertTrue(timeDerived.getAttributeType().isIsReadOnly());
Expand All @@ -265,13 +279,17 @@ view UserView(User u) {
DateTimeInput timestampDerived = (DateTimeInput) tab2Element.getChildren().stream().filter(c -> c.getName().equals("timestampDerived")).findFirst().orElseThrow();

assertEquals("timestampDerived", timestampDerived.getName());
assertEquals("Timestamp Derived", timestampDerived.getLabel());
assertEquals("timestamp", timestampDerived.getIcon().getIconName());
assertEquals("Timestamp", timestampDerived.getAttributeType().getDataType().getName());
assertFalse(timestampDerived.getAttributeType().isIsRequired());
assertTrue(timestampDerived.getAttributeType().isIsReadOnly());

EnumerationCombo mappedEnum = (EnumerationCombo) tab2Element.getChildren().stream().filter(c -> c.getName().equals("mappedEnum")).findFirst().orElseThrow();

assertEquals("mappedEnum", mappedEnum.getName());
assertEquals("Mapped Enum", mappedEnum.getLabel());
assertEquals("enum", mappedEnum.getIcon().getIconName());
assertEquals("MyEnum", mappedEnum.getAttributeType().getDataType().getName());
assertFalse(mappedEnum.getAttributeType().isIsRequired());
assertFalse(mappedEnum.getAttributeType().isIsReadOnly());
Expand Down

0 comments on commit 0b92de8

Please sign in to comment.