IDEMPIERE-2836 SQL Searches for advanced users

This commit is contained in:
Diego Ruiz 2019-11-21 22:32:14 +01:00 committed by Carlos Ruiz
parent 853315f087
commit ca714c3774
3 changed files with 241 additions and 161 deletions

View File

@ -0,0 +1,28 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-2836 SQL Searches for advanced users
-- Nov 21, 2019, 10:28:50 PM CET
UPDATE AD_Field SET Help='The Validation Code displays the date, time and message of the error.
You can add advanced SQL queries to your searches by filling this field with @SQL=[WHERE CLAUSE].
Do not include the WHERE statement and use Fully qualified SQL statements. F.e:
@SQL=C_Order.isActive=''Y'' AND SalesRep_ID=@AD_User_ID@
will filter orders by active and where the sales representative is the current user.', IsCentrallyMaintained='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2019-11-21 22:28:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12249
;
-- Nov 21, 2019, 6:54:31 PM CET
UPDATE AD_Field SET Help='The Validation Code displays the date, time and message of the error.
You can add advanced SQL queries to your searches by filling this field with @SQL=[WHERE CLAUSE].
Do not include the WHERE statement and use Fully qualified SQL statements. F.e:
@SQL=C_Order.isActive=''Y'' AND SalesRep_ID=@AD_User_ID@
will filter orders by active and where the sales representative is the current user.', IsCentrallyMaintained='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2019-11-21 18:54:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206305
;
SELECT register_migration_script('201911211857_IDEMPIERE-2836.sql') FROM dual
;

View File

@ -0,0 +1,25 @@
-- IDEMPIERE-2836 SQL Searches for advanced users
-- Nov 21, 2019, 10:28:50 PM CET
UPDATE AD_Field SET Help='The Validation Code displays the date, time and message of the error.
You can add advanced SQL queries to your searches by filling this field with @SQL=[WHERE CLAUSE].
Do not include the WHERE statement and use Fully qualified SQL statements. F.e:
@SQL=C_Order.isActive=''Y'' AND SalesRep_ID=@AD_User_ID@
will filter orders by active and where the sales representative is the current user.', IsCentrallyMaintained='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2019-11-21 22:28:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12249
;
-- Nov 21, 2019, 6:54:31 PM CET
UPDATE AD_Field SET Help='The Validation Code displays the date, time and message of the error.
You can add advanced SQL queries to your searches by filling this field with @SQL=[WHERE CLAUSE].
Do not include the WHERE statement and use Fully qualified SQL statements. F.e:
@SQL=C_Order.isActive=''Y'' AND SalesRep_ID=@AD_User_ID@
will filter orders by active and where the sales representative is the current user.', IsCentrallyMaintained='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2019-11-21 18:54:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206305
;
SELECT register_migration_script('201911211857_IDEMPIERE-2836.sql') FROM dual
;

View File

@ -243,6 +243,10 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
private StatusBarPanel statusBar = new StatusBarPanel();
/** END DEVCOFFEE **/
/** IDEMPIERE-2836 User Query Where */
private String m_whereUserQuery;
private ToolBar advancedPanelToolBar;
/**
* FindPanel Constructor
* @param targetWindowNo targetWindowNo
@ -469,10 +473,10 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
pnlButtonRight.appendChild(btnCancel);
pnlButtonRight.setStyle("text-align: right");
ToolBar toolBar = new ToolBar();
toolBar.appendChild(btnNew);
toolBar.appendChild(btnDelete);
ZKUpdateUtil.setWidth(toolBar, "100%");
advancedPanelToolBar = new ToolBar();
advancedPanelToolBar.appendChild(btnNew);
advancedPanelToolBar.appendChild(btnDelete);
ZKUpdateUtil.setWidth(advancedPanelToolBar, "100%");
fQueryName.addEventListener(Events.ON_SELECT, this);
@ -541,9 +545,9 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
North north =new North();
layout.appendChild(north);
north.appendChild(toolBar);
north.appendChild(advancedPanelToolBar);
ZKUpdateUtil.setVflex(toolBar, "0");
ZKUpdateUtil.setVflex(advancedPanelToolBar, "0");
Center center = new Center();
layout.appendChild(center);
@ -1313,6 +1317,8 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
}
else if (event.getTarget() == fQueryName)
{
m_whereUserQuery = null;
showAdvanced();
btnSave.setDisabled(false);
btnShare.setDisabled(false);
int index = fQueryName.getSelectedIndex();
@ -1483,6 +1489,11 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
private void parseUserQuery(MUserQuery userQuery)
{
String code = userQuery.getCode();
if (code.startsWith("@SQL=")) {
m_whereUserQuery = "(" + code.substring(code.indexOf("=")+1, code.length()) + ")";
log.log(Level.INFO, m_whereUserQuery);
hideAdvanced();
} else {
String[] segments = code.split(Pattern.quote(SEGMENT_SEPARATOR));
List<?> rowList = advancedPanel.getChildren();
@ -1506,8 +1517,9 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
//historyCombo.setSelectedItem(new Comboitem(history, history));
historyCombo.setSelectedIndex(getHistoryIndex(history)+1);
}
}
advancedPanel.invalidate();
winAdvanced.invalidate();
}
private int getHistoryIndex(String value)
@ -1613,6 +1625,8 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
//
m_query = new MQuery(m_tableName);
m_query.addRestriction(Env.parseContext(Env.getCtx(), m_targetWindowNo, m_whereExtended, false));
if (m_whereUserQuery == null) {
StringBuilder code = new StringBuilder();
int openBrackets = 0;
@ -1753,6 +1767,9 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
}
saveQuery(saveQuery, code, shareAllUsers);
} else {
m_query.addRestriction(Env.parseContext(Env.getCtx(), m_targetWindowNo, m_whereUserQuery, false));
}
} // cmd_saveAdvanced
@ -2709,4 +2726,14 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
} // setDtatusDB
/** END DEVCOFFEE **/
private void hideAdvanced() {
advancedPanelToolBar.setVisible(false);
advancedPanel.setVisible(false);
}
private void showAdvanced() {
advancedPanelToolBar.setVisible(true);
advancedPanel.setVisible(true);
}
} // FindPanel