Skip to content

Commit

Permalink
JNG-5847 enabled by hidden by table actions (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg authored Jul 29, 2024
1 parent 218ed89 commit 19f6085
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,17 @@ public static MaskEntry getMaskForTable(Table table, PageDefinition pageDefiniti
columnAttributeNames.addAll(table.getAdditionalMaskAttributes().stream().map(NamedElement::getName).collect(Collectors.toSet()));
mask.addPrimitives(columnAttributeNames);
if (table.getRowActionButtonGroup() != null) {
mask.addPrimitives(table.getRowActionButtonGroup().getButtons().stream()
.filter(b -> b.getConfirmation() != null && b.getConfirmation().getConfirmationCondition() != null)
.map(b -> b.getConfirmation().getConfirmationCondition().getName())
.collect(Collectors.toSet()));
for (Button button: table.getRowActionButtonGroup().getButtons()) {
if (button.getConfirmation() != null && button.getConfirmation().getConfirmationCondition() != null) {
mask.addPrimitives(button.getConfirmation().getConfirmationCondition().getName());
}
if (button.getEnabledBy() != null) {
mask.addPrimitives(button.getEnabledBy().getName());
}
if (button.getHiddenBy() != null) {
mask.addPrimitives(button.getHiddenBy().getName());
}
}
}
if (table.isIsEager() && counter < 5) {
// table items can be potentially opened, therefore we need the target's attributes as well
Expand Down Expand Up @@ -284,6 +291,18 @@ public static MaskEntry getMaskForView(PageDefinition pageDefinition, Integer co
mask.addRelations(tableMask);
}

for (Table table: ((List<Table>) container.getTables())) {
List<Button> tableButtons = table.getTableActionButtonGroup().getButtons();
for (Button button: tableButtons) {
if (button.getHiddenBy() != null) {
mask.addPrimitives(button.getHiddenBy().getName());
}
if (button.getEnabledBy() != null) {
mask.addPrimitives(button.getEnabledBy().getName());
}
}
}

for (Link link: ((List<Link>) container.getLinks()).stream().filter(t -> t.getRelationType().getIsRelationKindComposition() || t.getRelationType().getIsRelationKindAggregation()).toList()) {
MaskEntry linkMask = getMaskForLink(link, pageDefinition, counter + 1);
linkMask.setRelationName(link.getDataElement().getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,19 +335,26 @@ public static Boolean displayDropdownForButtonGroup(ButtonGroup actionGroup) {
}

public static String tableButtonVisibilityConditions(Button button, Table table, PageContainer container) {
String result = "";
if (button.getEnabledBy() != null) {
result += "(ownerData ? ownerData." + button.getEnabledBy().getName() + " : true) && ";
}
if (button.getHiddenBy() != null) {
result += "(ownerData ? !ownerData." + button.getHiddenBy().getName() + " : true) && ";
}
if (button.getActionDefinition().getIsOpenCreateFormAction() && !table.isIsEager() && container.isView()) {
return "!editMode && (isFormUpdateable ? isFormUpdateable() : false)";
return result += "!editMode && (isFormUpdateable ? isFormUpdateable() : false)";
}
if (container.isView()) {
if (button.getActionDefinition().getIsOpenSelectorAction() || button.getActionDefinition().getIsRemoveAction()) {
return "(isFormUpdateable ? (isFormUpdateable()" + (!table.isIsEager() ? "&& !editMode" : "") + ") : false)";
return result += "(isFormUpdateable ? (isFormUpdateable()" + (!table.isIsEager() ? "&& !editMode" : "") + ") : false)";
}
if (button.getActionDefinition().getIsBulkRemoveAction()) {
return "(isFormUpdateable ? (isFormUpdateable()" + (!table.isIsEager() ? "&& !editMode" : "") + " && selectionModel.length > 0) : false)";
return result += "(isFormUpdateable ? (isFormUpdateable()" + (!table.isIsEager() ? "&& !editMode" : "") + " && selectionModel.length > 0) : false)";
}
}
if (button.getActionDefinition().getIsClearAction()) {
String result = "data.length > 0";
result += "data.length > 0";
if (table.getEnabledBy() != null) {
result += " && (ownerData ? ownerData." + table.getEnabledBy().getName() +" : false)";
}
Expand All @@ -357,13 +364,13 @@ public static String tableButtonVisibilityConditions(Button button, Table table,
return result;
}
if (button.getActionDefinition().isIsBulk()) {
String result = "selectionModel.length > 0";
result += "selectionModel.length > 0";
if (container.isView() && button.getActionDefinition().getIsCallOperationAction()) {
return result + " && !editMode";
}
return result;
}
return "true";
return result += "true";
}

public static String tableRowButtonDisabledConditions(Button button, Table table, PageContainer container) {
Expand Down

0 comments on commit 19f6085

Please sign in to comment.