Introducing the DoAction Form

This commit is contained in:
Francesco Mangiacrapa 2021-06-28 18:41:52 +02:00
parent 9977824106
commit ae9f61a4f2
5 changed files with 133 additions and 38 deletions

View File

@ -30,7 +30,7 @@ import com.google.gwt.view.client.Range;
import com.google.gwt.view.client.SelectionModel;
import com.google.gwt.view.client.SingleSelectionModel;
// TODO: Auto-generated Javadoc
/**
* The Class ContentModeratorPaginatedView.
*

View File

@ -4,13 +4,12 @@ import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class ContentModeratorSystemBaseView.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 16, 2021
* Jun 16, 2021
*/
public class ContentModeratorSystemBaseView {
@ -41,8 +40,7 @@ public class ContentModeratorSystemBaseView {
public void addToCenter(Widget w) {
centerPanel.add(w);
}
/**
* Adds the to bottom.
*

View File

@ -0,0 +1,63 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
import java.util.List;
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
import com.github.gwtbootstrap.client.ui.AlertBlock;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.TextArea;
import com.google.gwt.core.client.GWT;
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.HTML;
import com.google.gwt.user.client.ui.Widget;
public class DoActionCMS extends Composite {
private static DoActionCMSUiBinder uiBinder = GWT.create(DoActionCMSUiBinder.class);
interface DoActionCMSUiBinder extends UiBinder<Widget, DoActionCMS> {
}
@UiField
HTML htmlDisplayMessage;
@UiField
CheckBox checkBoxPermDelete;
@UiField
TextArea txtMsgReason;
@UiField
Button buttonActionConfirmYES;
@UiField
Button buttonActionConfirmNO;
@UiField
AlertBlock alertBlockDoAction;
public DoActionCMS(ItemStatus fromStatus, ItemStatus toStatus, List<CatalogueDataset> listSelectItems) {
initWidget(uiBinder.createAndBindUi(this));
int count = listSelectItems.size();
String msg = "Going to update status of";
if (count > 0) {
if (count == 1) {
msg += " one item";
} else {
msg += " " + count + " items";
}
msg += " from <b>" + fromStatus.getLabel() + "</b> to <b>" + toStatus.getLabel() + "</b>. Confirm?";
} else
return;
htmlDisplayMessage.setHTML(msg);
}
}

View File

@ -0,0 +1,24 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
</ui:style>
<g:HTMLPanel>
<b:AlertBlock ui:field="alertBlockDoAction">
<g:HTML ui:field="htmlDisplayMessage"></g:HTML>
<b:Form type="VERTICAL">
<b:TextArea placeholder="Rejecting reason..."
ui:field="txtMsgReason" />
<b:CheckBox ui:field="checkBoxPermDelete">Permanently Delete</b:CheckBox>
<b:Paragraph>
<b:Button type="PRIMARY" ui:field="buttonActionConfirmYES">YES</b:Button>
<b:Button ui:field="buttonActionConfirmNO">NO</b:Button>
</b:Paragraph>
</b:Form>
</b:AlertBlock>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -8,18 +8,11 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CheckBoxSel
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.AlertBlock;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.Dropdown;
import com.github.gwtbootstrap.client.ui.Heading;
import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.base.AlertBase;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.event.ClosedEvent;
import com.github.gwtbootstrap.client.ui.event.ClosedHandler;
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.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
@ -60,8 +53,8 @@ public class HomeView extends Composite {
@UiField
HTMLPanel confirmPanel;
private ScrollPanel confirmPanelContainer = new ScrollPanel();
private ScrollPanel confirmPanelContainer = new ScrollPanel();
private List<NavLink> setStatusOptions = new ArrayList<NavLink>();
@ -143,22 +136,23 @@ public class HomeView extends Composite {
@Override
public void onClick(ClickEvent event) {
selectedItems = paginatedView.getSelectItems();
int count = selectedItems.size();
String msg = "Going to update status of";
if (count > 0) {
if (count == 1) {
msg += " one item";
} else {
msg += " " + count + " items";
}
msg += " from <b>" + displayingItemStatus.getLabel() + "</b> to <b>" + navLink.getText()
+ "</b>. Confirm?";
}else
return;
showConfirm(msg);
// selectedItems = paginatedView.getSelectItems();
// int count = selectedItems.size();
// String msg = "Going to update status of";
// if (count > 0) {
// if (count == 1) {
// msg += " one item";
// } else {
// msg += " " + count + " items";
// }
//
// msg += " from <b>" + displayingItemStatus.getLabel() + "</b> to <b>" + navLink.getText()
// + "</b>. Confirm?";
// } else
// return;
if(paginatedView.getSelectItems().size()>0) {
showConfirm(navLink);
}
}
});
@ -207,10 +201,27 @@ public class HomeView extends Composite {
*
* @param msg the msg
*/
public void showConfirm(String msg) {
public void showConfirm(NavLink navLink) {
confirmPanelContainer.clear();
GWT.log("showConfirm clicked link: "+navLink.getText());
ItemStatus fromStatus = displayingItemStatus;
ItemStatus toStatus = null;
final AlertBlock newAlertBlock = new AlertBlock(AlertType.DEFAULT);
for (ItemStatus theStatus : ItemStatus.values()) {
if(theStatus.getLabel().compareTo(navLink.getText().trim())==0) {
toStatus = theStatus;
break;
}
}
GWT.log("Do action on from: "+fromStatus + " to: "+toStatus);
if(toStatus==null) {
return;
}
DoActionCMS doActionCMS = new DoActionCMS(fromStatus, toStatus, paginatedView.getSelectItems());
/*final AlertBlock newAlertBlock = new AlertBlock(AlertType.DEFAULT);
newAlertBlock.setAnimation(true);
newAlertBlock.setClose(true);
@ -243,10 +254,10 @@ public class HomeView extends Composite {
buttonActionConfirmNo.getElement().getStyle().setMarginLeft(10, Unit.PX);
buttonActionConfirmNo.setText("NO");
newAlertBlock.add(buttonActionConfirmNo);
newAlertBlock.setHTML(msg);
confirmPanelContainer.add(newAlertBlock);
newAlertBlock.setHTML(msg);*/
confirmPanelContainer.add(doActionCMS);
}
/**
@ -261,12 +272,11 @@ public class HomeView extends Composite {
setVisibleUpdateStatusAction(false);
try {
confirmPanelContainer.clear();
}catch (Exception e) {
GWT.log("error: "+e.getMessage() + " cause: "+e.getCause().toString());
} catch (Exception e) {
GWT.log("error: " + e.getMessage() + " cause: " + e.getCause().toString());
}
paginatedView.loadItemsForStatus(itemStatus);
GWT.log("loadItemsWithStatus end");
}