merged with master branch. Fixing issue on clicking

This commit is contained in:
Francesco Mangiacrapa 2022-11-30 10:08:51 +01:00
parent 7d2b8844af
commit 5a5fbdfabb
2 changed files with 44 additions and 27 deletions

View File

@ -38,7 +38,8 @@ public class ActionListPanel extends Composite {
private List<ActionDefinitionDV> listActionDefinition; private List<ActionDefinitionDV> listActionDefinition;
private HandlerManager appManagerBus; private HandlerManager appManagerBus;
public ActionListPanel(HandlerManager appManagerBus,String projectName, String profileID, List<ActionDefinitionDV> listActionDef) { public ActionListPanel(HandlerManager appManagerBus, String projectName, String profileID,
List<ActionDefinitionDV> listActionDef) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
GWT.log("Adding list of actions: " + listActionDef); GWT.log("Adding list of actions: " + listActionDef);
this.appManagerBus = appManagerBus; this.appManagerBus = appManagerBus;
@ -60,7 +61,7 @@ public class ActionListPanel extends Composite {
private void initActions(List<ActionDefinitionDV> listActionDef) { private void initActions(List<ActionDefinitionDV> listActionDef) {
if (listActionDef.size() > 0) { if (listActionDef.size() > 0) {
//actionListBasePanel.setVisible(true); // actionListBasePanel.setVisible(true);
ButtonGroup buttonGroup = new ButtonGroup(); ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.getElement().addClassName("actions-button-group"); buttonGroup.getElement().addClassName("actions-button-group");
@ -68,12 +69,13 @@ public class ActionListPanel extends Composite {
mapPhaseListButtons = new LinkedHashMap<String, List<ActionDefButton>>(); mapPhaseListButtons = new LinkedHashMap<String, List<ActionDefButton>>();
for (ActionDefinitionDV actionDefinitionDV : listActionDef) { for (ActionDefinitionDV actionDefinitionDV : listActionDef) {
//skipping the special workflow action // skipping the special workflow action
if(actionDefinitionDV.getId().equals(ConstantsGeoPortalDataEntryApp.WORKFLOW_ACTION_POST_CREATION_ACTION_ID)) { if (actionDefinitionDV.getId()
.equals(ConstantsGeoPortalDataEntryApp.WORKFLOW_ACTION_POST_CREATION_ACTION_ID)) {
continue; continue;
} }
Button butt = new Button(); Button butt = new Button();
butt.setText(actionDefinitionDV.getTitle()); butt.setText(actionDefinitionDV.getTitle());
butt.setTitle(actionDefinitionDV.getDescription()); butt.setTitle(actionDefinitionDV.getDescription());
@ -83,7 +85,8 @@ public class ActionListPanel extends Composite {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
appManagerBus.fireEvent(new WorkflowActionOnSelectedItemEvent<ResultDocumentDV>(actionDefinitionDV)); appManagerBus
.fireEvent(new WorkflowActionOnSelectedItemEvent<ResultDocumentDV>(actionDefinitionDV));
} }
}); });
@ -110,9 +113,9 @@ public class ActionListPanel extends Composite {
public <T> void showActionsOnSelected(List<T> listSelected, GcubeUserRole userRole) { public <T> void showActionsOnSelected(List<T> listSelected, GcubeUserRole userRole) {
setAllActionsVisible(false); setAllActionsVisible(false);
if (listSelected.size() == 1) { if (listSelected.size() == 1) {
for (T item : listSelected) { for (T item : listSelected) {
if (item instanceof ResultDocumentDV) { if (item instanceof ResultDocumentDV) {
@ -120,20 +123,25 @@ public class ActionListPanel extends Composite {
String itemPhase = ((ResultDocumentDV) item).getLifecycleInfo().getPhase(); String itemPhase = ((ResultDocumentDV) item).getLifecycleInfo().getPhase();
List<ActionDefButton> listButtons = mapPhaseListButtons.get(itemPhase); List<ActionDefButton> listButtons = mapPhaseListButtons.get(itemPhase);
for (ActionDefButton actionDefButton : listButtons) {
if (listButtons != null) {
Set<String> roles = actionDefButton.getActionDefinitionDV().getRoles();
for (ActionDefButton actionDefButton : listButtons) {
//No role/s defined means enable the action by default
if(roles.isEmpty()) { Set<String> roles = actionDefButton.getActionDefinitionDV().getRoles();
actionDefButton.getButton().setVisible(true);
actionListBasePanel.setVisible(true); // No role/s defined means enable the action by default
}else { if (roles.isEmpty()) {
//Checking if the userRole is matching the role defined in the ActionDefinition
boolean isRoleIntoActionDef= roles.stream().anyMatch(userRole.getName()::equalsIgnoreCase);
if(isRoleIntoActionDef) {
actionDefButton.getButton().setVisible(true); actionDefButton.getButton().setVisible(true);
actionListBasePanel.setVisible(true); actionListBasePanel.setVisible(true);
} else {
// Checking if the userRole is matching the role defined in the ActionDefinition
boolean isRoleIntoActionDef = roles.stream()
.anyMatch(userRole.getName()::equalsIgnoreCase);
if (isRoleIntoActionDef) {
actionDefButton.getButton().setVisible(true);
actionListBasePanel.setVisible(true);
}
} }
} }
} }
@ -144,13 +152,19 @@ public class ActionListPanel extends Composite {
} }
private void setAllActionsVisible(boolean bool) { private void setAllActionsVisible(boolean bool) {
Iterator<List<ActionDefButton>> collIterator = mapPhaseListButtons.values().iterator();
while (collIterator.hasNext()) {
List<ActionDefButton> listButton = collIterator.next();
for (ActionDefButton actionDefButton : listButton) {
actionDefButton.getButton().setVisible(bool);
}
if (mapPhaseListButtons != null && mapPhaseListButtons.values().size() > 0) {
Iterator<List<ActionDefButton>> collIterator = mapPhaseListButtons.values().iterator();
if (collIterator != null) {
while (collIterator.hasNext()) {
List<ActionDefButton> listButton = collIterator.next();
for (ActionDefButton actionDefButton : listButton) {
actionDefButton.getButton().setVisible(bool);
}
}
}
} }
} }
} }

View File

@ -165,6 +165,9 @@ public class ItemsTable<T extends DocumentDV> extends AbstractItemsCellTable<T>
Object value = documentDV.getDocumentAsMap().get(key); Object value = documentDV.getDocumentAsMap().get(key);
// GWT.log("key: "+key+" is instance of: "+value.getClass()); // GWT.log("key: "+key+" is instance of: "+value.getClass());
if(value==null)
return;
if (value instanceof ArrayList) { if (value instanceof ArrayList) {
ArrayList<Object> arrayValues = (ArrayList<Object>) value; ArrayList<Object> arrayValues = (ArrayList<Object>) value;
String toReturn = "<ul>"; String toReturn = "<ul>";