Added Delete Item facility
This commit is contained in:
parent
9d7efed441
commit
23f2764ca4
|
@ -1,16 +1,14 @@
|
|||
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.action;
|
||||
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.ReloadDatasetPageEvent;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.utils.LoaderIcon;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.AlertBlock;
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.Icon;
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
|
@ -41,9 +39,9 @@ public class DeleteItemPanel extends Composite {
|
|||
|
||||
private FlowPanel alertPanel = new FlowPanel();
|
||||
|
||||
private Icon iconSpinner = new Icon(IconType.SPINNER);
|
||||
// private Icon iconSpinner = new Icon(IconType.SPINNER);
|
||||
|
||||
private HandlerManager mainApplicationBusRef;
|
||||
private HandlerManager eventBusMainApplication;
|
||||
|
||||
private final CKanPublisherServiceAsync ckanServices = CKanPublisherServiceAsync.Util.getInstance();
|
||||
|
||||
|
@ -56,19 +54,13 @@ public class DeleteItemPanel extends Composite {
|
|||
|
||||
private DatasetBean selectedDataset;
|
||||
|
||||
public DeleteItemPanel(HandlerManager mainApplicationBusRef, String datasetIdOrName) {
|
||||
public DeleteItemPanel(HandlerManager eventBusMainApp, String datasetIdOrName) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.datasetIdOrName = datasetIdOrName;
|
||||
this.mainApplicationBusRef = mainApplicationBusRef;
|
||||
this.eventBusMainApplication = eventBusMainApp;
|
||||
|
||||
iconSpinner.setSpin(true);
|
||||
iconSpinner.getElement().getStyle().setMarginLeft(5, Unit.PX);
|
||||
iconSpinner.getElement().getStyle().setProperty("animation", "spin 1s infinite linear");
|
||||
alertPanel.add(iconSpinner);
|
||||
infoBlock.add(alertPanel);
|
||||
|
||||
infoBlock.setVisible(true);
|
||||
|
||||
LoaderIcon loaderIcon = new LoaderIcon("Checking your permissions...");
|
||||
setAlertBlock(null, loaderIcon, AlertType.INFO, true);
|
||||
|
||||
|
@ -99,10 +91,8 @@ public class DeleteItemPanel extends Composite {
|
|||
public void onSuccess(DatasetBean result) {
|
||||
setAlertBlock("", null, null, false);
|
||||
panelConfirm.setVisible(true);
|
||||
|
||||
selectedDataset = result;
|
||||
|
||||
deleteMessage.add(new HTML("<div><i>" + result.getTitle() + "</i></div>"));
|
||||
deleteMessage.add(new HTML("<div><br/><i><b>" + result.getTitle() + "</b></i></div>"));
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -119,6 +109,7 @@ public class DeleteItemPanel extends Composite {
|
|||
|
||||
LoaderIcon loaderIcon = new LoaderIcon("Deleting the item....");
|
||||
setAlertBlock(null, loaderIcon, AlertType.INFO, true);
|
||||
panelConfirm.setVisible(false);
|
||||
ckanServices.deleteItem(selectedDataset, new AsyncCallback<Boolean>() {
|
||||
|
||||
@Override
|
||||
|
@ -131,10 +122,12 @@ public class DeleteItemPanel extends Composite {
|
|||
@Override
|
||||
public void onSuccess(Boolean result) {
|
||||
if (result) {
|
||||
setAlertBlock("Item deleted correclty", null, AlertType.INFO, true);
|
||||
setAlertBlock("Item '" + selectedDataset.getTitle() + "' permanently deleted!", null,
|
||||
AlertType.SUCCESS, true);
|
||||
eventBusMainApplication.fireEvent(new ReloadDatasetPageEvent(null));
|
||||
} else {
|
||||
setAlertBlock("Sorry, I cannot delete the item. Please contact the support", null, AlertType.INFO,
|
||||
true);
|
||||
setAlertBlock("Sorry, I cannot delete the item. Refresh and retry or contact the support", null,
|
||||
AlertType.INFO, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,16 +21,16 @@
|
|||
}
|
||||
</ui:style>
|
||||
<g:FlowPanel>
|
||||
<b:AlertBlock type="INFO" close="false" animation="true"
|
||||
<b:AlertBlock close="false" animation="true"
|
||||
visible="false" ui:field="infoBlock"
|
||||
styleName="{style.block-alert-style}"></b:AlertBlock>
|
||||
addStyleNames="{style.block-alert-style}"></b:AlertBlock>
|
||||
<g:FlowPanel ui:field="panelConfirm" visible="false">
|
||||
<g:HTMLPanel ui:field="deleteMessage"
|
||||
addStyleNames="{style.delete-message-panel}">
|
||||
Do you want to delete the item?
|
||||
Do you want to permanently delete the item?
|
||||
</g:HTMLPanel>
|
||||
<b:Button type="PRIMARY" ui:field="buttonDelete"
|
||||
addStyleNames="{style.float-right}">Delete</b:Button>
|
||||
addStyleNames="{style.float-right}">Permanently delete</b:Button>
|
||||
</g:FlowPanel>
|
||||
</g:FlowPanel>
|
||||
</ui:UiBinder>
|
|
@ -386,6 +386,7 @@ public class CreateDatasetForm extends Composite {
|
|||
iconSpinner.setSpin(true);
|
||||
iconSpinner.getElement().getStyle().setMarginLeft(5, Unit.PX);
|
||||
iconSpinner.getElement().getStyle().setProperty("animation", "spin 1s infinite linear");
|
||||
infoBlock.add(alertPanel);
|
||||
|
||||
List<String> listOfSteps = null;
|
||||
if (isWorkspaceRequest) {
|
||||
|
|
|
@ -718,106 +718,6 @@ public class UpdateDatasetForm extends Composite {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When the organization name is changed we need to retrieve the list of
|
||||
* profiles and groups.
|
||||
*
|
||||
* @param operation the operation
|
||||
*/
|
||||
|
||||
// NEVER USED IN UPDATE MODE
|
||||
/*
|
||||
* private void organizationsListboxChangeHandlerBody(OPERATION operation) {
|
||||
*
|
||||
* // remove any other product profiles metadataTypeListbox.clear();
|
||||
*
|
||||
* // add "none" item again metadataTypeListbox.addItem(NONE_PROFILE);
|
||||
*
|
||||
* // select "none" metadataTypeListbox.setSelectedIndex(0);
|
||||
*
|
||||
* // get the name of the organization from the title String
|
||||
* selectedOrganizationTitle = organizationsListbox.getSelectedItemText(); final
|
||||
* String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle);
|
||||
*
|
||||
* theDatasetBean.setSelectedOrganization(orgName);
|
||||
*
|
||||
* // try to retrieve the profiles
|
||||
* setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
|
||||
*
|
||||
* // disable the list of organizations name so that the user doesn't change it
|
||||
* // again // also disable the profiles and the list of groups
|
||||
* organizationsListbox.setEnabled(false);
|
||||
* metadataTypeListbox.setEnabled(false); groupsListbox.clear();
|
||||
* groupsControlGroup.setVisible(false);
|
||||
*
|
||||
* // perform remote request of profiles for the selected organization
|
||||
* ckanServices.getProfiles(orgName, new
|
||||
* AsyncCallback<List<MetaDataProfileBean>>() {
|
||||
*
|
||||
* @Override public void onSuccess(final List<MetaDataProfileBean> profiles) {
|
||||
*
|
||||
* if (profiles != null) {
|
||||
*
|
||||
* theDatasetBean.setMetadataList(profiles); prepareMetadataList(theDatasetBean,
|
||||
* operation); organizationsListbox.setEnabled(true);
|
||||
* metadataTypeListbox.setEnabled(true);
|
||||
*
|
||||
* // try to retrieve the licenses
|
||||
* setAlertBlock("Retrieving groups, please wait...", AlertType.INFO, true);
|
||||
*
|
||||
* // request groups ckanServices.getUserGroups(orgName, new
|
||||
* AsyncCallback<List<OrganizationBean>>() {
|
||||
*
|
||||
* @Override public void onSuccess(List<OrganizationBean> groups) {
|
||||
*
|
||||
* if (groups == null) {
|
||||
* setAlertBlock("Error while retrieving groups, try later", AlertType.ERROR,
|
||||
* true); } else { if (groups.isEmpty()) { groupsControlGroup.setVisible(false);
|
||||
* } else {
|
||||
*
|
||||
* // add groups for (OrganizationBean group : groups) {
|
||||
* groupsListbox.addItem(group.getTitle(), group.getName()); }
|
||||
* groupsListbox.setEnabled(true); hideGroupsAlreadyInProfile(profiles); }
|
||||
* setAlertBlock("", AlertType.ERROR, false); } }
|
||||
*
|
||||
* @Override public void onFailure(Throwable caught) {
|
||||
* setAlertBlock("Error while retrieving groups, try later", AlertType.ERROR,
|
||||
* true); } });
|
||||
*
|
||||
* // check also for tags (if for that context there is a vocabulary or not)
|
||||
* tagsPanel.setVisible(false);
|
||||
* setAlertBlock("Checking for tags vocabulary, please wait...", AlertType.INFO,
|
||||
* true); ckanServices.getTagsForOrganization(orgName, new
|
||||
* AsyncCallback<List<String>>() {
|
||||
*
|
||||
* @Override public void onSuccess(List<String> vocabulary) {
|
||||
*
|
||||
* tagsPanel.setVocabulary(vocabulary); tagsPanel.setVisible(true);
|
||||
* setAlertBlock("", AlertType.ERROR, false); }
|
||||
*
|
||||
* @Override public void onFailure(Throwable arg0) {
|
||||
*
|
||||
* setAlertBlock(
|
||||
* "Error while checking if a vocabulary of tags is defined in the selected organization."
|
||||
* , AlertType.ERROR, true); tagsPanel.setVocabulary(null);
|
||||
* tagsPanel.setVisible(true);
|
||||
*
|
||||
* } });
|
||||
*
|
||||
* } else setAlertBlock("Error while retrieving types, sorry", AlertType.ERROR,
|
||||
* true);
|
||||
*
|
||||
* }
|
||||
*
|
||||
* @Override public void onFailure(Throwable caught) {
|
||||
*
|
||||
* setAlertBlock("Error while retrieving types, sorry", AlertType.ERROR, true);
|
||||
*
|
||||
* } });
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add the items to the listbox and put data into the metadataPanel.
|
||||
*
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
<!-- Alert blocks for info/errors -->
|
||||
<b:AlertBlock type="INFO" close="false"
|
||||
animation="true" visible="false" ui:field="infoBlock"
|
||||
styleName="{style.block-alert-style}"></b:AlertBlock>
|
||||
addStyleNames="{style.block-alert-style}"></b:AlertBlock>
|
||||
|
||||
<b:ControlGroup ui:field="productTitleGroup">
|
||||
<b:ControlLabel for="title" title="Item title">
|
||||
|
|
|
@ -228,6 +228,9 @@ 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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -236,6 +239,8 @@ 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);
|
||||
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue