IDEMPIERE-4368: Allow Define Default Saved Query for User (#169)

* Update AD_UserQuery models

* Implementation of initializing Default User Queries

* Added Migration Scripts

* Update 202007161400_IDEMPIERE-4368.sql

Added missing register_migration_script.

* IDEMPIERE-4368 Added missing script.

* IDEMPIERE-4368 Allow Define Default Saved Query for User

Fix Load defaults only on Initialization.

* IDEMPIERE-4368

Move Migration Script to 7.1 folder

* IDEMPEIRE-4368

Apply of patch.
This commit is contained in:
igorpojzl 2020-07-20 14:51:48 +02:00 committed by GitHub
parent 31acb032ab
commit dd2b24aafa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 183 additions and 45 deletions

View File

@ -0,0 +1,42 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-4368
-- Jul 16, 2020, 12:30:03 PM CEST
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,IsHtml) VALUES (214215,0,'Default','Default value','The Default Checkbox indicates if this record will be used as a default value.',814,'IsDefault','N',1,'N','N','N','N','N',0,'N',20,0,0,'Y',TO_DATE('2020-07-16 12:30:02','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-07-16 12:30:02','YYYY-MM-DD HH24:MI:SS'),100,1103,'Y','N','D','N','N','N','Y','d3ac9ca1-7806-449b-81fc-ffdc20be02b1','Y',0,'N','N','N')
;
-- Jul 16, 2020, 12:30:24 PM CEST
ALTER TABLE AD_UserQuery ADD IsDefault CHAR(1) DEFAULT 'N' CHECK (IsDefault IN ('Y','N'))
;
-- Jul 16, 2020, 12:36:23 PM CEST
ALTER TABLE AD_UserQuery MODIFY IsDefault CHAR(1) DEFAULT 'N'
;
-- Jul 16, 2020, 1:56:10 PM CEST
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (206419,'Default','Default value','The Default Checkbox indicates if this record will be used as a default value.',200275,214215,'Y',1,120,'N','N','N','N',0,0,'Y',TO_DATE('2020-07-16 13:56:09','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-07-16 13:56:09','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','046cd713-95d0-4ab4-95b4-fe1ebddde62d','Y',120,2,2)
;
-- Jul 16, 2020, 1:56:57 PM CEST
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (206420,'Default','Default value','The Default Checkbox indicates if this record will be used as a default value.',757,214215,'Y',1,90,'N','N','N','N',0,0,'Y',TO_DATE('2020-07-16 13:56:57','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-07-16 13:56:57','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','46e6f0ed-c348-479d-881e-39036bef7756','Y',90,2,2)
;
-- Jul 16, 2020, 2:01:14 PM CEST
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=70, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=5, IsToolbarButton=NULL,Updated=TO_DATE('2020-07-16 14:01:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206420
;
-- Jul 16, 2020, 2:01:14 PM CEST
UPDATE AD_Field SET SeqNo=80, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-07-16 14:01:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12246
;
-- Jul 16, 2020, 2:01:14 PM CEST
UPDATE AD_Field SET SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-07-16 14:01:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12249
;
-- Jul 16, 2020, 2:01:14 PM CEST
UPDATE AD_Field SET SeqNo=0, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-07-16 14:01:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204619
;
SELECT register_migration_script('202007161400_IDEMPIERE-4368.sql') FROM dual
;

View File

@ -0,0 +1,39 @@
-- IDEMPIERE-4368
-- Jul 16, 2020, 12:30:03 PM CEST
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,IsHtml) VALUES (214215,0,'Default','Default value','The Default Checkbox indicates if this record will be used as a default value.',814,'IsDefault','N',1,'N','N','N','N','N',0,'N',20,0,0,'Y',TO_TIMESTAMP('2020-07-16 12:30:02','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-07-16 12:30:02','YYYY-MM-DD HH24:MI:SS'),100,1103,'Y','N','D','N','N','N','Y','d3ac9ca1-7806-449b-81fc-ffdc20be02b1','Y',0,'N','N','N')
;
-- Jul 16, 2020, 12:30:24 PM CEST
ALTER TABLE AD_UserQuery ADD COLUMN IsDefault CHAR(1) DEFAULT 'N' CHECK (IsDefault IN ('Y','N'))
;
-- Jul 16, 2020, 12:36:23 PM CEST
INSERT INTO t_alter_column values('ad_userquery','IsDefault','CHAR(1)',null,'N')
;
-- Jul 16, 2020, 1:56:10 PM CEST
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (206419,'Default','Default value','The Default Checkbox indicates if this record will be used as a default value.',200275,214215,'Y',1,120,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2020-07-16 13:56:09','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-07-16 13:56:09','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','046cd713-95d0-4ab4-95b4-fe1ebddde62d','Y',120,2,2)
;
-- Jul 16, 2020, 1:56:57 PM CEST
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (206420,'Default','Default value','The Default Checkbox indicates if this record will be used as a default value.',757,214215,'Y',1,90,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2020-07-16 13:56:57','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-07-16 13:56:57','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','46e6f0ed-c348-479d-881e-39036bef7756','Y',90,2,2)
;
-- Jul 16, 2020, 2:01:14 PM CEST
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=70, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=5, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-07-16 14:01:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206420
;
-- Jul 16, 2020, 2:01:14 PM CEST
UPDATE AD_Field SET SeqNo=80, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-07-16 14:01:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12246
;
-- Jul 16, 2020, 2:01:14 PM CEST
UPDATE AD_Field SET SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-07-16 14:01:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12249
;
-- Jul 16, 2020, 2:01:14 PM CEST
UPDATE AD_Field SET SeqNo=0, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-07-16 14:01:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204619
;
SELECT register_migration_script('202007161400_IDEMPIERE-4368.sql') FROM dual
;

View File

@ -107,21 +107,6 @@ public interface I_AD_UserQuery
public org.compiere.model.I_AD_Table getAD_Table() throws RuntimeException; public org.compiere.model.I_AD_Table getAD_Table() throws RuntimeException;
/** Column name AD_User_ID */
public static final String COLUMNNAME_AD_User_ID = "AD_User_ID";
/** Set User/Contact.
* User within the system - Internal or Business Partner Contact
*/
public void setAD_User_ID (int AD_User_ID);
/** Get User/Contact.
* User within the system - Internal or Business Partner Contact
*/
public int getAD_User_ID();
public org.compiere.model.I_AD_User getAD_User() throws RuntimeException;
/** Column name AD_UserQuery_ID */ /** Column name AD_UserQuery_ID */
public static final String COLUMNNAME_AD_UserQuery_ID = "AD_UserQuery_ID"; public static final String COLUMNNAME_AD_UserQuery_ID = "AD_UserQuery_ID";
@ -144,6 +129,21 @@ public interface I_AD_UserQuery
/** Get AD_UserQuery_UU */ /** Get AD_UserQuery_UU */
public String getAD_UserQuery_UU(); public String getAD_UserQuery_UU();
/** Column name AD_User_ID */
public static final String COLUMNNAME_AD_User_ID = "AD_User_ID";
/** Set User/Contact.
* User within the system - Internal or Business Partner Contact
*/
public void setAD_User_ID (int AD_User_ID);
/** Get User/Contact.
* User within the system - Internal or Business Partner Contact
*/
public int getAD_User_ID();
public org.compiere.model.I_AD_User getAD_User() throws RuntimeException;
/** Column name AD_Window_ID */ /** Column name AD_Window_ID */
public static final String COLUMNNAME_AD_Window_ID = "AD_Window_ID"; public static final String COLUMNNAME_AD_Window_ID = "AD_Window_ID";
@ -214,6 +214,19 @@ public interface I_AD_UserQuery
*/ */
public boolean isActive(); public boolean isActive();
/** Column name IsDefault */
public static final String COLUMNNAME_IsDefault = "IsDefault";
/** Set Default.
* Default value
*/
public void setIsDefault (boolean IsDefault);
/** Get Default.
* Default value
*/
public boolean isDefault();
/** Column name Name */ /** Column name Name */
public static final String COLUMNNAME_Name = "Name"; public static final String COLUMNNAME_Name = "Name";

View File

@ -30,7 +30,7 @@ public class X_AD_UserQuery extends PO implements I_AD_UserQuery, I_Persistent
/** /**
* *
*/ */
private static final long serialVersionUID = 20200413L; private static final long serialVersionUID = 20200716L;
/** Standard Constructor */ /** Standard Constructor */
public X_AD_UserQuery (Properties ctx, int AD_UserQuery_ID, String trxName) public X_AD_UserQuery (Properties ctx, int AD_UserQuery_ID, String trxName)
@ -158,34 +158,6 @@ public class X_AD_UserQuery extends PO implements I_AD_UserQuery, I_Persistent
return ii.intValue(); return ii.intValue();
} }
public org.compiere.model.I_AD_User getAD_User() throws RuntimeException
{
return (org.compiere.model.I_AD_User)MTable.get(getCtx(), org.compiere.model.I_AD_User.Table_Name)
.getPO(getAD_User_ID(), get_TrxName()); }
/** Set User/Contact.
@param AD_User_ID
User within the system - Internal or Business Partner Contact
*/
public void setAD_User_ID (int AD_User_ID)
{
if (AD_User_ID < 1)
set_Value (COLUMNNAME_AD_User_ID, null);
else
set_Value (COLUMNNAME_AD_User_ID, Integer.valueOf(AD_User_ID));
}
/** Get User/Contact.
@return User within the system - Internal or Business Partner Contact
*/
public int getAD_User_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_User_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set User Query. /** Set User Query.
@param AD_UserQuery_ID @param AD_UserQuery_ID
Saved User Query Saved User Query
@ -223,6 +195,34 @@ public class X_AD_UserQuery extends PO implements I_AD_UserQuery, I_Persistent
return (String)get_Value(COLUMNNAME_AD_UserQuery_UU); return (String)get_Value(COLUMNNAME_AD_UserQuery_UU);
} }
public org.compiere.model.I_AD_User getAD_User() throws RuntimeException
{
return (org.compiere.model.I_AD_User)MTable.get(getCtx(), org.compiere.model.I_AD_User.Table_Name)
.getPO(getAD_User_ID(), get_TrxName()); }
/** Set User/Contact.
@param AD_User_ID
User within the system - Internal or Business Partner Contact
*/
public void setAD_User_ID (int AD_User_ID)
{
if (AD_User_ID < 1)
set_Value (COLUMNNAME_AD_User_ID, null);
else
set_Value (COLUMNNAME_AD_User_ID, Integer.valueOf(AD_User_ID));
}
/** Get User/Contact.
@return User within the system - Internal or Business Partner Contact
*/
public int getAD_User_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_User_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public org.compiere.model.I_AD_Window getAD_Window() throws RuntimeException public org.compiere.model.I_AD_Window getAD_Window() throws RuntimeException
{ {
return (org.compiere.model.I_AD_Window)MTable.get(getCtx(), org.compiere.model.I_AD_Window.Table_Name) return (org.compiere.model.I_AD_Window)MTable.get(getCtx(), org.compiere.model.I_AD_Window.Table_Name)
@ -285,6 +285,30 @@ public class X_AD_UserQuery extends PO implements I_AD_UserQuery, I_Persistent
return (String)get_Value(COLUMNNAME_Description); return (String)get_Value(COLUMNNAME_Description);
} }
/** Set Default.
@param IsDefault
Default value
*/
public void setIsDefault (boolean IsDefault)
{
set_Value (COLUMNNAME_IsDefault, Boolean.valueOf(IsDefault));
}
/** Get Default.
@return Default value
*/
public boolean isDefault ()
{
Object oo = get_Value(COLUMNNAME_IsDefault);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Name. /** Set Name.
@param Name @param Name
Alphanumeric identifier of the entity Alphanumeric identifier of the entity

View File

@ -1238,4 +1238,20 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
return selectedUserQuery.getAD_UserQuery_ID(); return selectedUserQuery.getAD_UserQuery_ID();
} }
/**
* Init Default Query in Window Toolbar
* @return true if initialized
*/
public boolean initDefaultQuery() {
if(userQueries != null) {
for (int i = 0; i < userQueries.length; i++) {
if(userQueries[i].isDefault()) {
fQueryName.setSelectedIndex(i);
setSelectedUserQuery(userQueries[i]);
return true;
}
}
}
return false;
}
} }

View File

@ -386,6 +386,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
toolbar.updateToolbarAccess(adWindowId); toolbar.updateToolbarAccess(adWindowId);
updateToolbar(); updateToolbar();
if (toolbar.initDefaultQuery()) {
doOnQueryChange();
}
if (detailQuery != null && zoomToDetailTab(detailQuery)) if (detailQuery != null && zoomToDetailTab(detailQuery))
{ {
@ -1448,6 +1451,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
(!isNewRow && (m_onlyCurrentRows || m_onlyCurrentDays > 0))); (!isNewRow && (m_onlyCurrentRows || m_onlyCurrentDays > 0)));
toolbar.refreshUserQuery(adTabbox.getSelectedGridTab().getAD_Tab_ID(), findWindow != null ? findWindow.getAD_UserQuery_ID() : 0); toolbar.refreshUserQuery(adTabbox.getSelectedGridTab().getAD_Tab_ID(), findWindow != null ? findWindow.getAD_UserQuery_ID() : 0);
} }
/** /**