IDEMPIERE-5238 - Support of Search display type for AD_Table_ID (#1726)
* IDEMPIERE-5238 - Support of Search display type for AD_Table_ID * IDEMPIERE-5238 - no key column error * IDEMPIERE-5238 - fix css * IDEMPIERE-5238 - move scripts to iD10 * IDEMPIERE-5238 - bug fixes - dialog did not open if AD_Table_ID = 0 - NPE if closing dialog with OK button and AD_Table_ID = 0 * IDEMPIERE-5238 - fix multiple tableID > 0 checks
This commit is contained in:
parent
9c2dc06dcc
commit
21e4f610eb
|
@ -0,0 +1,10 @@
|
||||||
|
-- IDEMPIERE-5238
|
||||||
|
SELECT register_migration_script('202303141224_IDEMPIERE-5238.sql') FROM dual;
|
||||||
|
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- Mar 14, 2023, 12:24:54 PM CET
|
||||||
|
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','This Table has no Key Column',0,0,'Y',TO_TIMESTAMP('2023-03-14 12:24:53','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-03-14 12:24:53','YYYY-MM-DD HH24:MI:SS'),100,200826,'TableHasNoKeyColumn','D','f157fa43-7351-43fe-beae-3870f0d76363')
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- IDEMPIERE-5238
|
||||||
|
SELECT register_migration_script('202303141224_IDEMPIERE-5238.sql') FROM dual;
|
||||||
|
|
||||||
|
-- Mar 14, 2023, 12:24:54 PM CET
|
||||||
|
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','This Table has no Key Column',0,0,'Y',TO_TIMESTAMP('2023-03-14 12:24:53','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-03-14 12:24:53','YYYY-MM-DD HH24:MI:SS'),100,200826,'TableHasNoKeyColumn','D','f157fa43-7351-43fe-beae-3870f0d76363')
|
||||||
|
;
|
||||||
|
|
|
@ -356,7 +356,7 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo
|
||||||
/**
|
/**
|
||||||
* Get Lookup
|
* Get Lookup
|
||||||
* @param tableID
|
* @param tableID
|
||||||
* @return {@link MLookup}
|
* @return null if tableID <= 0 or the table doesn't have any key column, else {@link MLookup}
|
||||||
*/
|
*/
|
||||||
public MLookup getRecordsLookup(int tableID) {
|
public MLookup getRecordsLookup(int tableID) {
|
||||||
if(tableID <= 0)
|
if(tableID <= 0)
|
||||||
|
@ -366,6 +366,8 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo
|
||||||
String keyColumn = "";
|
String keyColumn = "";
|
||||||
if(keyColumns.length > 0)
|
if(keyColumns.length > 0)
|
||||||
keyColumn = keyColumns[0];
|
keyColumn = keyColumns[0];
|
||||||
|
else
|
||||||
|
return null;
|
||||||
MColumn mColumn = MColumn.get(Env.getCtx(), mTable.getTableName(), keyColumn);
|
MColumn mColumn = MColumn.get(Env.getCtx(), mTable.getTableName(), keyColumn);
|
||||||
|
|
||||||
int tabNo = gridTab != null ? gridTab.getTabNo() : FindWindow.TABNO;
|
int tabNo = gridTab != null ? gridTab.getTabNo() : FindWindow.TABNO;
|
||||||
|
@ -382,7 +384,7 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo
|
||||||
*/
|
*/
|
||||||
public String getIdentifier(int tableID, int recordID) {
|
public String getIdentifier(int tableID, int recordID) {
|
||||||
MLookup lookup = getRecordsLookup(tableID);
|
MLookup lookup = getRecordsLookup(tableID);
|
||||||
return lookup != null ? lookup.getDisplay(recordID) : null;
|
return lookup != null ? lookup.getDisplay(recordID) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,15 +30,22 @@ import org.adempiere.webui.component.Button;
|
||||||
import org.adempiere.webui.component.ConfirmPanel;
|
import org.adempiere.webui.component.ConfirmPanel;
|
||||||
import org.adempiere.webui.component.Textbox;
|
import org.adempiere.webui.component.Textbox;
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.webui.component.Window;
|
||||||
|
import org.adempiere.webui.editor.WEditor;
|
||||||
import org.adempiere.webui.editor.WRecordIDEditor;
|
import org.adempiere.webui.editor.WRecordIDEditor;
|
||||||
import org.adempiere.webui.editor.WSearchEditor;
|
import org.adempiere.webui.editor.WSearchEditor;
|
||||||
import org.adempiere.webui.editor.WTableDirEditor;
|
import org.adempiere.webui.editor.WTableDirEditor;
|
||||||
|
import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
|
import org.adempiere.webui.event.ValueChangeListener;
|
||||||
import org.adempiere.webui.factory.ButtonFactory;
|
import org.adempiere.webui.factory.ButtonFactory;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
|
import org.compiere.model.MLookup;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.zkoss.zhtml.Text;
|
import org.zkoss.zhtml.Text;
|
||||||
|
import org.zkoss.zk.ui.HtmlBasedComponent;
|
||||||
import org.zkoss.zk.ui.Page;
|
import org.zkoss.zk.ui.Page;
|
||||||
|
import org.zkoss.zk.ui.WrongValueException;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
@ -50,7 +57,7 @@ import org.zkoss.zul.Vlayout;
|
||||||
* @author Peter Takacs, Cloudempiere
|
* @author Peter Takacs, Cloudempiere
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class WRecordIDDialog extends Window implements EventListener<Event> {
|
public class WRecordIDDialog extends Window implements EventListener<Event>, ValueChangeListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generated serial id
|
* generated serial id
|
||||||
|
@ -71,7 +78,7 @@ public class WRecordIDDialog extends Window implements EventListener<Event> {
|
||||||
private Div labelsDiv;
|
private Div labelsDiv;
|
||||||
private Div fieldsDiv;
|
private Div fieldsDiv;
|
||||||
private Div confirmPanelDiv;
|
private Div confirmPanelDiv;
|
||||||
private WTableDirEditor tableIDEditor;
|
private WEditor tableIDEditor;
|
||||||
private Button okBtn;
|
private Button okBtn;
|
||||||
private Button cancelBtn;
|
private Button cancelBtn;
|
||||||
private Textbox parentTextBox;
|
private Textbox parentTextBox;
|
||||||
|
@ -117,11 +124,21 @@ public class WRecordIDDialog extends Window implements EventListener<Event> {
|
||||||
contentDiv = new Div();
|
contentDiv = new Div();
|
||||||
confirmPanelDiv = new Div();
|
confirmPanelDiv = new Div();
|
||||||
okBtn = ButtonFactory.createNamedButton(ConfirmPanel.A_OK, true, true);
|
okBtn = ButtonFactory.createNamedButton(ConfirmPanel.A_OK, true, true);
|
||||||
cancelBtn = ButtonFactory.createNamedButton(ConfirmPanel.A_CANCEL, true, true);;
|
cancelBtn = ButtonFactory.createNamedButton(ConfirmPanel.A_CANCEL, true, true);
|
||||||
|
|
||||||
|
if(DisplayType.Search == tableIDGridField.getDisplayType()) {
|
||||||
|
tableIDEditor = new WSearchEditor("AD_Table_ID", false, false, true, tableIDGridField.getLookup());
|
||||||
|
}
|
||||||
|
else {
|
||||||
tableIDEditor = new WTableDirEditor("AD_Table_ID", false, false, true, tableIDGridField.getLookup(), true);
|
tableIDEditor = new WTableDirEditor("AD_Table_ID", false, false, true, tableIDGridField.getLookup(), true);
|
||||||
|
}
|
||||||
|
tableIDEditor.addValueChangeListener(this);
|
||||||
tableIDEditor.setValue(tableIDValue);
|
tableIDEditor.setValue(tableIDValue);
|
||||||
|
|
||||||
int tableID = tableIDValue != null ? tableIDValue.intValue() : 0;
|
int tableID = tableIDValue != null ? tableIDValue.intValue() : 0;
|
||||||
recordsEditor = tableID > 0 ? new WSearchEditor("Record_ID", false, false, true, editor.getRecordsLookup(tableID)) : null;
|
MLookup recordsLookup = editor.getRecordsLookup(tableID);
|
||||||
|
if(recordsLookup != null)
|
||||||
|
recordsEditor = new WSearchEditor("Record_ID", false, false, true, recordsLookup);
|
||||||
|
|
||||||
setPage(page);
|
setPage(page);
|
||||||
setClosable(true);
|
setClosable(true);
|
||||||
|
@ -139,8 +156,6 @@ public class WRecordIDDialog extends Window implements EventListener<Event> {
|
||||||
editor.getGridField().getGridTab().getAD_Table_ID(), editor.getGridField().getGridTab().getRecord_ID()));
|
editor.getGridField().getGridTab().getAD_Table_ID(), editor.getGridField().getGridTab().getRecord_ID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
tableIDEditor.getComponent().addEventListener(Events.ON_SELECT, this);
|
|
||||||
|
|
||||||
if (recordsEditor != null)
|
if (recordsEditor != null)
|
||||||
recordsEditor.setValue(recordIDValue);
|
recordsEditor.setValue(recordIDValue);
|
||||||
|
|
||||||
|
@ -180,7 +195,8 @@ public class WRecordIDDialog extends Window implements EventListener<Event> {
|
||||||
appendChild(vLayout);
|
appendChild(vLayout);
|
||||||
doHighlighted();
|
doHighlighted();
|
||||||
|
|
||||||
tableIDEditor.getComponent().focus();
|
if(tableIDEditor.getComponent() instanceof HtmlBasedComponent)
|
||||||
|
((HtmlBasedComponent) tableIDEditor.getComponent()).focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -189,6 +205,7 @@ public class WRecordIDDialog extends Window implements EventListener<Event> {
|
||||||
if(event.getTarget().equals(okBtn)) {
|
if(event.getTarget().equals(okBtn)) {
|
||||||
// set the selected values to the editors
|
// set the selected values to the editors
|
||||||
editor.setAD_Table_ID(tableIDEditor.getValue());
|
editor.setAD_Table_ID(tableIDEditor.getValue());
|
||||||
|
if(recordsEditor != null)
|
||||||
editor.setValue(recordsEditor.getValue());
|
editor.setValue(recordsEditor.getValue());
|
||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
|
@ -197,23 +214,31 @@ public class WRecordIDDialog extends Window implements EventListener<Event> {
|
||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(event.getName().equalsIgnoreCase(Events.ON_SELECT)) {
|
}
|
||||||
if (event.getTarget().equals(tableIDEditor.getComponent())) {
|
|
||||||
|
@Override
|
||||||
|
public void valueChange(ValueChangeEvent evt) {
|
||||||
|
if (evt.getSource().equals(tableIDEditor)) {
|
||||||
// the Record_ID should be cleared when a different AD_Table_ID is selected
|
// the Record_ID should be cleared when a different AD_Table_ID is selected
|
||||||
if (recordsEditor != null) {
|
if (recordsEditor != null) {
|
||||||
recordsEditor.setValue(null);
|
recordsEditor.setValue(null);
|
||||||
recordsEditorLabel.detach();
|
recordsEditorLabel.detach();
|
||||||
recordsEditor.getComponent().detach();
|
recordsEditor.getComponent().detach();
|
||||||
}
|
}
|
||||||
int tableID = Integer.parseInt(Objects.toString(tableIDEditor.getValue(), "-1"));
|
int tableID = Integer.parseInt(Objects.toString(evt.getNewValue(), "-1"));
|
||||||
if(tableID > 0) {
|
|
||||||
recordsEditor = new WSearchEditor("Record_ID", false, false, true, editor.getRecordsLookup(tableID));
|
MLookup recordsLookup = editor.getRecordsLookup(tableID);
|
||||||
|
if(recordsLookup != null) {
|
||||||
|
recordsEditor = new WSearchEditor("Record_ID", false, false, true, recordsLookup);
|
||||||
labelsDiv.appendChild(recordsEditorLabel);
|
labelsDiv.appendChild(recordsEditorLabel);
|
||||||
fieldsDiv.appendChild(recordsEditor.getComponent());
|
fieldsDiv.appendChild(recordsEditor.getComponent());
|
||||||
recordsEditor.getComponent().focus();
|
recordsEditor.getComponent().focus();
|
||||||
} else {
|
}
|
||||||
tableIDEditor.getComponent().focus();
|
else if(tableID > 0) {
|
||||||
}
|
throw new WrongValueException(tableIDEditor.getComponent(), Msg.getMsg(Env.getCtx(), "TableHasNoKeyColumn"));
|
||||||
|
}
|
||||||
|
else if(tableIDEditor.getComponent() instanceof HtmlBasedComponent) {
|
||||||
|
((HtmlBasedComponent) tableIDEditor.getComponent()).focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ input[type="checkbox"]:focus
|
||||||
height: 24px;
|
height: 24px;
|
||||||
min-height: 24px;
|
min-height: 24px;
|
||||||
right: 0px;
|
right: 0px;
|
||||||
top: 3px;
|
top: 1px;
|
||||||
border: 1px solid #CFCFCF;
|
border: 1px solid #CFCFCF;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue