Revisit the "Select Item Resources" step when publishing from Workspace

#26874
This commit is contained in:
Francesco Mangiacrapa 2024-02-23 12:35:47 +01:00
parent ff1500b991
commit 4a5ed9caa5
10 changed files with 148 additions and 70 deletions

View File

@ -24,7 +24,6 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.Ad
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.ManageResources;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.WizardCreator;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace.SelectResourceByWEMainPanel;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataProfileBeanForUpdate;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
@ -310,7 +309,7 @@ public class UpdateDatasetForm extends Composite {
private DatasetBean theDatasetBean;
// resource table
private SelectResourceByWEMainPanel resourcesSelectByWEMainPanel;
//private SelectResourceByWEMainPanel resourcesSelectByWEMainPanel;
// List of opened popup'ids
private List<String> popupOpenedIds = new ArrayList<String>();
@ -515,11 +514,11 @@ public class UpdateDatasetForm extends Composite {
// set it as visible anyway
tagsPanel.setVisible(true);
// The resource root is the folder id. Es. ID of the Workspace Root folder.
if (datasetBean.getResourceRoot() != null) {
resourcesSelectByWEMainPanel = new SelectResourceByWEMainPanel(
datasetBean.getResourceRoot());
}
// // The resource root is the folder id. Es. ID of the Workspace Root folder.
// if (datasetBean.getResourceRoot() != null) {
// resourcesSelectByWEMainPanel = new SelectResourceByWEMainPanel(
// datasetBean.getResourceRoot());
// }
// set organizations
List<OrganizationBean> organizations = datasetBean.getOrganizationList();
@ -946,7 +945,7 @@ public class UpdateDatasetForm extends Composite {
// add the resources to the container panel
if (workspaceResourcesContainer.getWidget() == null) {
workspaceResourcesContainer.getElement().getStyle().setMarginLeft(20, Unit.PX);
workspaceResourcesContainer.add(resourcesSelectByWEMainPanel);
//workspaceResourcesContainer.add(resourcesSelectByWEMainPanel);
}
} else {
@ -1156,9 +1155,9 @@ public class UpdateDatasetForm extends Composite {
theDatasetBean.setGroups(groups);
theDatasetBean.setGroupsForceCreation(groupsToForceCreation);
if (resourcesSelectByWEMainPanel != null) {
theDatasetBean.setResourceRoot(resourcesSelectByWEMainPanel.getResourcesToPublish());
}
// if (resourcesSelectByWEMainPanel != null) {
// theDatasetBean.setResourceRoot(resourcesSelectByWEMainPanel.getResourcesToPublish());
// }
theDatasetBean.setCustomFields(customFieldsMap);
@ -1600,9 +1599,9 @@ public class UpdateDatasetForm extends Composite {
}
// freeze table of resources
if (resourcesSelectByWEMainPanel != null)
resourcesSelectByWEMainPanel.freeze();
// // freeze table of resources
// if (resourcesSelectByWEMainPanel != null)
// resourcesSelectByWEMainPanel.freeze();
}
/**

View File

@ -35,14 +35,23 @@ import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
/**
* Form used to add resource(s) to a dataset
* The Class AddResourceToDataset.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
* Feb 23, 2024
*/
public class AddResourceToDataset extends Composite {
private static AddResourceToDatasetUiBinder uiBinder = GWT.create(AddResourceToDatasetUiBinder.class);
/**
* The Interface AddResourceToDatasetUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Feb 23, 2024
*/
interface AddResourceToDatasetUiBinder extends UiBinder<Widget, AddResourceToDataset> {
}
@ -82,6 +91,15 @@ public class AddResourceToDataset extends Composite {
FlowPanel alertPanel = new FlowPanel();
/**
* Instantiates a new adds the resource to dataset.
*
* @param eventBus the event bus
* @param datasetId the dataset id
* @param datasetTitle the dataset title
* @param datasetOrg the dataset org
* @param datasetUrl the dataset url
*/
public AddResourceToDataset(HandlerManager eventBus, final String datasetId, String datasetTitle,
final String datasetOrg, final String datasetUrl) {
initWidget(uiBinder.createAndBindUi(this));
@ -115,6 +133,9 @@ public class AddResourceToDataset extends Composite {
}
/**
* Bind.
*/
private void bind() {
eventBus.addHandler(WorkspaceItemSelectedEvent.TYPE, new WorkspaceItemSelectedEventHandler() {
@ -149,6 +170,11 @@ public class AddResourceToDataset extends Composite {
}
/**
* On select from workspace click.
*
* @param e the e
*/
@UiHandler("buttoSelectFromWorkspace")
void onSelectFromWorkspaceClick(ClickEvent e) {
@ -165,6 +191,11 @@ public class AddResourceToDataset extends Composite {
dialog.center();
}
/**
* On add button click.
*
* @param e the e
*/
@UiHandler("addResourceButton")
void onAddButtonClick(ClickEvent e) {
@ -228,8 +259,7 @@ public class AddResourceToDataset extends Composite {
} else
showAlert("Unable to add this resource. Check that the url is correct", null, AlertType.ERROR, true,
true);
addResourceButton.setEnabled(true);
}
@ -239,7 +269,7 @@ public class AddResourceToDataset extends Composite {
infoPanel.clear();
showAlert("Unable to add this resource, sorry. Error is: " + caught.getMessage(), null, AlertType.ERROR,
true, true);
addResourceButton.setEnabled(true);
}
@ -249,9 +279,12 @@ public class AddResourceToDataset extends Composite {
/**
* Show error/success after resource creation attempt.
*
* @param text
* @param type
*
* @param text the text
* @param loader the loader
* @param type the type
* @param scheduleHide the schedule hide
* @param setVisible the set visible
*/
protected void showAlert(String text, LoaderIcon loader, AlertType type, boolean scheduleHide, boolean setVisible) {

View File

@ -16,7 +16,6 @@ import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
@ -62,7 +61,7 @@ public class ResourceInfoForm extends Composite{
resourcePath.setText(resource.getFullPath());
closeButton.getElement().getStyle().setFloat(Float.RIGHT);
closeButton.setIcon(IconType.REMOVE_CIRCLE);
commandPanel.setCellHorizontalAlignment(updateResourceButton, HasHorizontalAlignment.ALIGN_RIGHT);
//commandPanel.setCellHorizontalAlignment(updateResourceButton, HasHorizontalAlignment.ALIGN_RIGHT);
commandPanel.getElement().getStyle().setMarginTop(10, Unit.PX);
updateResourceButton.addClickHandler(new ClickHandler() {

View File

@ -14,8 +14,8 @@
padding: 5px;
border: 1px solid #bbb;
border-radius: 5px;
height: 320px;
width: 700px;
height: 300px;
/*width: 700px;*/
margin-bottom: 20px;
}
@ -32,11 +32,11 @@
}
.custom-input input {
width: 350px;
width: 80%;
}
.custom-input textarea {
width: 355px;
width: 81%;
}
</ui:style>
<g:HTMLPanel addStyleNames="{style.panel-style}">
@ -45,7 +45,7 @@
<b:Legend addStyleNames="{style.legend-style}">
<b>Resource Information</b>
<b:Button ui:field="closeButton" type="LINK"
title="Close details"></b:Button>
title="Close details" visible="false"></b:Button>
</b:Legend>
<b:ControlGroup ui:field="controlName">
<b:ControlLabel for="name"
@ -92,7 +92,7 @@
<g:HorizontalPanel width="100%"
ui:field="commandPanel">
<!-- <b:Button ui:field="cancelButton">Cancel</b:Button> -->
<b:Button ui:field="updateResourceButton" type="PRIMARY">Update</b:Button>
<b:Button ui:field="updateResourceButton" type="INFO">Update</b:Button>
</g:HorizontalPanel>
</b:Fieldset>
</b:Form>

View File

@ -40,14 +40,14 @@
<g:HTMLPanel ui:field="containerPickResources"
addStyleNames="{style.margin-top-30}">
<b:AccordionGroup ui:field="buttPickResources"
heading="Add files from..." defaultOpen="false"
heading="Select from Workspace..." defaultOpen="false"
addStyleNames="accordion-no-border-inner">
<b:FluidRow addStyleNames="{style.max-height-250}">
<g:VerticalPanel ui:field="wsContainer">
</g:VerticalPanel>
</b:FluidRow>
<b:Button ui:field="buttSelectResource"
addStyleNames="{style.margin-top-10}">Select</b:Button>
type="INFO" addStyleNames="{style.margin-top-10}">Select</b:Button>
</b:AccordionGroup>
</g:HTMLPanel>
</g:HTMLPanel>

View File

@ -7,9 +7,12 @@ import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
@ -19,7 +22,7 @@ import com.google.gwt.user.client.ui.Widget;
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Mar 12, 2021
* Mar 12, 2021
*/
public class SelectedResourceWidget extends Composite {
@ -31,7 +34,7 @@ public class SelectedResourceWidget extends Composite {
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Mar 12, 2021
* Mar 12, 2021
*/
interface SelectedResourceWidgetUiBinder extends UiBinder<Widget, SelectedResourceWidget> {
}
@ -54,14 +57,22 @@ public class SelectedResourceWidget extends Composite {
/** The field name. */
@UiField
Label fieldName;
@UiField
Label fieldDescription;
/** The edit panel. */
@UiField
HTMLPanel editPanel;
@UiField
FlowPanel resourcePanel;
@UiField
FlowPanel selectedResourcesPanelTitle;
private boolean selectetResource = false;
/** The resource bean. */
private ResourceElementBean resourceBean;
@ -79,46 +90,66 @@ public class SelectedResourceWidget extends Composite {
addHandlers();
}
private void updateFields() {
this.fieldName.setText(resourceBean.getEditableName());
if(resourceBean.getDescription()!=null && !resourceBean.getDescription().isEmpty()) {
if (resourceBean.getDescription() != null && !resourceBean.getDescription().isEmpty()) {
this.fieldDescription.setVisible(true);
this.fieldDescription.setText(resourceBean.getDescription());
}else
} else
this.fieldDescription.setVisible(false);
}
/**
* Adds the handlers.
*/
private void addHandlers() {
buttonEdit.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
editPanel.clear();
ResourceInfoForm resourceInformationInfo = new ResourceInfoForm(resourceBean) {
protected void onUnload() {
super.onUnload();
updateFields();
};
};
editPanel.add(resourceInformationInfo);
manageEditOpenResource();
}
});
buttonDelete.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
SelectResourceByWEMainPanel.eventBus.fireEvent(new RemovePublishingResourceEvent(resourceBean));
}
});
MouseDownHandler handler = new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
manageEditOpenResource();
}
};
selectedResourcesPanelTitle.addDomHandler(handler, MouseDownEvent.getType());
}
private void manageEditOpenResource() {
editPanel.clear();
if (selectetResource) {
selectetResource = false;
} else {
ResourceInfoForm resourceInformationInfo = new ResourceInfoForm(resourceBean) {
protected void onUnload() {
super.onUnload();
updateFields();
};
};
editPanel.add(resourceInformationInfo);
selectetResource = true;
}
}
/**

View File

@ -7,14 +7,6 @@
font-weight: bold;
}
.selected-resources {
}
.selected-resources td {
vertical-align: middle !important;
}
.margin-bottom-8 {
margin-bottom: 8px;
}
@ -26,7 +18,7 @@
}
.title-text {
font-weight: bold;
/*font-weight: bold;*/
font-size: 14px;
display: inline;
vertical-align: middle;
@ -41,14 +33,18 @@
}
</ui:style>
<g:HTMLPanel addStyleNames="{style.margin-bottom-8}">
<g:FlowPanel addStyleNames="{style.selected-resources}">
<g:FlowPanel addStyleNames="selected-resources-ws"
ui:field="resourcePanel">
<!-- <b:Icon type="PUSHPIN" addStyleNames="{style.icon-my-style}"></b:Icon> -->
<b:Button ui:field="buttonEdit" icon="PENCIL"
title="Edit the resource information" />
<b:Button ui:field="buttonDelete" icon="TRASH"
title="Remove this resource" />
<g:Label ui:field="fieldName"
addStyleNames="{style.title-text}"></g:Label>
<g:FlowPanel ui:field="selectedResourcesPanelTitle"
addStyleNames="selected-resources-ws-title">
<g:Label ui:field="fieldName"
addStyleNames="{style.title-text}"></g:Label>
</g:FlowPanel>
<g:Label ui:field="fieldDescription" visible="false"
addStyleNames="{style.descr-text}"></g:Label>
</g:FlowPanel>

View File

@ -62,6 +62,24 @@
padding: 4px 4px !important;
}
.selected-resources-ws {
background-color: #f1f3f9 !important;
padding: 5px;
box-shadow: 0px 3px #888;
border-radius: 3px;
}
.selected-resources-ws td {
vertical-align: middle !important;
}
.selected-resources-ws-title {
display: inline;
}
.selected-resources-ws-title:hover {
cursor: pointer;
}
/* WIZARD-CREATOR CLASSES */
.wizard-creator {
width: 100%;

View File

@ -1187,8 +1187,9 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
logger.info("Checking if the user " + username + " can publish or not on the catalogue");
if (!isWithinPortal()) {
logger.warn("OUT FROM PORTAL DETECTED RETURNING TRUE");
return true;
boolean isPublisherFunny = true;
logger.warn("OUT FROM PORTAL DETECTED RETURNING: "+isPublisherFunny);
return isPublisherFunny;
}
try {

View File

@ -73,7 +73,8 @@ public class CatalogueRoleManager {
List<GCubeGroup> listGroups = groupManager.listGroupsByUser(userid);
groups = new HashSet<GCubeGroup>(listGroups);
}
//Used by Workspace?
// root (so check into the root, the VOs and the VRES)
if(groupManager.isRootVO(currentGroupId)){