task_21363 #1

Closed
francesco.mangiacrapa wants to merge 53 commits from task_21363 into master
4 changed files with 105 additions and 28 deletions
Showing only changes of commit 3fcd1f3f3a - Show all commits

View File

@ -89,6 +89,12 @@ public class CkanContentModeratorWidgetController {
// if items selected are > 0 then shows button "Update status as.."
howeView.setVisibleUpdateStatusAction(items.size() > 0);
if(howeView.getDisplayingItemStatus().equals(ItemStatus.APPROVED)) {
GWT.log("The Item Status displayed is "+ItemStatus.APPROVED +" hiding update status actions");
howeView.setVisibleUpdateStatusAction(false);
}
}
}
});
@ -209,7 +215,7 @@ public class CkanContentModeratorWidgetController {
}
};
t.schedule(12000);
t.schedule(15000);
}
/**

View File

@ -8,6 +8,7 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModerat
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CheckBoxSelectIemsEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStatusEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.LoadingPanel;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.UtilFunct;
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
import org.gcube.portlets.widgets.ckancontentmoderator.shared.OperationReport;
@ -33,6 +34,7 @@ import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
@ -62,6 +64,9 @@ public class HomeView extends Composite {
@UiField
Heading pageHeader;
@UiField
HTMLPanel actionLoaderPanel;
@UiField
HTMLPanel confirmPanel;
@ -76,6 +81,8 @@ public class HomeView extends Composite {
private HandlerManager eventBus;
private LoadingPanel actionInProgressLoader = new LoadingPanel(new HTML("Performing action..."));
/**
* The Interface HomeViewUiBinder.
*
@ -114,12 +121,20 @@ public class HomeView extends Composite {
}
showActionLoader(false);
actionLoaderPanel.add(actionInProgressLoader);
setStatusOptions(status);
bindEvents();
confirmPanel.add(confirmPanelContainer);
}
private void showActionLoader(boolean showActionInProgress) {
GWT.log("Show action in progress: "+showActionInProgress);
actionLoaderPanel.setVisible(showActionInProgress);
}
/**
* Sets the status options according to item status selected
*/
@ -141,6 +156,11 @@ public class HomeView extends Composite {
}
}
//Hiding the changing of any status from the APPROVED
if(selectedStatus.equals(ItemStatus.APPROVED)) {
navLink.setVisible(false);
}
}
}
@ -297,10 +317,11 @@ public class HomeView extends Composite {
* Show do action delete permanently.
*/
private void showDoActionViewDeletePermanently() {
confirmPanelContainer.clear();
GWT.log("showDoActionViewDeletePermanently...");
DoActionCMSView doActionCMS = new DoActionCMSView();
final DoActionCMSView doActionCMS = new DoActionCMSView();
final List<CatalogueDataset> selectedItems = paginatedView.getSelectItems();
doActionCMS.permanentlyDelete(selectedItems);
@ -319,19 +340,50 @@ public class HomeView extends Composite {
@Override
public void onClick(ClickEvent event) {
confirmPanelContainer.clear();
AlertType alert = AlertType.SUCCESS;
int count = selectedItems.size();
String msg = "Deleted permanently";
if (count > 0) {
if (count == 1) {
msg += " one item";
} else {
msg += " " + count + " items";
showActionLoader(true);
List<String> listDatasetNames = UtilFunct.toListDatasetNames(doActionCMS.getListSelectItems());
CkanContentModeratorWidgetController.contentModeratorService.permanentlyDelete(listDatasetNames, new AsyncCallback<OperationReport>() {
@Override
public void onFailure(Throwable caught) {
showActionLoader(false);
Window.alert(caught.getMessage());
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus,
"Sorry an error occurred. Please, refresh and try again", AlertType.ERROR));
}
msg += " from Catalogue";
}
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg, alert));
@Override
public void onSuccess(OperationReport result) {
showActionLoader(false);
AlertType alert = AlertType.SUCCESS;
int count = selectedItems.size();
String msg = "Deleted permanently";
if (count > 0) {
if (count == 1) {
msg += " one item";
} else {
msg += " " + count + " items";
}
msg += " from Catalogue";
}
int errorCount = result.getErrorMapItems().size();
if (errorCount > 0) {
msg += " <br/>Error occurred on deleting permanently " + errorCount + " item/s:";
for (String key : result.getErrorMapItems().keySet()) {
msg += "<br/> "+ key+". Error: "+ result.getErrorMapItems().get(key);
}
alert = AlertType.WARNING;
}
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg, alert));
}
});
}
});
@ -374,8 +426,9 @@ public class HomeView extends Composite {
*
* @param doActionCMSView the do action CMS view
*/
private void performCMSAction(DoActionCMSView doActionCMSView) {
private void performCMSAction(final DoActionCMSView doActionCMSView) {
showActionLoader(true);
final ItemStatus toStatus = doActionCMSView.getToStatus();
List<String> listDatasetNames = UtilFunct.toListDatasetNames(doActionCMSView.getListSelectItems());
switch (toStatus) {
@ -386,7 +439,7 @@ public class HomeView extends Composite {
@Override
public void onSuccess(OperationReport result) {
showActionLoader(false);
AlertType alert = AlertType.SUCCESS;
int count = result.getPassedListItems().size();
String msg = "";
@ -415,6 +468,7 @@ public class HomeView extends Composite {
@Override
public void onFailure(Throwable caught) {
showActionLoader(false);
Window.alert(caught.getMessage());
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus,
"Sorry an error occurred. Please, refresh and try again", AlertType.ERROR));
@ -431,6 +485,7 @@ public class HomeView extends Composite {
@Override
public void onFailure(Throwable caught) {
showActionLoader(false);
Window.alert(caught.getMessage());
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus,
"Sorry an error occurred. Please, refresh and try again", AlertType.ERROR));
@ -439,7 +494,7 @@ public class HomeView extends Composite {
@Override
public void onSuccess(OperationReport result) {
showActionLoader(false);
AlertType alert = AlertType.SUCCESS;
int count = result.getPassedListItems().size();
String msg = "";
@ -459,6 +514,8 @@ public class HomeView extends Composite {
for (String key : result.getErrorMapItems().keySet()) {
msg += "<br/> "+ key+". Error: "+ result.getErrorMapItems().get(key);
}
alert = AlertType.WARNING;
}
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg, alert));
@ -476,6 +533,7 @@ public class HomeView extends Composite {
@Override
public void onFailure(Throwable caught) {
showActionLoader(false);
Window.alert(caught.getMessage());
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus,
"Sorry an error occurred. Please, refresh and try again", AlertType.ERROR));
@ -483,7 +541,7 @@ public class HomeView extends Composite {
@Override
public void onSuccess(OperationReport result) {
showActionLoader(false);
AlertType alert = AlertType.SUCCESS;
int count = result.getPassedListItems().size();
String msg = "";
@ -494,7 +552,14 @@ public class HomeView extends Composite {
msg += count + " items";
}
msg += " moved to " + toStatus + " status.";
boolean isPermanentlyDelete = doActionCMSView.isPermanentlyDelete();
if(isPermanentlyDelete) {
msg += " deleted permanently from Catalogue";
}
else {
msg += " moved to " + toStatus + " status.";
}
}
int errorCount = result.getErrorMapItems().size();
@ -503,6 +568,8 @@ public class HomeView extends Composite {
for (String key : result.getErrorMapItems().keySet()) {
msg += "<br/> "+ key+". Error: "+ result.getErrorMapItems().get(key);
}
alert = AlertType.WARNING;
}
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg, alert));
@ -517,4 +584,8 @@ public class HomeView extends Composite {
}
}
public ItemStatus getDisplayingItemStatus() {
return displayingItemStatus;
}
}

View File

@ -54,6 +54,7 @@
addStyleNames="{style.button-style}" type="LINK" visible="false">Permanently
Delete</b:Button>
</g:HorizontalPanel>
<g:HTMLPanel ui:field="actionLoaderPanel"></g:HTMLPanel>
<g:HTMLPanel ui:field="confirmPanel"></g:HTMLPanel>
<g:HTMLPanel ui:field="panelContainer"></g:HTMLPanel>
</g:HTMLPanel>

View File

@ -7,13 +7,12 @@ import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
/**
* The Class LoadingPanel.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 16, 2021
* Jun 16, 2021
*/
public class LoadingPanel extends HorizontalPanel {
@ -28,11 +27,11 @@ public class LoadingPanel extends HorizontalPanel {
this.getElement().getStyle().setMargin(5.0, Unit.PX);
// LOADING_PANEL.setSpacing(3);
this.add(LOADING_IMAGE);
if (html != null) {
HTML loadingText = new HTML("Loading...");
loadingText.getElement().getStyle().setPaddingLeft(5.0, Unit.PX);
this.add(loadingText);
}
}
if (html == null)
html = new HTML("Loading...");
html.getElement().getStyle().setPaddingLeft(5.0, Unit.PX);
this.add(html);
}
}