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-5858 transform relation components #257

Merged
merged 5 commits into from
Jul 25, 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
Expand Up @@ -13,11 +13,6 @@ operation JSL!TransferRelationDeclaration isEager(): Boolean {
return jslUtils.isEager(self);
}

@cached
operation JSL!TransferRelationDeclaration getDetail(): JSL!DetailModifier {
return self.modifiers.selectOne(m | m.isTypeOf(JSL!DetailModifier));
}

@cached
operation JSL!TransferRelationDeclaration isAggregation(): Boolean {
return jslUtils.isAggregation(self);
Expand Down Expand Up @@ -87,26 +82,26 @@ operation JSL!TransferRelationDeclaration isChoiceDefined(): Boolean {
operation JSL!TransferRelationDeclaration isAddReferenceAllowed(): Boolean {
var lower = self.isRequired() and not self.isMany ? 1 : 0;
var upper = self.isMany ? -1 : 1;
return self.maps() and self.eContainer.isUpdateSupported()
return self.maps() and self.getTransferContainer().isUpdateSupported()
and upper != 1 and (lower < upper or upper == -1);
}

@cached
operation JSL!TransferRelationDeclaration isRemoveReferenceAllowed(): Boolean {
var lower = self.isRequired() and not self.isMany ? 1 : 0;
var upper = self.isMany ? -1 : 1;
return self.maps() and self.eContainer.isUpdateSupported()
return self.maps() and self.getTransferContainer().isUpdateSupported()
and upper != 1 and (lower < upper or upper == -1);
}

@cached
operation JSL!TransferRelationDeclaration isSetReferenceAllowed(): Boolean {
return self.maps() and self.eContainer.isUpdateSupported() and not self.isRequired();
return self.maps() and self.getTransferContainer().isUpdateSupported() and not self.isRequired();
}

@cached
operation JSL!TransferRelationDeclaration isUnsetReferenceAllowed(): Boolean {
return self.maps() and self.eContainer.isUpdateSupported() and not self.isRequired();
return self.maps() and self.getTransferContainer().isUpdateSupported() and not self.isRequired();
}

@cached
Expand Down Expand Up @@ -171,3 +166,8 @@ operation JSL!TransferRelationDeclaration getContainerEquivalentClassType(): UI!
operation JSL!TransferRelationDeclaration uiContainer() : UI!ui::VisualElement {
return self.referenceType.equivalent("TransferDeclarationVisualElement");
}

@cached
operation JSL!TransferRelationDeclaration getTransferObjectType(): JSL!TransferDeclaration {
return self.referenceType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ operation JSL!Modifiable getStretchModifier(): JSL!Modifier {
return self.modifiers.selectOne(m | m.isTypeOf(JSL!StretchModifier));
}

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

@cached
operation JSL!Modifiable getPrecision(): JSL!Modifier {
return (self.modifiers.selectOne(m | m.type == "precision"));
Expand Down Expand Up @@ -63,6 +68,11 @@ operation JSL!Modifiable getMimeType(): JSL!Modifier {
return (self.modifiers.selectOne(m | m.type == "mime-type"));
}

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

@cached
operation JSL!Modifiable getOpposite(): JSL!Modifier {
return (self.modifiers.selectOne(m | m.type == "opposite" or m.type == "opposite-add"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,115 @@ rule ViewLinkPageDefinition

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

@abstract
rule AbstractViewLinkDeclaration
transform s: JSL!ViewLinkDeclaration
to t: UI!ui::Link {
guard: actorDeclaration.getAllRelations().contains(s)

t.name = s.name;
t.relationName = s.name;
if (s.getLabelModifier().isDefined()) {
t.label = s.getLabelModifier().value.value;
}
if (s.getIconModifier().isDefined()) {
t.icon = s.equivalent("LinkIcon");
}
t.row = 1d;
t.col = s.width.isDefined() ? s.width.asReal() : 12d;
t.~pos = s.~pos;
t.isEager = s.isEager();
if (t.~pos.isUndefined()) {
t.~pos = 0;
}

if (s.isEager()) {
// TODO finish additional mas attributes
/*
for (dataFeature in s.additionalMaskFeatures) {
var attributeType = dataFeature.getMember().mapAttributeType(s.getRoot().getTransferObjectType().equivalent("ClassType"));
t.additionalMaskAttributes.add(attributeType);
}
*/
}
}
noherczeg marked this conversation as resolved.
Show resolved Hide resolved

@lazy
@greedy
rule LinkIcon
transform s: JSL!ViewLinkDeclaration
to t: UI!ui::Icon {
t.iconName = s.getIconModifier().value.value;
t.name = s.name + "Icon";
t.setId(actorDeclaration.name + "/(jsl/" + s.getId() + ")/LinkIcon");
}

rule InlineViewLink
transform s: JSL!ViewLinkDeclaration
to t: UI!ui::Link
extends AbstractViewLinkDeclaration {
guard: s.getTransferObjectType().isGenerated()

var id = actorDeclaration.name + "/(jsl/" + s.getId() + ")/InlineViewLink";
t.setId(id);
t.dataElement = s.equivalent("RelationType");

s.eContainer.uiContainer().children.add(t);

var col = s.equivalentDiscriminated("ViewLinkDeclarationRepresentationColumn", id);
t.parts.add(col);

// TODO transform selector row per page
t.selectorRowsPerPage = 10;
t.autoCompleteRows = 10;

t.actionButtonGroup = s.equivalent("TabularReferenceFieldLinkButtonGroup");

/*
t.autocompleteRangeActionDefinition = s.equivalent("TabularReferenceFieldLinkAutocompleteRangeActionDefinition");
t.autocompleteSetActionDefinition = s.equivalent("TabularReferenceFieldLinkAutocompleteSetActionDefinition");

if (relation.isRefreshSupported() and relation.relationKind == ESM!esm::structure::RelationKind#ASSOCIATION) {
t.refreshActionDefinition = s.equivalent("TabularReferenceFieldLinkRefreshActionDefinition");
}
*/

log.debug("InlineViewLink: " + t.name);
}
noherczeg marked this conversation as resolved.
Show resolved Hide resolved

@lazy
rule InlineViewLinkButtonGroup
transform s: JSL!ViewLinkDeclaration
to t: UI!ui::ButtonGroup {
t.setId(actorDeclaration.name + "/(jsl/" + s.getId() + ")/InlineViewLinkButtonGroup");
t.name = s.name + "::Actions";
t.label = "Actions";

// TODO add action buttons

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

@lazy
rule ViewLinkDeclarationRepresentationColumn
transform s: JSL!ViewLinkDeclaration
to t: UI!ui::Column {
noherczeg marked this conversation as resolved.
Show resolved Hide resolved
t.setId(actorDeclaration.name + "/(jsl/" + s.getId() + ")/ViewLinkDeclarationRepresentationColumn");

var firstStringFromTarget = s.referenceType.getAllPrimitiveFields().selectOne(f | f.referenceType.isDefined() and f.referenceType.`primitive` == "string");

if (firstStringFromTarget.isUndefined()) {
throw "Could not get string type field from relation target to use for representation: " + s.referenceType.name;
}

t.attributeType = firstStringFromTarget.getTransferFieldDeclarationEquivalent();
t.name = t.attributeType.name;
t.label = "";
noherczeg marked this conversation as resolved.
Show resolved Hide resolved
t.col = 12d;
t.row = 1d;
t.format = "%s";
t.sort = UI!ui::Sort#ASC;

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