task_21363 #1

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

View File

@ -25,9 +25,12 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainTabPanel;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.FlowPanel;
@ -45,6 +48,7 @@ public class CkanContentModeratorWidgetController {
.create(CkanContentModeratorService.class);
private FlowPanel mainPanel = new FlowPanel();
private FlowPanel infoPanel = new FlowPanel();
private ContentModeratorToolbar toolbar;
private MainTabPanel mainTabPanel = new MainTabPanel();
@ -65,6 +69,7 @@ public class CkanContentModeratorWidgetController {
howeView = new HomeView(eventBus, status, displayFields, sortByField);
mainTabPanel.addHomeWidget(howeView.getPanel());
mainPanel.add(toolbar);
mainPanel.add(infoPanel);
mainPanel.add(mainTabPanel);
bindEvents();
}
@ -160,11 +165,32 @@ public class CkanContentModeratorWidgetController {
@Override
public void onValueChanged(SelectItemsWithItemStatusEvent statusSelectedEvent) {
GWT.log("On value changed: " + statusSelectedEvent.getItemStatus());
infoPanel.clear();
if (statusSelectedEvent.getItemStatus() != null) {
howeView.loadItemsWithStatus(statusSelectedEvent.getItemStatus());
mainTabPanel.selectTab(0);
}
if(statusSelectedEvent.getDisplayMessage()!=null) {
final Alert alert = new Alert(statusSelectedEvent.getDisplayMessage());
alert.setType(AlertType.INFO);
alert.setClose(true);
alert.setAnimation(true);
infoPanel.add(alert);
//Cleans the info panel after 10 sec.
Timer t = new Timer() {
@Override
public void run() {
infoPanel.clear();
}
};
t.schedule(10000);
}
}
});
}

View File

@ -14,14 +14,17 @@ import com.google.gwt.event.shared.GwtEvent;
public class SelectItemsWithItemStatusEvent extends GwtEvent<SelectItemsWithItemStatusEventHandler> {
public static Type<SelectItemsWithItemStatusEventHandler> TYPE = new Type<SelectItemsWithItemStatusEventHandler>();
private ItemStatus itemStatus;
private String displayMessage;
/**
* Instantiates a new click item event.
*
* @param itemStatus the item status
* @param displayMessage the display message
*/
public SelectItemsWithItemStatusEvent(ItemStatus itemStatus) {
public SelectItemsWithItemStatusEvent(ItemStatus itemStatus, String displayMessage) {
this.itemStatus = itemStatus;
this.displayMessage = displayMessage;
}
/**
@ -53,4 +56,13 @@ public class SelectItemsWithItemStatusEvent extends GwtEvent<SelectItemsWithItem
return itemStatus;
}
/**
* Gets the display message.
*
* @return the display message
*/
public String getDisplayMessage() {
return displayMessage;
}
}

View File

@ -67,7 +67,7 @@ public class ContentModeratorToolbar extends Composite {
public void onClick(ClickEvent event) {
GWT.log("clicked: "+status);
setActiveStatus(status);
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(status));
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(status, null));
}
});

View File

@ -6,6 +6,7 @@ import java.util.List;
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
import org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModeratorWidgetController;
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.UtilFunct;
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
@ -33,7 +34,6 @@ import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class HomeView.
*
@ -237,16 +237,17 @@ public class HomeView extends Composite {
*/
private void showDoActionView(NavLink navLink) {
confirmPanelContainer.clear();
GWT.log("showConfirm clicked link: " + navLink.getText());
GWT.log("showDoActionView clicked link: " + navLink.getText());
ItemStatus fromStatus = displayingItemStatus;
ItemStatus toStatus = UtilFunct.toStatusFromStatusLabel(navLink.getText().trim());
final ItemStatus toStatus = UtilFunct.toStatusFromStatusLabel(navLink.getText().trim());
GWT.log("Do action on from: " + fromStatus + " to: " + toStatus);
if (toStatus == null) {
return;
}
DoActionCMSView doActionCMS = new DoActionCMSView();
doActionCMS.updateStatus(fromStatus, toStatus, paginatedView.getSelectItems());
final List<CatalogueDataset> selectedItems = paginatedView.getSelectItems();
doActionCMS.updateStatus(fromStatus, toStatus, selectedItems);
final AlertBlock newAlertBlock = doActionCMS.getAlertBlockDoAction();
newAlertBlock.addClosedHandler(new ClosedHandler<AlertBase>() {
@ -264,6 +265,22 @@ public class HomeView extends Composite {
public void onClick(ClickEvent event) {
confirmPanelContainer.clear();
//TODO DO ACTION UPDATE STATUS OR DELETE PERMANENTLY
int count = selectedItems.size();
String msg = "";
if (count > 0) {
if (count == 1) {
msg += "One item";
} else {
msg += count + " items";
}
msg += " moved to " + toStatus + " status";
}
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg));
}
});
@ -285,10 +302,11 @@ public class HomeView extends Composite {
*/
private void showDoActionViewDeletePermanently() {
confirmPanelContainer.clear();
GWT.log("showDoActionDeletePermanently...");
GWT.log("showDoActionViewDeletePermanently...");
DoActionCMSView doActionCMS = new DoActionCMSView();
doActionCMS.permanentlyDelete(paginatedView.getSelectItems());
final List<CatalogueDataset> selectedItems = paginatedView.getSelectItems();
doActionCMS.permanentlyDelete(selectedItems);
final AlertBlock newAlertBlock = doActionCMS.getAlertBlockDoAction();
newAlertBlock.addClosedHandler(new ClosedHandler<AlertBase>() {
@ -306,6 +324,21 @@ public class HomeView extends Composite {
public void onClick(ClickEvent event) {
confirmPanelContainer.clear();
//TODO DO ACTION DELETE PERMANENTLY
int count = selectedItems.size();
String msg = "Deleted permanently";
if (count > 0) {
if (count == 1) {
msg += " one item";
} else {
msg += " " + count + " items";
}
msg += " from Catalogue";
}
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg));
}
});