Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JNG-5852 transform fallback dashboard #255

Merged
merged 8 commits into from
Jul 22, 2024
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
@@ -1,4 +1,6 @@
import "id.eol";
import "equivalentDiscriminated.eol";

import "ui/namedElement.eol";

import "jsl/_importAll.eol";
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@cached
operation JSL!EnumDeclaration getId(): String {
return (self.eContainer.getId() + "/" + self.name);
}

@cached
operation JSL!EnumDeclaration getActorDeclaration(): JSL!ActorDeclaration {
if (self.eContainer.isTypeOf(JSL!ActorDeclaration)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@cached
operation JSL!EnumLiteral getId(): String {
return (self.eContainer.getId() + "/" + self.name);
}

@cached
operation JSL!EnumLiteral getActorDeclaration(): JSL!ActorDeclaration {
if (self.eContainer.isTypeOf(JSL!EnumDeclaration)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,13 @@ operation JSL!TransferDeclaration isGetTemplateSupported(): Boolean {
operation JSL!TransferDeclaration isRefreshSupported(): Boolean {
return self.map.isDefined();
}

@cached
operation JSL!TransferDeclaration isGenerated() : Boolean {
return actorDeclaration.getExposedTransferObjects().includes(self);
}


operation JSL!TransferDeclaration uiContainer() : UI!ui::VisualElement {
return self.equivalent("TransferDeclarationVisualElement");
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,7 @@ operation JSL!TransferRelationDeclaration getContainerEquivalentClassType(): UI!
}
return null;
}

operation JSL!TransferRelationDeclaration uiContainer() : UI!ui::VisualElement {
return self.referenceType.equivalent("TransferDeclarationVisualElement");
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ operation JSL!Modifiable getIconModifier(): JSL!Modifier {
return self.modifiers.selectOne(m | m.isTypeOf(JSL!IconModifier));
}

@cached
operation JSL!Modifiable getOrientationModifier(): JSL!Modifier {
return self.modifiers.selectOne(m | m.isTypeOf(JSL!OrientationModifier));
}

@cached
operation JSL!Modifiable getStretchModifier(): JSL!Modifier {
return self.modifiers.selectOne(m | m.isTypeOf(JSL!StretchModifier));
}

@cached
operation JSL!Modifiable getPrecision(): JSL!Modifier {
return (self.modifiers.selectOne(m | m.type == "precision"));
Expand Down Expand Up @@ -75,15 +85,40 @@ operation JSL!Modifiable getBind(): JSL!Modifier {

@cached
operation JSL!Modifiable isEventInstead(): Boolean {
return (not self.modifiers.exists(m|m.type == "on"));
return (not self.modifiers.exists(m | m.type == "on"));
}

@cached
operation JSL!Modifiable isEventBefore(): Boolean {
return (self.modifiers.exists(m|m.type == "on" and m.before));
return (self.modifiers.exists(m | m.type == "on" and m.before));
}

@cached
operation JSL!Modifiable isEventAfter(): Boolean {
return (self.modifiers.exists(m|m.type == "on" and m.after));
return (self.modifiers.exists(m | m.type == "on" and m.after));
}

@cached
operation JSL!Modifiable getFrame(): JSL!Modifier {
return (self.modifiers.selectOne(m | m.type == "frame"));
}

@cached
operation JSL!Modifiable getWidth(): JSL!Modifier {
return (self.modifiers.selectOne(m | m.type == "width"));
}

@cached
operation JSL!Modifiable getHAlign(): JSL!Modifier {
return (self.modifiers.selectOne(m | m.type == "h-align"));
}

@cached
operation JSL!Modifiable getVAlign(): JSL!Modifier {
return (self.modifiers.selectOne(m | m.type == "v-align"));
}

@cached
operation JSL!Modifiable getLines(): JSL!Modifier {
return (self.modifiers.selectOne(m | m.type == "lines"));
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import "viewDeclaration.eol";
import "viewFieldDeclaration.eol";
import "viewGroupDeclaration.eol";
import "viewPanelDeclaration.eol";
import "viewTabsDeclaration.eol";
import "visibleDeclaration.eol";
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@cached
operation JSL!ViewFieldDeclaration getId(): String {
return (self.eContainer.getId() + "/" + self.name);
}

@cached
operation JSL!ViewFieldDeclaration getFqName(): String {
return self.eContainer.getFqName() + "::" + self.name;
}

@cached
operation JSL!ViewFieldDeclaration getTransferObjectType(): JSL!TransferDeclaration {
var to = self.eContainer;
while (to.isDefined() and not to.isKindOf(JSL!TransferDeclaration)) {
to = to.eContainer;
}
return to;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@cached
operation JSL!ViewGroupDeclaration getId(): String {
return (self.eContainer.getId() + "/" + self.name);
}

@cached
operation JSL!ViewGroupDeclaration getFqName(): String {
return self.eContainer.getFqName() + "::" + self.name;
}

@cached
operation JSL!ViewGroupDeclaration getTransferObjectType(): JSL!TransferDeclaration {
var to = self.eContainer;
while (to.isDefined() and not to.isKindOf(JSL!TransferDeclaration)) {
to = to.eContainer;
}
return to;
}

@cached
operation JSL!ViewGroupDeclaration isFrame(): Boolean {
var frame = self.getFrame();
return frame.isDefined() and frame.isTrue();
}

operation JSL!ViewGroupDeclaration uiContainer() : UI!ui::VisualElement {
return self.equivalent("GroupVisualElement");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@cached
operation JSL!ViewTabsDeclaration getId(): String {
return (self.eContainer.getId() + "/" + self.name);
}

@cached
operation JSL!ViewTabsDeclaration getFqName(): String {
return self.eContainer.getFqName() + "::" + self.name;
}

@cached
operation JSL!ViewTabsDeclaration getTransferObjectType(): JSL!TransferDeclaration {
var to = self.eContainer;
while (to.isDefined() and not to.isKindOf(JSL!TransferDeclaration)) {
to = to.eContainer;
}
return to;
}

@cached
operation JSL!ViewTabsDeclaration isFrame(): Boolean {
return false;
}

operation JSL!ViewTabsDeclaration uiContainer() : UI!ui::VisualElement {
return self.equivalent("TabBarVisualElement");
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,61 @@ import "modules/structure/transferRelationDeclaration.etl";

import "modules/type/type.etl";

import "modules/view/viewDeclaration.etl";
import "modules/view/enumLiteral.etl";
import "modules/view/viewFieldDeclaration.etl";
import "modules/view/viewGroupDeclaration.etl";
import "modules/view/viewLinkDeclaration.etl";
import "modules/view/viewTableDeclaration.etl";
import "modules/view/viewTabsDeclaration.etl";

pre {
var ecoreUtil = new Native("org.eclipse.emf.ecore.util.EcoreUtil");
var __cacheMap = new ConcurrentMap();
var __originalMap = new ConcurrentMap();
var System = Native("java.lang.System");

//UI.target.resource.contents.add(defaultModelName.equivalent("CreateRootApplication"));
for (container : JSL!ViewPanelDeclaration in JSL!ViewPanelDeclaration.all()) {
if (container.isTypeOf(JSL!ViewGroupDeclaration)) {
for (member in container.members) {
member.~pos = container.members.indexOf(member) + 1;
}
} else if (container.isTypeOf(JSL!ViewTabsDeclaration)) {
for (group in container.groups) {
group.~pos = container.groups.indexOf(group) + 1;
}
}
}
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 {
var application = actorDeclaration.equivalent("Application");

for (navigationController : UI!ui::NavigationController in UI!ui::NavigationController.all()) {
navigationController.items = navigationController.items.sortBy(e | e.~pos);
}

for (group : UI!ui::NavigationItem in UI!ui::NavigationItem.all()) {
group.items = group.items.sortBy(e | e.~pos);
}

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()) {
missingPos = true;
log.error("Position is not defined: " + child.getId());
}
}
if (missingPos) {
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 @@ -90,7 +90,7 @@ rule NavigationController
t.name = s.getFqName() + "::NavigationController";

log.debug("Create NavigationController: " + t.name);
}
}

rule Authentication
transform s: JSL!ActorDeclaration
Expand All @@ -105,7 +105,37 @@ rule Authentication

s.equivalent("Application").authentication = t;

// TODO map claims

log.debug("Create Authentication: " + t.realm);
}
}

rule EmptyDashboardPageDefinition
transform s: JSL!ActorDeclaration
to t: UI!ui::PageDefinition {
guard: s = actorDeclaration

t.setId(actorDeclaration.name + "/(jsl/" + s.getId() + ")/EmptyDashboardPageDefinition");
t.name = s.getFqName() + "::DashboardPage";
t.dashboard = true;
t.dataElement = s.equivalent("Actor");

t.container = s.equivalent("EmptyDashboardPageContainer");
actorDeclaration.equivalent("Application").pages.add(t);

log.debug("EmptyDashboardPageDefinition [" + t.name + "]");
}

rule EmptyDashboardPageContainer
transform s: JSL!ActorDeclaration
to t: UI!ui::PageContainer {
guard: s = actorDeclaration

t.setId(actorDeclaration.name + "/(jsl/" + s.getId() + ")/EmptyDashboardPageContainer");
t.name = s.getFqName() + "::Dashboard";
t.label = "Dashboard";
t.type = UI!ui::PageContainerType#TABLE;
t.dataElement = s.equivalent("Actor");

actorDeclaration.equivalent("Application").pageContainers.add(t);

log.debug("EmptyDashboardPageContainer [" + t.name + "]");
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,21 @@ rule ActorNavigationItem
}

log.debug("ActorNavigationItem: " + s.name);
}
}

rule AccessPageDefinition
transform s: JSL!ActorLinkDeclaration
to t: UI!ui::PageDefinition {
guard: s.getActorDeclaration().isDefined() and s.getActorDeclaration() == actorDeclaration

t.setId(actorDeclaration.name + "/(jsl/" + s.getId() + ")/AccessPageDefinition");

t.name = s.getFqName() + "::PageDefinition";
t.container = s.referenceType.equivalent("TransferDeclarationPageContainer");

actorDeclaration.equivalent("Application").pages.add(t);

t.dataElement = s.equivalent("RelationType");

log.debug("Create AccessPageDefinition: " + t.name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,41 @@ rule ClassType

log.debug("Create ClassType: " + t.name);
}

@greedy
rule TransferDeclarationPageContainer
transform s: JSL!TransferDeclaration
to t: UI!ui::PageContainer {
guard: actorDeclaration.getExposedTransferObjects().contains(s)

t.setId(actorDeclaration.name + "/(jsl/" + s.getId() + ")/TransferDeclarationPageContainer");
t.name = s.getFqName() + "::PageContainer";
var label = s.getLabelModifier();
if (label.isDefined()) {
t.label = label.value.value;
}
t.titleFrom = UI!ui::TitleFrom#LABEL;
t.type = UI!ui::PageContainerType#VIEW;
// t.onInit = s.equivalent("TransferObjectTableAddSelectorTableRangeActionDefinition");
actorDeclaration.equivalent("Application").pageContainers.add(t);
t.children.add(s.equivalent("TransferDeclarationVisualElement"));
// t.actionButtonGroup = s.equivalent("TransferObjectTableAddSelectorButtonGroup");
noherczeg marked this conversation as resolved.
Show resolved Hide resolved
t.dataElement = s.equivalent("ClassType");

log.debug("TransferDeclarationPageContainer: " + t.name);
}

@greedy
rule TransferDeclarationVisualElement
transform s: JSL!TransferDeclaration
to t: UI!ui::Flex {
guard: actorDeclaration.getExposedTransferObjects().contains(s)

t.setId(actorDeclaration.name + "/(jsl/" + s.getId() + ")/TransferDeclarationVisualElement");
t.name = s.name;
t.~pos = 0;
t.col = 12d;
t.direction = UI!Axis#VERTICAL;
t.label = null; // we don't need labels for root visual elements
log.debug("TransferDeclarationVisualElement: " + t.name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@lazy
@greedy
rule EnumerationMemberOption
transform s: JSL!EnumLiteral
to t: UI!ui::Option {
t.setId(actorDeclaration.name + "/(jsl/" + s.getId() + ")/EnumerationMemberOption");
t.selected = false;
t.name = s.name;
t.enumerationMember = s.equivalent("CreateEnumerationMember");
}
Loading
Loading