IDEMPIERE-4196 Image Field: Not fully clickable on user window and doesn't maintain aspect ratio

This commit is contained in:
hengsin 2020-03-08 19:19:06 +08:00
parent 2d06047049
commit dfcb22fa5c
3 changed files with 26 additions and 2 deletions

View File

@ -25,9 +25,12 @@ import org.compiere.model.MImage;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.zkoss.image.AImage;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Cell;
import org.zkoss.zul.Image;
/**
@ -53,7 +56,21 @@ public class WImageEditor extends WEditor
public WImageEditor(GridField gridField)
{
super(new Image(), gridField);
super(new Image() {
private static final long serialVersionUID = 8492629361709791256L;
@Override
public void onPageAttached(Page newpage, Page oldpage) {
super.onPageAttached(newpage, oldpage);
if (newpage != null && getParent() != null) {
Component p = getParent();
if (p instanceof Cell) {
Cell cell = (Cell) p;
LayoutUtils.addSclass("image-field-cell", cell);
}
}
}
}, gridField);
init();
}
@ -66,7 +83,7 @@ public class WImageEditor extends WEditor
{
AImage img = null;
getComponent().setContent(img);
getComponent().setSclass("image-field");
getComponent().setSclass("image-field image-fit-contain");
}
@Override

View File

@ -205,6 +205,7 @@ public class WImageDialog extends Window implements EventListener<Event>
ZKUpdateUtil.setHflex(image, "true");
ZKUpdateUtil.setVflex(image, "true");
center.setParent(mainLayout);
image.setSclass("image-fit-contain");
center.appendChild(image);
South south = new South();

View File

@ -190,6 +190,12 @@ span.grid-combobox-editor {
cursor: default;
border: none;
}
.image-fit-contain {
object-fit: contain;
}
.z-cell.image-field-cell {
z-index: 1;
}
.html-field {
cursor: pointer;