task_21363 #1
|
@ -0,0 +1,168 @@
|
||||||
|
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||||
|
|
||||||
|
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||||
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainPanel;
|
||||||
|
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.UtilUx;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.user.client.Command;
|
||||||
|
import com.google.gwt.user.client.ui.ComplexPanel;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class CheckConfigsUxController.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Apr 8, 2022
|
||||||
|
*/
|
||||||
|
public class CheckConfigsUxController {
|
||||||
|
|
||||||
|
private LoadingPanel loader;
|
||||||
|
|
||||||
|
private CkanContentModeratorCheckConfigs moderatorCheckConfig;
|
||||||
|
|
||||||
|
private ComplexPanel basePanelContainer;
|
||||||
|
|
||||||
|
private CkanContentModeratorWidgetController cmsController;
|
||||||
|
|
||||||
|
private MainPanel mainPanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new check configs ux controller.
|
||||||
|
*
|
||||||
|
* @param baseCP the base CP
|
||||||
|
* @param moderatorCheckConfig the moderatorcheck config
|
||||||
|
*/
|
||||||
|
protected CheckConfigsUxController(MainPanel mainPanel, CkanContentModeratorCheckConfigs moderatorcheckConfig) {
|
||||||
|
this.mainPanel = mainPanel;
|
||||||
|
this.basePanelContainer = mainPanel.getMainPanelContainer();
|
||||||
|
this.moderatorCheckConfig = moderatorcheckConfig;
|
||||||
|
checkConfigs();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check configs.
|
||||||
|
*/
|
||||||
|
private void checkConfigs() {
|
||||||
|
|
||||||
|
if (moderatorCheckConfig == null) {
|
||||||
|
// here the moderatorCheckConfig is null, so loading configurations from server
|
||||||
|
// and
|
||||||
|
// checking them
|
||||||
|
loader = new LoadingPanel(new HTML("Checking configurations and authorizations... please wait"));
|
||||||
|
basePanelContainer.add(loader);
|
||||||
|
moderatorCheckConfig = new CkanContentModeratorCheckConfigs();
|
||||||
|
|
||||||
|
final Command whenDone = new Command() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
onConfigurationsLoaded();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
moderatorCheckConfig.checkConfigs(whenDone, false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
GWT.log("Check configs error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// here the moderatorCheckConfig is already full
|
||||||
|
onConfigurationsLoaded();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On configurations loaded.
|
||||||
|
*/
|
||||||
|
private void onConfigurationsLoaded() {
|
||||||
|
GWT.log("onConfigurationLoaded executed");
|
||||||
|
boolean isContentModerationEnabled = false;
|
||||||
|
boolean isModeratorRoleAssingned = false;
|
||||||
|
boolean isExistsMyItemInModeration = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
isContentModerationEnabled = moderatorCheckConfig.isContentModerationEnabled();
|
||||||
|
} catch (Exception e) {
|
||||||
|
GWT.log("Command - Check configs error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
isModeratorRoleAssingned = moderatorCheckConfig.isModeratorRoleAssigned();
|
||||||
|
} catch (Exception e) {
|
||||||
|
GWT.log("Command - Check configs error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
isExistsMyItemInModeration = moderatorCheckConfig.isExistsMyItemInModeration();
|
||||||
|
} catch (Exception e) {
|
||||||
|
GWT.log("Command - Check configs error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
GWT.log("Moderation is enabled? " + isContentModerationEnabled);
|
||||||
|
GWT.log("Moderator role is assigned? " + isModeratorRoleAssingned);
|
||||||
|
GWT.log("isExistsMyItemInModeration? " + isExistsMyItemInModeration);
|
||||||
|
|
||||||
|
if (!isContentModerationEnabled) {
|
||||||
|
try {
|
||||||
|
basePanelContainer.remove(loader);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
UtilUx.showAlert("The Moderation facility is not enabled in this context", AlertType.WARNING, false,
|
||||||
|
basePanelContainer, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// moderator logged in
|
||||||
|
if (isModeratorRoleAssingned) {
|
||||||
|
try {
|
||||||
|
basePanelContainer.remove(loader);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
cmsController = new CkanContentModeratorWidgetController(ItemStatus.PENDING, DISPLAY_FIELD.values(),
|
||||||
|
DISPLAY_FIELD.NAME, false, false);
|
||||||
|
basePanelContainer.add(cmsController.getMainPanel());
|
||||||
|
|
||||||
|
mainPanel.setLoggedLabelText("Logged in as Moderator");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// no item under moderation or already moderated
|
||||||
|
if (!isExistsMyItemInModeration) {
|
||||||
|
try {
|
||||||
|
basePanelContainer.remove(loader);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
UtilUx.showAlert("You are not authorized to access to Moderation facility", AlertType.WARNING, false,
|
||||||
|
basePanelContainer, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
basePanelContainer.remove(loader);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// read only mode enabled in case of moderator role not assigned
|
||||||
|
boolean readOnlyMode = !isModeratorRoleAssingned;
|
||||||
|
// Listing only data belonging to user logged in. He/She must be the owner of.
|
||||||
|
boolean restrictDataToLoggedInUser = readOnlyMode;
|
||||||
|
|
||||||
|
GWT.log("readOnlyMode is enabled? " + readOnlyMode);
|
||||||
|
GWT.log("restrictDataToLoggedInUser is? " + restrictDataToLoggedInUser);
|
||||||
|
|
||||||
|
cmsController = new CkanContentModeratorWidgetController(ItemStatus.PENDING, DISPLAY_FIELD.values(),
|
||||||
|
DISPLAY_FIELD.NAME, readOnlyMode, restrictDataToLoggedInUser);
|
||||||
|
|
||||||
|
basePanelContainer.add(cmsController.getMainPanel());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CkanContentModeratorCheckConfigs getModeratorCheckConfig() {
|
||||||
|
return moderatorCheckConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,13 +6,13 @@ import com.google.gwt.user.client.Timer;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CkanContentModeratorCheckConfig.
|
* The Class CkanContentModeratorCheckConfigs.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
*
|
*
|
||||||
* Feb 22, 2022
|
* Apr 8, 2022
|
||||||
*/
|
*/
|
||||||
public class CkanContentModeratorCheckConfig {
|
public class CkanContentModeratorCheckConfigs {
|
||||||
|
|
||||||
private int configurationLoaded = 0;
|
private int configurationLoaded = 0;
|
||||||
private static final int CONFIGURATION_EXPECTED = 3;
|
private static final int CONFIGURATION_EXPECTED = 3;
|
||||||
|
@ -25,7 +25,7 @@ public class CkanContentModeratorCheckConfig {
|
||||||
/**
|
/**
|
||||||
* Instantiates a new ckan content moderator check config.
|
* Instantiates a new ckan content moderator check config.
|
||||||
*/
|
*/
|
||||||
public CkanContentModeratorCheckConfig() {
|
public CkanContentModeratorCheckConfigs() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +1,58 @@
|
||||||
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||||
|
|
||||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainPanel;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.ExtModal;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.github.gwtbootstrap.client.ui.Modal;
|
||||||
import com.google.gwt.user.client.ui.ComplexPanel;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CkanContentModeratorWidget.
|
* The Class CkanContentModeratorWidget.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
*
|
*
|
||||||
* Jun 15, 2021
|
* Apr 7, 2022
|
||||||
*/
|
*/
|
||||||
public class CkanContentModeratorWidget {
|
public class CkanContentModeratorWidget {
|
||||||
|
|
||||||
private CkanContentModeratorWidgetController cmsController;
|
// private VerticalPanel baseVP = new VerticalPanel();
|
||||||
|
|
||||||
|
private MainPanel mainPanel = new MainPanel();
|
||||||
|
|
||||||
|
private CheckConfigsUxController ccux;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new ckan content moderator widget.
|
* Instantiates a new ckan content moderator widget.
|
||||||
*
|
|
||||||
* @param status the status
|
|
||||||
* @param displayFields the display fields
|
|
||||||
* @param sortByField the sort by field
|
|
||||||
* @param readOnlyMode the read only mode is true if the Moderator Role is not assigned
|
|
||||||
* @param restrictDataToLoggedInUser the restrict data to logged in user
|
|
||||||
*/
|
*/
|
||||||
public CkanContentModeratorWidget(ItemStatus status, DISPLAY_FIELD[] displayFields, DISPLAY_FIELD sortByField, boolean readOnlyMode, boolean restrictDataToLoggedInUser) {
|
public CkanContentModeratorWidget() {
|
||||||
GWT.log("CkanContentModeratorWidget called. ReadOnlyMode: "+readOnlyMode);
|
mainPanel.setWidth("100%");
|
||||||
cmsController = new CkanContentModeratorWidgetController(status, displayFields, sortByField, readOnlyMode, restrictDataToLoggedInUser);
|
ccux = new CheckConfigsUxController(mainPanel, null);
|
||||||
|
|
||||||
|
boolean iamModerator = false;
|
||||||
|
try {
|
||||||
|
iamModerator = ccux.getModeratorCheckConfig().isModeratorRoleAssigned();
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iamModerator) {
|
||||||
|
mainPanel.setLoggedLabelText("Logged in as Moderator");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show as modal.
|
||||||
|
*/
|
||||||
|
public void showAsModal(String modalTitle) {
|
||||||
|
final Modal modal = new ExtModal(true, true);
|
||||||
|
modalTitle = modalTitle == null || modalTitle.isEmpty() ? "Manage Items" : modalTitle;
|
||||||
|
modal.setTitle(modalTitle);
|
||||||
|
modal.setWidth(1200);
|
||||||
|
modal.getElement().addClassName("modal-content-moderator");
|
||||||
|
// modal.getElement().getStyle().setProperty("min-height", "500px");
|
||||||
|
modal.add(mainPanel);
|
||||||
|
modal.setCloseVisible(true);
|
||||||
|
modal.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,8 +60,11 @@ public class CkanContentModeratorWidget {
|
||||||
*
|
*
|
||||||
* @return the panel
|
* @return the panel
|
||||||
*/
|
*/
|
||||||
public ComplexPanel getPanel() {
|
public Composite getPanel() {
|
||||||
return cmsController.getMainPanel();
|
return mainPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CkanContentModeratorCheckConfigs getCongifs() {
|
||||||
|
return ccux.getModeratorCheckConfig();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,11 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModerato
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.HomeView;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.HomeView;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainTabPanel;
|
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.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
||||||
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.UtilUx;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
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.core.client.GWT;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
import com.google.gwt.user.client.Timer;
|
|
||||||
import com.google.gwt.user.client.ui.ComplexPanel;
|
import com.google.gwt.user.client.ui.ComplexPanel;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
|
|
||||||
|
@ -64,30 +62,27 @@ public class CkanContentModeratorWidgetController {
|
||||||
/**
|
/**
|
||||||
* Instantiates a new ckan content moderator widget.
|
* Instantiates a new ckan content moderator widget.
|
||||||
*
|
*
|
||||||
* @param status the status
|
* @param status the status
|
||||||
* @param displayFields the display fields
|
* @param displayFields the display fields
|
||||||
* @param sortByField the sort by field
|
* @param sortByField the sort by field
|
||||||
* @param readOnlyMode the read only mode
|
* @param readOnlyMode the read only mode
|
||||||
* @param restrictDataToLoggedInUser
|
* @param restrictDataToLoggedInUser
|
||||||
*/
|
*/
|
||||||
public CkanContentModeratorWidgetController(ItemStatus status, DISPLAY_FIELD[] displayFields,
|
protected CkanContentModeratorWidgetController(ItemStatus status, DISPLAY_FIELD[] displayFields,
|
||||||
DISPLAY_FIELD sortByField, boolean readOnlyMode, boolean restrictDataToLoggedInUser) {
|
DISPLAY_FIELD sortByField, boolean readOnlyMode, boolean restrictDataToLoggedInUser) {
|
||||||
toolbar = new ContentModeratorToolbar(eventBus, status);
|
toolbar = new ContentModeratorToolbar(eventBus, status);
|
||||||
|
|
||||||
// GWT.log("***************** HARD CODED READONLY ********************** ");
|
// GWT.log("***************** HARD CODED READONLY ********************** ");
|
||||||
// readOnlyMode = true;
|
// readOnlyMode = true;
|
||||||
// restrictDataToLoggedInUser = readOnlyMode;
|
// restrictDataToLoggedInUser = readOnlyMode;
|
||||||
|
|
||||||
howeView = new HomeView(eventBus, status, displayFields, sortByField, readOnlyMode, restrictDataToLoggedInUser);
|
howeView = new HomeView(eventBus, status, displayFields, sortByField, readOnlyMode, restrictDataToLoggedInUser);
|
||||||
mainTabPanel.addHomeWidget(howeView.getPanel());
|
mainTabPanel.addHomeWidget(howeView.getPanel());
|
||||||
mainPanel.add(toolbar);
|
mainPanel.add(toolbar);
|
||||||
mainPanel.add(infoPanel);
|
mainPanel.add(infoPanel);
|
||||||
mainPanel.add(mainTabPanel);
|
mainPanel.add(mainTabPanel);
|
||||||
this.readOnlyMode = readOnlyMode;
|
this.readOnlyMode = readOnlyMode;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
howeView.hideUpdateStatusAction(readOnlyMode);
|
howeView.hideUpdateStatusAction(readOnlyMode);
|
||||||
howeView.hideSelectableRow(readOnlyMode);
|
howeView.hideSelectableRow(readOnlyMode);
|
||||||
bindEvents();
|
bindEvents();
|
||||||
|
@ -200,7 +195,8 @@ public class CkanContentModeratorWidgetController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statusSelectedEvent.getDisplayMessage() != null) {
|
if (statusSelectedEvent.getDisplayMessage() != null) {
|
||||||
showMessage(statusSelectedEvent.getDisplayMessage(), statusSelectedEvent.getAlertType());
|
UtilUx.showAlert(statusSelectedEvent.getDisplayMessage(), statusSelectedEvent.getAlertType(), true,
|
||||||
|
infoPanel, 15000);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -212,7 +208,7 @@ public class CkanContentModeratorWidgetController {
|
||||||
public void onShowMessage(ShowMessageEvent showMessageEvent) {
|
public void onShowMessage(ShowMessageEvent showMessageEvent) {
|
||||||
|
|
||||||
if (showMessageEvent.getMsg() != null) {
|
if (showMessageEvent.getMsg() != null) {
|
||||||
showMessage(showMessageEvent.getMsg(), showMessageEvent.getAlerType());
|
UtilUx.showAlert(showMessageEvent.getMsg(), showMessageEvent.getAlerType(), true, infoPanel, 15000);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,33 +226,6 @@ public class CkanContentModeratorWidgetController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Show message.
|
|
||||||
*
|
|
||||||
* @param msg the msg
|
|
||||||
* @param alertType the alert type
|
|
||||||
*/
|
|
||||||
private void showMessage(String msg, AlertType alertType) {
|
|
||||||
|
|
||||||
final Alert alert = new Alert(msg);
|
|
||||||
alertType = alertType != null ? alertType : AlertType.INFO;
|
|
||||||
alert.setType(alertType);
|
|
||||||
alert.setClose(true);
|
|
||||||
alert.setAnimation(true);
|
|
||||||
infoPanel.add(alert);
|
|
||||||
|
|
||||||
// Cleans the info panel after 12 sec.
|
|
||||||
Timer t = new Timer() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
infoPanel.clear();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
t.schedule(15000);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the main panel.
|
* Gets the main panel.
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||||
|
|
||||||
|
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||||
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainPanel;
|
||||||
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
||||||
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.ExtModal;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Modal;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class CkanContentModeratorWidget.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Jun 15, 2021
|
||||||
|
*/
|
||||||
|
public class CkanContentModeratorWidgetTrusted {
|
||||||
|
|
||||||
|
private MainPanel mainPanel = new MainPanel();
|
||||||
|
|
||||||
|
private CheckConfigsUxController ccux;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new ckan content moderator widget trusted.
|
||||||
|
*
|
||||||
|
* @param status the status
|
||||||
|
* @param displayFields the display fields
|
||||||
|
* @param sortByField the sort by field
|
||||||
|
* @param ckanContentModeratorCheckConfig the ckan content moderator check
|
||||||
|
* config
|
||||||
|
*/
|
||||||
|
public CkanContentModeratorWidgetTrusted(ItemStatus status, DISPLAY_FIELD[] displayFields,
|
||||||
|
DISPLAY_FIELD sortByField, CkanContentModeratorCheckConfigs ckanContentModeratorCheckConfig) {
|
||||||
|
GWT.log("CkanContentModeratorWidget called. CkanContentModeratorCheckConfigs: "
|
||||||
|
+ ckanContentModeratorCheckConfig);
|
||||||
|
mainPanel.setWidth("100%");
|
||||||
|
ccux = new CheckConfigsUxController(mainPanel, ckanContentModeratorCheckConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show as modal.
|
||||||
|
*
|
||||||
|
* @param modalTitle the modal title
|
||||||
|
*/
|
||||||
|
public void showAsModal(String modalTitle) {
|
||||||
|
final Modal modal = new ExtModal(true, true);
|
||||||
|
modalTitle = modalTitle == null || modalTitle.isEmpty() ? "Manage Items" : modalTitle;
|
||||||
|
modal.setTitle(modalTitle);
|
||||||
|
modal.setWidth(1200);
|
||||||
|
modal.getElement().addClassName("modal-content-moderator");
|
||||||
|
// modal.getElement().getStyle().setProperty("min-height", "500px");
|
||||||
|
modal.add(mainPanel);
|
||||||
|
modal.setCloseVisible(true);
|
||||||
|
modal.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the panel.
|
||||||
|
*
|
||||||
|
* @return the panel
|
||||||
|
*/
|
||||||
|
public Composite getPanel() {
|
||||||
|
return mainPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the configs.
|
||||||
|
*
|
||||||
|
* @return the configs
|
||||||
|
*/
|
||||||
|
public CkanContentModeratorCheckConfigs getConfigs() {
|
||||||
|
return ccux.getModeratorCheckConfig();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
|
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||||
|
@ -60,10 +61,10 @@ public class ContentModeratorPaginatedView {
|
||||||
/**
|
/**
|
||||||
* Instantiates a new content moderator paginated view.
|
* Instantiates a new content moderator paginated view.
|
||||||
*
|
*
|
||||||
* @param eventbus the eventbus
|
* @param eventbus the eventbus
|
||||||
* @param theStatus the the status
|
* @param theStatus the the status
|
||||||
* @param displayFields the display fields
|
* @param displayFields the display fields
|
||||||
* @param sortByField the sort by field
|
* @param sortByField the sort by field
|
||||||
* @param restrictDataToLoggedInUser the restrict data to logged in user
|
* @param restrictDataToLoggedInUser the restrict data to logged in user
|
||||||
*/
|
*/
|
||||||
public ContentModeratorPaginatedView(HandlerManager eventbus, ItemStatus theStatus, DISPLAY_FIELD[] displayFields,
|
public ContentModeratorPaginatedView(HandlerManager eventbus, ItemStatus theStatus, DISPLAY_FIELD[] displayFields,
|
||||||
|
@ -208,6 +209,20 @@ public class ContentModeratorPaginatedView {
|
||||||
getAsycnDataProvider().updateRowCount((int) result.getTotalItems(), true);
|
getAsycnDataProvider().updateRowCount((int) result.getTotalItems(), true);
|
||||||
getAsycnDataProvider().updateRowData(result.getClientStartIndex(), result.getData());
|
getAsycnDataProvider().updateRowData(result.getClientStartIndex(), result.getData());
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MOCK-UP int total = 35; List<CatalogueDataset> listData = new
|
||||||
|
* ArrayList<CatalogueDataset>(35); for (int i = 0; i < total; i++) {
|
||||||
|
* CatalogueDataset cd = new CatalogueDataset(); cd.setId(i+"");
|
||||||
|
* cd.setName("name "+i);
|
||||||
|
*
|
||||||
|
* listData.add(cd);
|
||||||
|
*
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* getAsycnDataProvider().updateRowCount(total, true);
|
||||||
|
* getAsycnDataProvider().updateRowData(result.getClientStartIndex(), listData);
|
||||||
|
*/
|
||||||
|
|
||||||
if (result.getData().size() == 0) {
|
if (result.getData().size() == 0) {
|
||||||
getCellTable().setLoadingIndicator(new Label("No data"));
|
getCellTable().setLoadingIndicator(new Label("No data"));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Label;
|
||||||
|
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.HTMLPanel;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
public class MainPanel extends Composite {
|
||||||
|
|
||||||
|
private static MainPanelUiBinder uiBinder = GWT.create(MainPanelUiBinder.class);
|
||||||
|
|
||||||
|
interface MainPanelUiBinder extends UiBinder<Widget, MainPanel> {
|
||||||
|
}
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
HTMLPanel mainPanel;
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
HTMLPanel mainPanelContainer;
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
Label labelLoggedIn;
|
||||||
|
|
||||||
|
public MainPanel() {
|
||||||
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoggedLabelText(String text){
|
||||||
|
labelLoggedIn.setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HTMLPanel getMainPanelContainer() {
|
||||||
|
return mainPanelContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<!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;
|
||||||
|
}
|
||||||
|
|
||||||
|
.margin-bottom-2 {
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
</ui:style>
|
||||||
|
<g:HTMLPanel ui:field="mainPanel">
|
||||||
|
<b:Label ui:field="labelLoggedIn"
|
||||||
|
addStyleNames="{style.margin-bottom-2}"></b:Label>
|
||||||
|
<g:HTMLPanel ui:field="mainPanelContainer"></g:HTMLPanel>
|
||||||
|
</g:HTMLPanel>
|
||||||
|
</ui:UiBinder>
|
|
@ -0,0 +1,133 @@
|
||||||
|
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Modal;
|
||||||
|
import com.github.gwtbootstrap.client.ui.event.HideEvent;
|
||||||
|
import com.github.gwtbootstrap.client.ui.event.HideHandler;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.core.client.Scheduler;
|
||||||
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||||
|
import com.google.gwt.dom.client.Element;
|
||||||
|
import com.google.gwt.user.client.DOM;
|
||||||
|
import com.google.gwt.user.client.Event;
|
||||||
|
import com.google.gwt.user.client.EventListener;
|
||||||
|
import com.google.gwt.user.client.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class ExtModal.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Apr 29, 2021
|
||||||
|
*
|
||||||
|
* This Class extends the {{@link Modal} preventing the default close of
|
||||||
|
* the Modal Bootstrap when clicking outside of the modal Window
|
||||||
|
*/
|
||||||
|
public class ExtModal extends Modal {
|
||||||
|
|
||||||
|
private String elementId;
|
||||||
|
private String closeElementId;
|
||||||
|
private Boolean closeButtoClicked = false;
|
||||||
|
final private ExtModal INSTANCE = this;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new ext modal.
|
||||||
|
*/
|
||||||
|
public ExtModal() {
|
||||||
|
super();
|
||||||
|
setElementIds();
|
||||||
|
addDeferredCommandToPreventModalClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an empty, hidden widget with specified show behavior.
|
||||||
|
*
|
||||||
|
* @param animated <code>true</code> if the widget should be animated.
|
||||||
|
*/
|
||||||
|
public ExtModal(boolean animated) {
|
||||||
|
super(animated, false);
|
||||||
|
setElementIds();
|
||||||
|
addDeferredCommandToPreventModalClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an empty, hidden widget with specified show behavior.
|
||||||
|
*
|
||||||
|
* @param animated <code>true</code> if the widget should be animated.
|
||||||
|
* @param dynamicSafe <code>true</code> removes from RootPanel when hidden
|
||||||
|
*/
|
||||||
|
public ExtModal(boolean animated, boolean dynamicSafe) {
|
||||||
|
super(animated, dynamicSafe);
|
||||||
|
setElementIds();
|
||||||
|
addDeferredCommandToPreventModalClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDeferredCommandToPreventModalClose() {
|
||||||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
((Element) INSTANCE.getElement().getChildNodes().getItem(0)).getFirstChildElement()
|
||||||
|
.setId(closeElementId);
|
||||||
|
preventModalCloseWhenClickingOutside();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the element id.
|
||||||
|
*/
|
||||||
|
private void setElementIds() {
|
||||||
|
this.elementId = "my-modal-publish-meta" + Random.nextInt();
|
||||||
|
this.getElement().setId(elementId);
|
||||||
|
|
||||||
|
this.closeElementId = "my-modal-close-button" + Random.nextInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevent modal close when clicking outside.
|
||||||
|
*/
|
||||||
|
private void preventModalCloseWhenClickingOutside() {
|
||||||
|
|
||||||
|
com.google.gwt.user.client.Element buttonCloseElement = DOM.getElementById(this.closeElementId);
|
||||||
|
|
||||||
|
if (buttonCloseElement != null) {
|
||||||
|
|
||||||
|
Event.sinkEvents(buttonCloseElement, Event.ONCLICK);
|
||||||
|
Event.setEventListener(buttonCloseElement, new EventListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBrowserEvent(Event event) {
|
||||||
|
System.out.println("ok");
|
||||||
|
if (Event.ONCLICK == event.getTypeInt()) {
|
||||||
|
GWT.log("close event clicked");
|
||||||
|
closeButtoClicked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
GWT.log("button close element not found");
|
||||||
|
closeButtoClicked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// hide any popup panel opened
|
||||||
|
this.addHideHandler(new HideHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHide(HideEvent hideEvent) {
|
||||||
|
GWT.log("HideEvent on modal fired");
|
||||||
|
GWT.log(hideEvent.toDebugString());
|
||||||
|
GWT.log("CloseButtonClicked is: " + closeButtoClicked);
|
||||||
|
|
||||||
|
if (!closeButtoClicked) {
|
||||||
|
hideEvent.preventDefault();
|
||||||
|
hideEvent.stopPropagation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Alert;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
|
import com.google.gwt.user.client.Timer;
|
||||||
|
import com.google.gwt.user.client.ui.Panel;
|
||||||
|
|
||||||
|
public class UtilUx {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show message.
|
||||||
|
*
|
||||||
|
* @param msg the msg
|
||||||
|
* @param alertType the alert type
|
||||||
|
* @param closable the closable
|
||||||
|
* @param addToPanel the add to panel
|
||||||
|
* @param scheduleTimerMls the schedule timer mls
|
||||||
|
*/
|
||||||
|
public static void showAlert(String msg, AlertType alertType, boolean closable, final Panel addToPanel, final Integer scheduleTimerMls) {
|
||||||
|
|
||||||
|
final Alert alert = new Alert(msg);
|
||||||
|
alertType = alertType != null ? alertType : AlertType.INFO;
|
||||||
|
alert.setType(alertType);
|
||||||
|
alert.setClose(closable);
|
||||||
|
alert.setAnimation(true);
|
||||||
|
addToPanel.add(alert);
|
||||||
|
|
||||||
|
if (scheduleTimerMls != null) {
|
||||||
|
|
||||||
|
// Cleans the info panel after 12 sec.
|
||||||
|
Timer t = new Timer() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
addToPanel.clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
t.schedule(scheduleTimerMls);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue