task_21363 #1

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

View File

@ -9,6 +9,8 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEv
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEventHandler; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEvent; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEventHandler; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStausEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStausEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEvent; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEventHandler; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent;
@ -56,7 +58,7 @@ public class CkanContentModeratorWidgetController {
*/ */
public CkanContentModeratorWidgetController(ItemStatus status, DISPLAY_FIELD[] displayFields, public CkanContentModeratorWidgetController(ItemStatus status, DISPLAY_FIELD[] displayFields,
DISPLAY_FIELD sortByField) { DISPLAY_FIELD sortByField) {
toolbar = new ContentModeratorToolbar(eventBus); toolbar = new ContentModeratorToolbar(eventBus, status);
howeView = new HomeView(eventBus, status, displayFields, sortByField); howeView = new HomeView(eventBus, status, displayFields, sortByField);
mainTabPanel.addHomeWidget(howeView.getPanel()); mainTabPanel.addHomeWidget(howeView.getPanel());
mainPanel.add(toolbar); mainPanel.add(toolbar);
@ -127,6 +129,19 @@ public class CkanContentModeratorWidgetController {
mainTabPanel.closeTabs(); mainTabPanel.closeTabs();
} }
}); });
eventBus.addHandler(SelectItemsWithItemStausEvent.TYPE, new SelectItemsWithItemStausEventHandler() {
@Override
public void onValueChanged(SelectItemsWithItemStausEvent statusSelectedEvent) {
if(statusSelectedEvent.getItemStatus()!=null) {
howeView.loadItemsWithStatus(statusSelectedEvent.getItemStatus());
mainTabPanel.selectTab(0);
}
}
});
} }
/** /**

View File

@ -0,0 +1,57 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class SelectItemsWithItemStausEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 25, 2021
*/
public class SelectItemsWithItemStausEvent extends GwtEvent<SelectItemsWithItemStausEventHandler> {
public static Type<SelectItemsWithItemStausEventHandler> TYPE = new Type<SelectItemsWithItemStausEventHandler>();
private ItemStatus itemStatus;
/**
* Instantiates a new click item event.
*
* @param itemStatus the item status
*/
public SelectItemsWithItemStausEvent(ItemStatus itemStatus) {
this.itemStatus = itemStatus;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<SelectItemsWithItemStausEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(SelectItemsWithItemStausEventHandler handler) {
handler.onValueChanged(this);
}
/**
* Gets the item status.
*
* @return the item status
*/
public ItemStatus getItemStatus() {
return itemStatus;
}
}

View File

@ -0,0 +1,21 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface SelectItemsWithItemStausEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 25, 2021
*/
public interface SelectItemsWithItemStausEventHandler extends EventHandler {
/**
* On value changed.
*
* @param statusSelectedEvent the status selected event
*/
void onValueChanged(SelectItemsWithItemStausEvent statusSelectedEvent);
}

View File

@ -42,7 +42,7 @@ public class ContentModeratorPaginatedView {
private static final int ITEMS_PER_PAGE = ContentModeratorWidgetConstants.ITEMS_PER_PAGE; private static final int ITEMS_PER_PAGE = ContentModeratorWidgetConstants.ITEMS_PER_PAGE;
private VerticalPanel vPanel = new VerticalPanel(); private VerticalPanel vPanel = new VerticalPanel();
private FlowPanel pagerPanel = new FlowPanel(); private FlowPanel pagerPanel = new FlowPanel();
private Boolean newLoading = false; private Boolean initClassFirstRangeChanged = false;
private ItemsTable<CatalogueDataset> itemsTable; private ItemsTable<CatalogueDataset> itemsTable;
private MyCustomDataProvider<CatalogueDataset> dataProvider = new MyCustomDataProvider<CatalogueDataset>(); private MyCustomDataProvider<CatalogueDataset> dataProvider = new MyCustomDataProvider<CatalogueDataset>();
protected Widget orginalLoadingIndicator = null; protected Widget orginalLoadingIndicator = null;
@ -63,14 +63,15 @@ public class ContentModeratorPaginatedView {
public ContentModeratorPaginatedView(HandlerManager eventbus, ItemStatus theStatus, DISPLAY_FIELD[] displayFields, public ContentModeratorPaginatedView(HandlerManager eventbus, ItemStatus theStatus, DISPLAY_FIELD[] displayFields,
DISPLAY_FIELD sortByField) { DISPLAY_FIELD sortByField) {
this.itemStatus = theStatus; this.itemStatus = theStatus;
this.newLoading = true; this.initClassFirstRangeChanged = true;
this.eventBus = eventbus; this.eventBus = eventbus;
itemsTable = new ItemsTable<CatalogueDataset>(eventbus, displayFields, sortByField); itemsTable = new ItemsTable<CatalogueDataset>(eventbus, displayFields, sortByField);
itemsTable.initTable(null, null, dataProvider); itemsTable.initTable(null, null, dataProvider);
orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator(); orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator();
initPagination(ITEMS_PER_PAGE); initPagination(ITEMS_PER_PAGE);
loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false); //loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false);
loadItemsForStatus(theStatus);
} }
/** /**
@ -143,15 +144,15 @@ public class ContentModeratorPaginatedView {
* @param limit the limit * @param limit the limit
* @param resetStore the reset store * @param resetStore the reset store
*/ */
public void loadNewPage(final int startIdx, final int limit, final boolean resetStore) { private void loadNewPage(final int startIdx, final int limit, final boolean resetStore) {
newLoading = resetStore; //initFirstRangeChanged = resetStore;
GWT.log("loading data with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:" GWT.log("loading data with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:"
+ resetStore + "]"); + resetStore + "]");
// showLoading(true); // showLoading(true);
int newStartIndex = startIdx; int newStartIndex = startIdx;
if (newLoading) { if (resetStore) {
GWT.log("Cleaning all data..."); GWT.log("Cleaning all data...");
newStartIndex = 0; newStartIndex = 0;
serverStartIndex = 0; serverStartIndex = 0;
@ -164,6 +165,13 @@ public class ContentModeratorPaginatedView {
} }
public void loadItemsForStatus(ItemStatus itemStatus) {
this.itemStatus = itemStatus;
getCellTable().setVisibleRangeAndClearData(new Range(0, ITEMS_PER_PAGE), false);
loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, true);
}
/** /**
* Sets the new page result. * Sets the new page result.
* *
@ -173,9 +181,9 @@ public class ContentModeratorPaginatedView {
serverStartIndex = result.getServerEndIndex(); serverStartIndex = result.getServerEndIndex();
if (newLoading) { // if (initFirstRangeChanged) {
getCellTable().setVisibleRangeAndClearData(new Range(result.getClientStartIndex(), ITEMS_PER_PAGE), false); // getCellTable().setVisibleRangeAndClearData(new Range(result.getClientStartIndex(), ITEMS_PER_PAGE), false);
} // }
SelectionModel<? super CatalogueDataset> sm = getCellTable().getSelectionModel(); SelectionModel<? super CatalogueDataset> sm = getCellTable().getSelectionModel();
@ -201,7 +209,7 @@ public class ContentModeratorPaginatedView {
GWT.log("Search finished!!!"); GWT.log("Search finished!!!");
getAsycnDataProvider().updateRowCount(getCellTable().getRowCount(), true); getAsycnDataProvider().updateRowCount(getCellTable().getRowCount(), true);
} }
newLoading = false; //initFirstRangeChanged = false;
} }
@ -260,11 +268,11 @@ public class ContentModeratorPaginatedView {
int start = range.getStart(); int start = range.getStart();
int length = range.getLength(); int length = range.getLength();
if (newLoading) { if (initClassFirstRangeChanged) {
GWT.log("OnLoading is true.. returning"); GWT.log("initClassFirstRangeChanged is true.. returning");
initClassFirstRangeChanged = false;
return; return;
} }
GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount()); GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount());
loadNewPage(start, length, false); loadNewPage(start, length, false);
eventBus.fireEvent(new TableRangeViewChangedEvent<T>(start, length)); eventBus.fireEvent(new TableRangeViewChangedEvent<T>(start, length));

View File

@ -2,8 +2,10 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus; import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEvent; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStausEvent;
import com.github.gwtbootstrap.client.ui.Dropdown; import com.github.gwtbootstrap.client.ui.Dropdown;
import com.github.gwtbootstrap.client.ui.Label;
import com.github.gwtbootstrap.client.ui.NavLink; import com.github.gwtbootstrap.client.ui.NavLink;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
@ -27,13 +29,20 @@ public class ContentModeratorToolbar extends Composite {
@UiField @UiField
NavLink closeAllTabs; NavLink closeAllTabs;
@UiField
Label statusInfo;
private HandlerManager eventBus; private HandlerManager eventBus;
public ContentModeratorToolbar(HandlerManager eventBus) { private ItemStatus activeStatus;
public ContentModeratorToolbar(HandlerManager eventBus, ItemStatus status) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
this.eventBus = eventBus; this.eventBus = eventBus;
//statusInfo.setReadOnly(true);
fillItemStatusOptions(); fillItemStatusOptions();
bindEvents(); bindEvents();
setActiveStatus(status);
} }
private void bindEvents() { private void bindEvents() {
@ -45,11 +54,10 @@ public class ContentModeratorToolbar extends Composite {
} }
}); });
} }
private void fillItemStatusOptions() { private void fillItemStatusOptions() {
for (ItemStatus status : ItemStatus.values()) { for (final ItemStatus status : ItemStatus.values()) {
NavLink link = new NavLink(); NavLink link = new NavLink();
link.setText(status.getLabel()); link.setText(status.getLabel());
@ -57,13 +65,23 @@ public class ContentModeratorToolbar extends Composite {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
// TODO Auto-generated method stub setActiveStatus(status);
eventBus.fireEvent(new SelectItemsWithItemStausEvent(activeStatus));
} }
}); });
dropdownSelectStatus.add(link); dropdownSelectStatus.add(link);
} }
}
private void setActiveStatus(ItemStatus status) {
this.activeStatus = status;
statusInfo.setText(activeStatus.getLabel());
} }
public ItemStatus getActiveStatus() {
return activeStatus;
}
} }

View File

@ -7,14 +7,26 @@
.important { .important {
font-weight: bold; font-weight: bold;
} }
.margin-top-12 {
margin-top: 12px;
}
</ui:style> </ui:style>
<g:HTMLPanel> <g:HTMLPanel>
<b:NavPills> <b:Navbar>
<b:Nav>
<b:Dropdown text="Select Items with status..." <b:Dropdown text="Select Items with status..."
ui:field="dropdownSelectStatus"> ui:field="dropdownSelectStatus">
</b:Dropdown> </b:Dropdown>
</b:Nav>
<b:Nav>
<b:Label ui:field="statusInfo" type="INFO"
addStyleNames="{style.margin-top-12}"></b:Label>
</b:Nav>
<b:Nav alignment="RIGHT">
<b:NavLink ui:field="closeAllTabs">Close All Tabs <b:NavLink ui:field="closeAllTabs">Close All Tabs
</b:NavLink> </b:NavLink>
</b:NavPills> </b:Nav>
</b:Navbar>
</g:HTMLPanel> </g:HTMLPanel>
</ui:UiBinder> </ui:UiBinder>

View File

@ -88,9 +88,8 @@ public class HomeView extends Composite {
public HomeView(HandlerManager eventBus, ItemStatus status, DISPLAY_FIELD[] displayFields, public HomeView(HandlerManager eventBus, ItemStatus status, DISPLAY_FIELD[] displayFields,
DISPLAY_FIELD sortByField) { DISPLAY_FIELD sortByField) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
this.displayingItemStatus = status; setDisplayingWithStatus(status);
this.eventBus = eventBus; this.eventBus = eventBus;
this.pageHeader.setSubtext(status.getLabel());
paginatedView = new ContentModeratorPaginatedView(eventBus, status, displayFields, sortByField); paginatedView = new ContentModeratorPaginatedView(eventBus, status, displayFields, sortByField);
cmsPanel.addToCenter(paginatedView.getCellPanel()); cmsPanel.addToCenter(paginatedView.getCellPanel());
cmsPanel.addToBottom(paginatedView.getPagerPanel()); cmsPanel.addToBottom(paginatedView.getPagerPanel());
@ -115,6 +114,11 @@ public class HomeView extends Composite {
} }
private void setDisplayingWithStatus(ItemStatus status) {
this.displayingItemStatus = status;
this.pageHeader.setSubtext(status.getLabel());
}
/** /**
* Bind events. * Bind events.
*/ */
@ -188,10 +192,25 @@ public class HomeView extends Composite {
} }
/**
* Show confirm.
*
* @param msg the msg
*/
public void showConfirm(String msg) { public void showConfirm(String msg) {
actionConfirmAlert.setVisible(true); actionConfirmAlert.setVisible(true);
} }
/**
* Load form server the items with status.
*
* @param itemStatus the item status
*/
public void loadItemsWithStatus(ItemStatus itemStatus) {
setDisplayingWithStatus(itemStatus);
paginatedView.loadItemsForStatus(itemStatus);
}
} }

View File

@ -91,13 +91,13 @@ public class MainTabPanel extends Composite {
results.add(tab); results.add(tab);
mainTabPanel.add(tab); mainTabPanel.add(tab);
activeTabPanels(false); //activeTabPanels(false);
Scheduler.get().scheduleDeferred(new ScheduledCommand() { Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override @Override
public void execute() { public void execute() {
mainTabPanel.selectTab(results.size() - 1); //mainTabPanel.selectTab(results.size() - 1);
} }
}); });
@ -141,7 +141,7 @@ public class MainTabPanel extends Composite {
selectTab(0); selectTab(0);
} }
private void selectTab(int tabIndex) { public void selectTab(int tabIndex) {
if (tabIndex <= results.size()) { if (tabIndex <= results.size()) {
mainTabPanel.selectTab(tabIndex); mainTabPanel.selectTab(tabIndex);
} }