IDEMPIERE-3518 Improvement For Mobile Compatibility. Fix calendar errors on mobile devices.
This commit is contained in:
parent
75a36ec2ac
commit
b98154670d
|
@ -28,10 +28,11 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
import java.util.TimeZone;
|
||||
|
||||
|
||||
import org.adempiere.webui.ClientInfo;
|
||||
import org.adempiere.webui.component.Tabpanel;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.panel.ITabOnCloseHandler;
|
||||
import org.adempiere.webui.part.WindowContainer;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.theme.ThemeManager;
|
||||
import org.adempiere.webui.util.ZKUpdateUtil;
|
||||
|
@ -80,6 +81,7 @@ public class CalendarWindow extends Window implements EventListener<Event>, ITab
|
|||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1576992746053720647L;
|
||||
private static final String ON_MOBILE_SET_SELECTED_TAB_ECHO = "onMobileSetSelectedTabEcho";
|
||||
|
||||
private Calendars calendars;
|
||||
private SimpleCalendarModel scm;
|
||||
|
@ -187,6 +189,11 @@ public class CalendarWindow extends Window implements EventListener<Event>, ITab
|
|||
calendars.addEventListener("onEventUpdate", this);
|
||||
calendars.addEventListener("onMouseOver", this);
|
||||
|
||||
if (ClientInfo.isMobile()) {
|
||||
addCallback(AFTER_PAGE_ATTACHED, t -> afterPageAttached());
|
||||
addEventListener(ON_MOBILE_SET_SELECTED_TAB_ECHO, evt -> calendars.invalidate());
|
||||
}
|
||||
|
||||
SessionManager.getAppDesktop().showWindow(this);
|
||||
|
||||
// IDEMPIERE-1457: when show this window on tab, handle event close to remove calendars away scm
|
||||
|
@ -196,6 +203,21 @@ public class CalendarWindow extends Window implements EventListener<Event>, ITab
|
|||
}
|
||||
}
|
||||
|
||||
private void afterPageAttached() {
|
||||
Component p = getParent();
|
||||
while (p != null) {
|
||||
if (p instanceof Tabpanel) {
|
||||
p.addEventListener(WindowContainer.ON_MOBILE_SET_SELECTED_TAB, evt -> onMobileSelected());
|
||||
break;
|
||||
}
|
||||
p = p.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
private void onMobileSelected() {
|
||||
Events.echoEvent(ON_MOBILE_SET_SELECTED_TAB_ECHO, this, null);
|
||||
}
|
||||
|
||||
public void onClose(Tabpanel tabPanel){
|
||||
//IDEMPIERE-1457: On close, remove calendars away scm
|
||||
calendars.setModel(null);
|
||||
|
|
|
@ -30,6 +30,9 @@ import org.adempiere.base.Service;
|
|||
import org.adempiere.base.event.AbstractEventHandler;
|
||||
import org.adempiere.base.event.EventManager;
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.adempiere.webui.ClientInfo;
|
||||
import org.adempiere.webui.component.Tabpanel;
|
||||
import org.adempiere.webui.part.WindowContainer;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.theme.ThemeManager;
|
||||
import org.adempiere.webui.util.ServerPushTemplate;
|
||||
|
@ -75,6 +78,7 @@ public class DPCalendar extends DashboardPanel implements EventListener<Event>,
|
|||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -224914882522997787L;
|
||||
private static final String ON_MOBILE_SET_SELECTED_TAB_ECHO = "onMobileSetSelectedTabEcho";
|
||||
private Calendars calendars;
|
||||
private SimpleCalendarModel scm;
|
||||
private LabelImageElement btnCal, btnRefresh;
|
||||
|
@ -137,6 +141,26 @@ public class DPCalendar extends DashboardPanel implements EventListener<Event>,
|
|||
DPCalendar.this.cleanup();
|
||||
}
|
||||
};
|
||||
|
||||
if (ClientInfo.isMobile()) {
|
||||
addCallback(AFTER_PAGE_ATTACHED, t -> afterPageAttached());
|
||||
addEventListener(ON_MOBILE_SET_SELECTED_TAB_ECHO, evt -> calendars.invalidate());
|
||||
}
|
||||
}
|
||||
|
||||
private void afterPageAttached() {
|
||||
Component p = getParent();
|
||||
while (p != null) {
|
||||
if (p instanceof Tabpanel) {
|
||||
p.addEventListener(WindowContainer.ON_MOBILE_SET_SELECTED_TAB, evt -> onMobileSelected());
|
||||
break;
|
||||
}
|
||||
p = p.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
private void onMobileSelected() {
|
||||
Events.echoEvent(ON_MOBILE_SET_SELECTED_TAB_ECHO, this, null);
|
||||
}
|
||||
|
||||
private synchronized void createStaticListeners() {
|
||||
|
|
|
@ -24,9 +24,12 @@ import java.util.GregorianCalendar;
|
|||
import java.util.TimeZone;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.ClientInfo;
|
||||
import org.adempiere.webui.component.Tabpanel;
|
||||
import org.adempiere.webui.component.ToolBarButton;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.component.ZkCssHelper;
|
||||
import org.adempiere.webui.part.WindowContainer;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.theme.ThemeManager;
|
||||
import org.adempiere.webui.util.ZKUpdateUtil;
|
||||
|
@ -69,6 +72,7 @@ public class WSchedule extends Window implements EventListener<Event>
|
|||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4819513326165148245L;
|
||||
private static final String ON_MOBILE_SET_SELECTED_TAB_ECHO = "onMobileSetSelectedTabEcho";
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private InfoSchedule infoSchedule;
|
||||
|
@ -204,7 +208,27 @@ public class WSchedule extends Window implements EventListener<Event>
|
|||
divTabClicked(7);
|
||||
|
||||
addEventListener("onAfterReCreate", this);
|
||||
} // jbInit
|
||||
|
||||
if (ClientInfo.isMobile()) {
|
||||
addCallback(AFTER_PAGE_ATTACHED, t -> afterPageAttached());
|
||||
addEventListener(ON_MOBILE_SET_SELECTED_TAB_ECHO, evt -> calendars.invalidate());
|
||||
}
|
||||
}
|
||||
|
||||
private void afterPageAttached() {
|
||||
Component p = getParent();
|
||||
while (p != null) {
|
||||
if (p instanceof Tabpanel) {
|
||||
p.addEventListener(WindowContainer.ON_MOBILE_SET_SELECTED_TAB, evt -> onMobileSelected());
|
||||
break;
|
||||
}
|
||||
p = p.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
private void onMobileSelected() {
|
||||
Events.echoEvent(ON_MOBILE_SET_SELECTED_TAB_ECHO, this, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recreate View
|
||||
|
|
|
@ -49,6 +49,8 @@ import org.zkoss.zul.Menuitem;
|
|||
*/
|
||||
public class WindowContainer extends AbstractUIPart implements EventListener<Event>
|
||||
{
|
||||
public static final String ON_MOBILE_SET_SELECTED_TAB = "onMobileSetSelectedTab";
|
||||
|
||||
private static final String ON_AFTER_TAB_CLOSE = "onAfterTabClose";
|
||||
|
||||
private static final String ON_DEFER_SET_SELECTED_TAB = "onDeferSetSelectedTab";
|
||||
|
@ -100,8 +102,11 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
|
|||
}
|
||||
});
|
||||
tabbox.addEventListener(ON_AFTER_TAB_CLOSE, evt -> {
|
||||
updateMobileTabState(tabbox.getSelectedTab());
|
||||
updateTabListButton();
|
||||
if (isMobile()) {
|
||||
updateMobileTabState(tabbox.getSelectedTab());
|
||||
updateTabListButton();
|
||||
tabbox.getTabs().invalidate();
|
||||
}
|
||||
});
|
||||
|
||||
Tabpanels tabpanels = new Tabpanels();
|
||||
|
@ -474,8 +479,11 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
|
|||
*/
|
||||
public void setSelectedTab(org.zkoss.zul.Tab tab)
|
||||
{
|
||||
if (isMobile())
|
||||
updateMobileTabState(tab);
|
||||
tabbox.setSelectedTab(tab);
|
||||
updateMobileTabState(tab);
|
||||
if (isMobile())
|
||||
tabbox.getTabs().invalidate();
|
||||
}
|
||||
|
||||
private void updateMobileTabState(org.zkoss.zul.Tab tab) {
|
||||
|
@ -487,9 +495,11 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
|
|||
Tab t = (Tab) c;
|
||||
t.setVisible(t == tab);
|
||||
t.getLinkedPanel().setVisible(t == tab);
|
||||
if (t.isVisible()) {
|
||||
Events.postEvent(ON_MOBILE_SET_SELECTED_TAB, t.getLinkedPanel(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
tabbox.getTabs().invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -216,6 +216,42 @@ Copyright (C) 2007 Ashley G Ramdass.
|
|||
});
|
||||
});
|
||||
|
||||
zk.afterLoad('calendar', function () {
|
||||
zk.override(calendar.Event.prototype, "calculate_", function () {
|
||||
if (typeof this.event === "undefined" || this.event == null) {
|
||||
return;
|
||||
}
|
||||
this.$calculate_.apply(this, arguments);
|
||||
});
|
||||
|
||||
zk.override(calendar.Event.prototype, "unbind_", function() {
|
||||
var node = this.$n();
|
||||
if (typeof node === "undefined") {
|
||||
return;
|
||||
}
|
||||
if (typeof this.$unbind_ === "undefined") {
|
||||
return;
|
||||
}
|
||||
this.$unbind_.apply(this, arguments);
|
||||
});
|
||||
|
||||
zk.override(calendar.CalendarsMonth.prototype, "onSize", function () {
|
||||
var cmp = this.$n();
|
||||
if (typeof cmp === "undefined" || cmp == null) {
|
||||
return;
|
||||
}
|
||||
this.$onSize.apply(this, arguments);
|
||||
});
|
||||
|
||||
zk.override(calendar.CalendarsDefault.prototype, "onSize", function () {
|
||||
var cmp = this.$n();
|
||||
if (typeof cmp === "undefined" || cmp == null) {
|
||||
return;
|
||||
}
|
||||
this.$onSize.apply(this, arguments);
|
||||
});
|
||||
});
|
||||
|
||||
]]>
|
||||
</script>
|
||||
<include src="${themePreference}"/>
|
||||
|
|
Loading…
Reference in New Issue