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.CloseAllTabsEvent;
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.ShowItemEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent;
@ -56,7 +58,7 @@ public class CkanContentModeratorWidgetController {
*/
public CkanContentModeratorWidgetController(ItemStatus status, DISPLAY_FIELD[] displayFields,
DISPLAY_FIELD sortByField) {
toolbar = new ContentModeratorToolbar(eventBus);
toolbar = new ContentModeratorToolbar(eventBus, status);
howeView = new HomeView(eventBus, status, displayFields, sortByField);
mainTabPanel.addHomeWidget(howeView.getPanel());
mainPanel.add(toolbar);
@ -127,6 +129,19 @@ public class CkanContentModeratorWidgetController {
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 VerticalPanel vPanel = new VerticalPanel();
private FlowPanel pagerPanel = new FlowPanel();
private Boolean newLoading = false;
private Boolean initClassFirstRangeChanged = false;
private ItemsTable<CatalogueDataset> itemsTable;
private MyCustomDataProvider<CatalogueDataset> dataProvider = new MyCustomDataProvider<CatalogueDataset>();
protected Widget orginalLoadingIndicator = null;
@ -63,14 +63,15 @@ public class ContentModeratorPaginatedView {
public ContentModeratorPaginatedView(HandlerManager eventbus, ItemStatus theStatus, DISPLAY_FIELD[] displayFields,
DISPLAY_FIELD sortByField) {
this.itemStatus = theStatus;
this.newLoading = true;
this.initClassFirstRangeChanged = true;
this.eventBus = eventbus;
itemsTable = new ItemsTable<CatalogueDataset>(eventbus, displayFields, sortByField);
itemsTable.initTable(null, null, dataProvider);
orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator();
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 resetStore the reset store
*/
public void loadNewPage(final int startIdx, final int limit, final boolean resetStore) {
newLoading = resetStore;
private void loadNewPage(final int startIdx, final int limit, final boolean resetStore) {
//initFirstRangeChanged = resetStore;
GWT.log("loading data with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:"
+ resetStore + "]");
// showLoading(true);
int newStartIndex = startIdx;
if (newLoading) {
if (resetStore) {
GWT.log("Cleaning all data...");
newStartIndex = 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.
*
@ -173,9 +181,9 @@ public class ContentModeratorPaginatedView {
serverStartIndex = result.getServerEndIndex();
if (newLoading) {
getCellTable().setVisibleRangeAndClearData(new Range(result.getClientStartIndex(), ITEMS_PER_PAGE), false);
}
// if (initFirstRangeChanged) {
// getCellTable().setVisibleRangeAndClearData(new Range(result.getClientStartIndex(), ITEMS_PER_PAGE), false);
// }
SelectionModel<? super CatalogueDataset> sm = getCellTable().getSelectionModel();
@ -201,7 +209,7 @@ public class ContentModeratorPaginatedView {
GWT.log("Search finished!!!");
getAsycnDataProvider().updateRowCount(getCellTable().getRowCount(), true);
}
newLoading = false;
//initFirstRangeChanged = false;
}
@ -260,11 +268,11 @@ public class ContentModeratorPaginatedView {
int start = range.getStart();
int length = range.getLength();
if (newLoading) {
GWT.log("OnLoading is true.. returning");
if (initClassFirstRangeChanged) {
GWT.log("initClassFirstRangeChanged is true.. returning");
initClassFirstRangeChanged = false;
return;
}
GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount());
loadNewPage(start, length, false);
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.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.Label;
import com.github.gwtbootstrap.client.ui.NavLink;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
@ -27,13 +29,20 @@ public class ContentModeratorToolbar extends Composite {
@UiField
NavLink closeAllTabs;
@UiField
Label statusInfo;
private HandlerManager eventBus;
public ContentModeratorToolbar(HandlerManager eventBus) {
private ItemStatus activeStatus;
public ContentModeratorToolbar(HandlerManager eventBus, ItemStatus status) {
initWidget(uiBinder.createAndBindUi(this));
this.eventBus = eventBus;
//statusInfo.setReadOnly(true);
fillItemStatusOptions();
bindEvents();
setActiveStatus(status);
}
private void bindEvents() {
@ -45,11 +54,10 @@ public class ContentModeratorToolbar extends Composite {
}
});
}
private void fillItemStatusOptions() {
for (ItemStatus status : ItemStatus.values()) {
for (final ItemStatus status : ItemStatus.values()) {
NavLink link = new NavLink();
link.setText(status.getLabel());
@ -57,13 +65,23 @@ public class ContentModeratorToolbar extends Composite {
@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
setActiveStatus(status);
eventBus.fireEvent(new SelectItemsWithItemStausEvent(activeStatus));
}
});
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 {
font-weight: bold;
}
.margin-top-12 {
margin-top: 12px;
}
</ui:style>
<g:HTMLPanel>
<b:NavPills>
<b:Navbar>
<b:Nav>
<b:Dropdown text="Select Items with status..."
ui:field="dropdownSelectStatus">
</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>
</b:NavPills>
</b:Nav>
</b:Navbar>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -88,9 +88,8 @@ public class HomeView extends Composite {
public HomeView(HandlerManager eventBus, ItemStatus status, DISPLAY_FIELD[] displayFields,
DISPLAY_FIELD sortByField) {
initWidget(uiBinder.createAndBindUi(this));
this.displayingItemStatus = status;
setDisplayingWithStatus(status);
this.eventBus = eventBus;
this.pageHeader.setSubtext(status.getLabel());
paginatedView = new ContentModeratorPaginatedView(eventBus, status, displayFields, sortByField);
cmsPanel.addToCenter(paginatedView.getCellPanel());
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.
*/
@ -188,10 +192,25 @@ public class HomeView extends Composite {
}
/**
* Show confirm.
*
* @param msg the msg
*/
public void showConfirm(String msg) {
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);
mainTabPanel.add(tab);
activeTabPanels(false);
//activeTabPanels(false);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
mainTabPanel.selectTab(results.size() - 1);
//mainTabPanel.selectTab(results.size() - 1);
}
});
@ -141,7 +141,7 @@ public class MainTabPanel extends Composite {
selectTab(0);
}
private void selectTab(int tabIndex) {
public void selectTab(int tabIndex) {
if (tabIndex <= results.size()) {
mainTabPanel.selectTab(tabIndex);
}