IDEMPIERE-5470 - Date Range Fieldtype (Reference List) (#1552)

* IDEMPIERE-5470 - Date Range Fieldtype (Reference List)

* IDEMPIERE-5470 - autodetection, fixing concept

* IDEMPIERE-5470 - remove Date Range Picker reference

* IDEMPIERE-5470 - add IsDisplayDateInWords to Process Parameter

* IDEMPIERE-5470 - DateRangeOption dropdown

* IDEMPIERE-5470 - fixes

* IDEMPIERE-5470 - patch pr1552

* IDEMPIERE-5470 - patch pr1552_1
This commit is contained in:
Peter Takács 2023-03-02 12:27:36 +01:00 committed by GitHub
parent eab14e9b5d
commit 36613c467e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 761 additions and 124 deletions

View File

@ -0,0 +1,106 @@
-- IDEMPIERE-5470
SELECT register_migration_script('202212020805_IDEMPIERE-5470.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Dec 2, 2022, 8:05:38 AM CET
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,PrintName,EntityType,AD_Element_UU) VALUES (203739,0,0,'Y',TO_TIMESTAMP('2022-12-02 08:05:37','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-12-02 08:05:37','YYYY-MM-DD HH24:MI:SS'),100,'IsDisplayDateInWords','Display Date In Words','Display Date In Words','D','74c708de-108a-4154-8b15-05a04fa74bcc')
;
-- Dec 2, 2022, 8:08:15 AM CET
INSERT INTO AD_Column (AD_Column_ID,Version,Name,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,FKConstraintType,IsHtml) VALUES (215695,0,'Display Date In Words',285,'IsDisplayDateInWords','N',1,'N','N','Y','N','N',0,'N',20,0,0,'Y',TO_TIMESTAMP('2022-12-02 08:08:15','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-12-02 08:08:15','YYYY-MM-DD HH24:MI:SS'),100,203739,'Y','N','D','N','N','N','Y','b26c16cb-e473-48e6-98b2-44130792d069','Y',0,'N','N','N','N')
;
-- Dec 2, 2022, 8:08:19 AM CET
ALTER TABLE AD_Process_Para ADD IsDisplayDateInWords CHAR(1) DEFAULT 'N' CHECK (IsDisplayDateInWords IN ('Y','N')) NOT NULL
;
-- Dec 2, 2022, 8:08:46 AM CET
INSERT INTO AD_Field (AD_Field_ID,Name,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 (207456,'Display Date In Words',246,215695,'Y',1,310,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2022-12-02 08:08:46','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-12-02 08:08:46','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','2d0f049f-bd43-4878-bcf8-b21fc1d04179','Y',290,2,2)
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=130,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205238
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=140,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5818
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=150,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2539
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=160,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2540
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=170,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2907
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=180,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2901
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=190,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2903
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=200,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200097
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=210,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2904
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=220, XPosition=5,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2544
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET IsDisplayed='Y', DisplayLogic='(@AD_Reference_ID@=15 | @AD_Reference_ID@=16) & @IsRange@=''Y''', SeqNo=230, XPosition=5,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207456
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=240,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205339
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=250,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2902
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=260,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4398
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=270,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2906
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=280,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2905
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=290,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205193
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=300,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=56333
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=310,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=56334
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=320,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204372
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=330,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206410
;

View File

@ -0,0 +1,62 @@
-- IDEMPIERE-5470
SELECT register_migration_script('202302060840_IDEMPIERE-5470.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Feb 6, 2023, 8:40:29 AM CET
UPDATE AD_Element SET ColumnName='DateRangeOption', Name='Date Range Option', Description='Options, how the date editor will be displayed.', PrintName='Date Range Option',Updated=TO_TIMESTAMP('2023-02-06 08:40:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=203739
;
-- Feb 6, 2023, 8:40:29 AM CET
UPDATE AD_Column SET ColumnName='DateRangeOption', Name='Date Range Option', Description='Options, how the date editor will be displayed.', Help=NULL, Placeholder=NULL WHERE AD_Element_ID=203739
;
-- Feb 6, 2023, 8:40:29 AM CET
UPDATE AD_Process_Para SET ColumnName='DateRangeOption', Name='Date Range Option', Description='Options, how the date editor will be displayed.', Help=NULL, AD_Element_ID=203739 WHERE UPPER(ColumnName)='DATERANGEOPTION' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL
;
-- Feb 6, 2023, 8:40:29 AM CET
UPDATE AD_Process_Para SET ColumnName='DateRangeOption', Name='Date Range Option', Description='Options, how the date editor will be displayed.', Help=NULL, Placeholder=NULL WHERE AD_Element_ID=203739 AND IsCentrallyMaintained='Y'
;
-- Feb 6, 2023, 8:40:29 AM CET
UPDATE AD_InfoColumn SET ColumnName='DateRangeOption', Name='Date Range Option', Description='Options, how the date editor will be displayed.', Help=NULL, Placeholder=NULL WHERE AD_Element_ID=203739 AND IsCentrallyMaintained='Y'
;
-- Feb 6, 2023, 8:40:29 AM CET
UPDATE AD_Field SET Name='Date Range Option', Description='Options, how the date editor will be displayed.', Help=NULL, Placeholder=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=203739) AND IsCentrallyMaintained='Y'
;
-- Feb 6, 2023, 8:40:29 AM CET
UPDATE AD_PrintFormatItem SET PrintName='Date Range Option', Name='Date Range Option' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=203739)
;
-- Feb 6, 2023, 8:52:12 AM CET
INSERT INTO AD_Reference (AD_Reference_ID,Name,Description,ValidationType,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,IsOrderByValue,AD_Reference_UU) VALUES (200228,'Date Range Option','Options, how the date editor will be displayed.','L',0,0,'Y',TO_TIMESTAMP('2023-02-06 08:52:11','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-02-06 08:52:11','YYYY-MM-DD HH24:MI:SS'),100,'D','N','299b9200-3e9e-4923-8c32-5273dd17e7b4')
;
-- Feb 6, 2023, 8:53:29 AM CET
INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200622,'Date Editor and Range Picker',200228,'D',0,0,'Y',TO_TIMESTAMP('2023-02-06 08:53:28','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-02-06 08:53:28','YYYY-MM-DD HH24:MI:SS'),100,'D','e56a4c96-0480-4c0e-9f25-e68d1d70d082')
;
-- Feb 6, 2023, 8:53:42 AM CET
INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200623,'Text and Range Picker',200228,'T',0,0,'Y',TO_TIMESTAMP('2023-02-06 08:53:42','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-02-06 08:53:42','YYYY-MM-DD HH24:MI:SS'),100,'D','6ee1efd4-d59f-4efb-b0ca-722d2dd39ce5')
;
-- Feb 6, 2023, 8:54:33 AM CET
UPDATE AD_Column SET DefaultValue='D', AD_Reference_ID=17, AD_Reference_Value_ID=200228,Updated=TO_TIMESTAMP('2023-02-06 08:54:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=215695
;
-- Feb 6, 2023, 8:54:33 AM CET
ALTER TABLE AD_Process_Para DROP COLUMN IsDisplayDateInWords
;
-- Feb 6, 2023, 8:54:33 AM CET
ALTER TABLE AD_Process_Para ADD DateRangeOption CHAR(1) DEFAULT 'D' NOT NULL
;
-- Feb 6, 2023, 9:18:45 AM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=230, XPosition=4,Updated=TO_TIMESTAMP('2023-02-06 09:18:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207456
;

View File

@ -0,0 +1,103 @@
-- IDEMPIERE-5470
SELECT register_migration_script('202212020805_IDEMPIERE-5470.sql') FROM dual;
-- Dec 2, 2022, 8:05:38 AM CET
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,PrintName,EntityType,AD_Element_UU) VALUES (203739,0,0,'Y',TO_TIMESTAMP('2022-12-02 08:05:37','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-12-02 08:05:37','YYYY-MM-DD HH24:MI:SS'),100,'IsDisplayDateInWords','Display Date In Words','Display Date In Words','D','74c708de-108a-4154-8b15-05a04fa74bcc')
;
-- Dec 2, 2022, 8:08:15 AM CET
INSERT INTO AD_Column (AD_Column_ID,Version,Name,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,FKConstraintType,IsHtml) VALUES (215695,0,'Display Date In Words',285,'IsDisplayDateInWords','N',1,'N','N','Y','N','N',0,'N',20,0,0,'Y',TO_TIMESTAMP('2022-12-02 08:08:15','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-12-02 08:08:15','YYYY-MM-DD HH24:MI:SS'),100,203739,'Y','N','D','N','N','N','Y','b26c16cb-e473-48e6-98b2-44130792d069','Y',0,'N','N','N','N')
;
-- Dec 2, 2022, 8:08:19 AM CET
ALTER TABLE AD_Process_Para ADD COLUMN IsDisplayDateInWords CHAR(1) DEFAULT 'N' CHECK (IsDisplayDateInWords IN ('Y','N')) NOT NULL
;
-- Dec 2, 2022, 8:08:46 AM CET
INSERT INTO AD_Field (AD_Field_ID,Name,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 (207456,'Display Date In Words',246,215695,'Y',1,310,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2022-12-02 08:08:46','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-12-02 08:08:46','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','2d0f049f-bd43-4878-bcf8-b21fc1d04179','Y',290,2,2)
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=130,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205238
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=140,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5818
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=150,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2539
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=160,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2540
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=170,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2907
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=180,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2901
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=190,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2903
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=200,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200097
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=210,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2904
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=220, XPosition=5,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2544
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET IsDisplayed='Y', DisplayLogic='(@AD_Reference_ID@=15 | @AD_Reference_ID@=16) & @IsRange@=''Y''', SeqNo=230, XPosition=5,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207456
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=240,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205339
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=250,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2902
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=260,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4398
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=270,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2906
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=280,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2905
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=290,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205193
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=300,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=56333
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=310,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=56334
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=320,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204372
;
-- Dec 2, 2022, 8:12:47 AM CET
UPDATE AD_Field SET SeqNo=330,Updated=TO_TIMESTAMP('2022-12-02 08:12:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206410
;

View File

@ -0,0 +1,59 @@
-- IDEMPIERE-5470
SELECT register_migration_script('202302060840_IDEMPIERE-5470.sql') FROM dual;
-- Feb 6, 2023, 8:40:29 AM CET
UPDATE AD_Element SET ColumnName='DateRangeOption', Name='Date Range Option', Description='Options, how the date editor will be displayed.', PrintName='Date Range Option',Updated=TO_TIMESTAMP('2023-02-06 08:40:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=203739
;
-- Feb 6, 2023, 8:40:29 AM CET
UPDATE AD_Column SET ColumnName='DateRangeOption', Name='Date Range Option', Description='Options, how the date editor will be displayed.', Help=NULL, Placeholder=NULL WHERE AD_Element_ID=203739
;
-- Feb 6, 2023, 8:40:29 AM CET
UPDATE AD_Process_Para SET ColumnName='DateRangeOption', Name='Date Range Option', Description='Options, how the date editor will be displayed.', Help=NULL, AD_Element_ID=203739 WHERE UPPER(ColumnName)='DATERANGEOPTION' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL
;
-- Feb 6, 2023, 8:40:29 AM CET
UPDATE AD_Process_Para SET ColumnName='DateRangeOption', Name='Date Range Option', Description='Options, how the date editor will be displayed.', Help=NULL, Placeholder=NULL WHERE AD_Element_ID=203739 AND IsCentrallyMaintained='Y'
;
-- Feb 6, 2023, 8:40:29 AM CET
UPDATE AD_InfoColumn SET ColumnName='DateRangeOption', Name='Date Range Option', Description='Options, how the date editor will be displayed.', Help=NULL, Placeholder=NULL WHERE AD_Element_ID=203739 AND IsCentrallyMaintained='Y'
;
-- Feb 6, 2023, 8:40:29 AM CET
UPDATE AD_Field SET Name='Date Range Option', Description='Options, how the date editor will be displayed.', Help=NULL, Placeholder=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=203739) AND IsCentrallyMaintained='Y'
;
-- Feb 6, 2023, 8:40:29 AM CET
UPDATE AD_PrintFormatItem SET PrintName='Date Range Option', Name='Date Range Option' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=203739)
;
-- Feb 6, 2023, 8:52:12 AM CET
INSERT INTO AD_Reference (AD_Reference_ID,Name,Description,ValidationType,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,IsOrderByValue,AD_Reference_UU) VALUES (200228,'Date Range Option','Options, how the date editor will be displayed.','L',0,0,'Y',TO_TIMESTAMP('2023-02-06 08:52:11','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-02-06 08:52:11','YYYY-MM-DD HH24:MI:SS'),100,'D','N','299b9200-3e9e-4923-8c32-5273dd17e7b4')
;
-- Feb 6, 2023, 8:53:29 AM CET
INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200622,'Date Editor and Range Picker',200228,'D',0,0,'Y',TO_TIMESTAMP('2023-02-06 08:53:28','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-02-06 08:53:28','YYYY-MM-DD HH24:MI:SS'),100,'D','e56a4c96-0480-4c0e-9f25-e68d1d70d082')
;
-- Feb 6, 2023, 8:53:42 AM CET
INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200623,'Text and Range Picker',200228,'T',0,0,'Y',TO_TIMESTAMP('2023-02-06 08:53:42','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-02-06 08:53:42','YYYY-MM-DD HH24:MI:SS'),100,'D','6ee1efd4-d59f-4efb-b0ca-722d2dd39ce5')
;
-- Feb 6, 2023, 8:54:33 AM CET
UPDATE AD_Column SET DefaultValue='D', AD_Reference_ID=17, AD_Reference_Value_ID=200228,Updated=TO_TIMESTAMP('2023-02-06 08:54:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=215695
;
-- Feb 6, 2023, 8:54:33 AM CET
ALTER TABLE AD_Process_Para DROP COLUMN IsDisplayDateInWords
;
-- Dec 2, 2022, 8:08:19 AM CET
ALTER TABLE AD_Process_Para ADD COLUMN DateRangeOption CHAR(1) DEFAULT 'D' NOT NULL
;
-- Feb 6, 2023, 9:18:45 AM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=230, XPosition=4,Updated=TO_TIMESTAMP('2023-02-06 09:18:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207456
;

View File

@ -2610,6 +2610,14 @@ public class GridField
return m_vo.IsQuickForm;
}
/**
* Get Date Range Options
* @return The option, how the date editor will be displayed.
*/
public String getDateRangeOption() {
return m_vo.dateRangeOption;
}
public void processUIVirtualColumn() {
String sql = m_vo.ColumnSQL.substring(5);
sql = Env.parseContext(Env.getCtx(), getWindowNo(), sql, false);

View File

@ -371,6 +371,7 @@ public class GridFieldVO implements Serializable, Cloneable
vo.ValueMin = rs.getString("ValueMin");
vo.ValueMax = rs.getString("ValueMax");
vo.isRange = rs.getString("IsRange").equals("Y");
vo.dateRangeOption = rs.getString("DateRangeOption");
//
vo.AD_Reference_Value_ID = rs.getInt("AD_Reference_Value_ID");
vo.ValidationCode = rs.getString("ValidationCode");
@ -481,6 +482,7 @@ public class GridFieldVO implements Serializable, Cloneable
voT.ValueMin = voF.ValueMin;
voT.ValueMax = voF.ValueMax;
voT.isRange = voF.isRange;
voT.dateRangeOption = voF.dateRangeOption;
//
// Genied: For a range parameter the second field
// lookup behaviour should match the first one.
@ -720,6 +722,8 @@ public class GridFieldVO implements Serializable, Cloneable
public boolean isRange = false;
/** Process Parameter Value2 */
public String DefaultValue2 = "";
/** Date Range Option */
public String dateRangeOption = "";
/** Lookup Value Object */
public MLookupInfo lookupInfo = null;

View File

@ -199,6 +199,19 @@ public interface I_AD_Process_Para
*/
public int getCreatedBy();
/** Column name DateRangeOption */
public static final String COLUMNNAME_DateRangeOption = "DateRangeOption";
/** Set Date Range Option.
* Options, how the date editor will be displayed.
*/
public void setDateRangeOption (String DateRangeOption);
/** Get Date Range Option.
* Options, how the date editor will be displayed.
*/
public String getDateRangeOption();
/** Column name DefaultValue */
public static final String COLUMNNAME_DefaultValue = "DefaultValue";
@ -471,6 +484,25 @@ public interface I_AD_Process_Para
*/
public int getUpdatedBy();
/** Column name VFormat */
public static final String COLUMNNAME_VFormat = "VFormat";
/** Set Value Format.
* Format of the value;
Can contain fixed format elements, Variables: "
_lLoOaAcCa09"
*/
public void setVFormat (String VFormat);
/** Get Value Format.
* Format of the value;
Can contain fixed format elements, Variables: "
_lLoOaAcCa09"
*/
public String getVFormat();
/** Column name ValueMax */
public static final String COLUMNNAME_ValueMax = "ValueMax";
@ -496,23 +528,4 @@ public interface I_AD_Process_Para
* Minimum Value for a field
*/
public String getValueMin();
/** Column name VFormat */
public static final String COLUMNNAME_VFormat = "VFormat";
/** Set Value Format.
* Format of the value;
Can contain fixed format elements, Variables: "
_lLoOaAcCa09"
*/
public void setVFormat (String VFormat);
/** Get Value Format.
* Format of the value;
Can contain fixed format elements, Variables: "
_lLoOaAcCa09"
*/
public String getVFormat();
}

View File

@ -31,7 +31,7 @@ public class X_AD_Process_Para extends PO implements I_AD_Process_Para, I_Persis
/**
*
*/
private static final long serialVersionUID = 20221224L;
private static final long serialVersionUID = 20230206L;
/** Standard Constructor */
public X_AD_Process_Para (Properties ctx, int AD_Process_Para_ID, String trxName)
@ -43,6 +43,8 @@ public class X_AD_Process_Para extends PO implements I_AD_Process_Para, I_Persis
setAD_Process_Para_ID (0);
setAD_Reference_ID (0);
setColumnName (null);
setDateRangeOption (null);
// D
setEntityType (null);
// @SQL=SELECT CASE WHEN '@P|AdempiereSys:N@'='Y' THEN 'D' ELSE get_sysconfig('DEFAULT_ENTITYTYPE','U',0,0) END FROM Dual
setFieldLength (0);
@ -70,6 +72,8 @@ public class X_AD_Process_Para extends PO implements I_AD_Process_Para, I_Persis
setAD_Process_Para_ID (0);
setAD_Reference_ID (0);
setColumnName (null);
setDateRangeOption (null);
// D
setEntityType (null);
// @SQL=SELECT CASE WHEN '@P|AdempiereSys:N@'='Y' THEN 'D' ELSE get_sysconfig('DEFAULT_ENTITYTYPE','U',0,0) END FROM Dual
setFieldLength (0);
@ -335,6 +339,29 @@ public class X_AD_Process_Para extends PO implements I_AD_Process_Para, I_Persis
return (String)get_Value(COLUMNNAME_ColumnName);
}
/** DateRangeOption AD_Reference_ID=200228 */
public static final int DATERANGEOPTION_AD_Reference_ID=200228;
/** Date Editor and Range Picker = D */
public static final String DATERANGEOPTION_DateEditorAndRangePicker = "D";
/** Text and Range Picker = T */
public static final String DATERANGEOPTION_TextAndRangePicker = "T";
/** Set Date Range Option.
@param DateRangeOption Options, how the date editor will be displayed.
*/
public void setDateRangeOption (String DateRangeOption)
{
set_Value (COLUMNNAME_DateRangeOption, DateRangeOption);
}
/** Get Date Range Option.
@return Options, how the date editor will be displayed.
*/
public String getDateRangeOption()
{
return (String)get_Value(COLUMNNAME_DateRangeOption);
}
/** Set Default Logic.
@param DefaultValue Default value hierarchy, separated by ;
*/
@ -688,6 +715,22 @@ public class X_AD_Process_Para extends PO implements I_AD_Process_Para, I_Persis
return ii.intValue();
}
/** Set Value Format.
@param VFormat Format of the value; Can contain fixed format elements, Variables: "_lLoOaAcCa09"
*/
public void setVFormat (String VFormat)
{
set_Value (COLUMNNAME_VFormat, VFormat);
}
/** Get Value Format.
@return Format of the value; Can contain fixed format elements, Variables: "_lLoOaAcCa09"
*/
public String getVFormat()
{
return (String)get_Value(COLUMNNAME_VFormat);
}
/** Set Max. Value.
@param ValueMax Maximum Value for a field
*/
@ -719,20 +762,4 @@ public class X_AD_Process_Para extends PO implements I_AD_Process_Para, I_Persis
{
return (String)get_Value(COLUMNNAME_ValueMin);
}
/** Set Value Format.
@param VFormat Format of the value; Can contain fixed format elements, Variables: "_lLoOaAcCa09"
*/
public void setVFormat (String VFormat)
{
set_Value (COLUMNNAME_VFormat, VFormat);
}
/** Get Value Format.
@return Format of the value; Can contain fixed format elements, Variables: "_lLoOaAcCa09"
*/
public String getVFormat()
{
return (String)get_Value(COLUMNNAME_VFormat);
}
}

View File

@ -178,7 +178,7 @@ public final class DisplayType
public static final int TimestampWithTimeZone = REFERENCE_DATATYPE_TIMESTAMP_WITH_TIMEZONE;
public static final int TimeZoneId = REFERENCE_DATATYPE_TIMEZONE;
/**
* - New Display Type
INSERT INTO AD_REFERENCE

View File

@ -57,6 +57,6 @@ Copyright (C) 2007 Ashley G Ramdass (ADempiere WebUI).
<!-- this js module doesn't actually exists and it is here for default theme version -->
<!-- since loading of js module is on demand, it doesn't cause any error as long as you don't try to load it -->
<javascript-module name="idempiere.theme.default" version="202301160600" />
<javascript-module name="idempiere.theme.default" version="202302161100" />
</language>

View File

@ -201,12 +201,33 @@ public final class LayoutUtils {
.append(position)
.append("');");
Clients.response("_openPopupWindow_", new AuScript(window, script.toString()));
}
/**
* open embedded window relative to ref component
* @param ref
* @param window
}
/**
* position component relative to ref component
* @param ref
* @param component
* @param position Refer to https://www.zkoss.org/javadoc/latest/jsdoc/_global_/jqzk.html#position-_global_.Dimension-_global_.String-_global_.Map-
*/
public static void positionComponent(Component ref, Component component, String position) {
StringBuilder script = new StringBuilder();
script.append("(function() {let w = zk('#")
.append(component.getUuid())
.append("'); ")
.append("let ref=zk.Widget.$('#")
.append(ref.getUuid())
.append("'); ")
.append("w.position(")
.append("ref.$n(),'")
.append(position)
.append("');})()");
Clients.response("_positionComponent_", new AuScript(component, script.toString()));
}
/**
* open embedded window relative to ref component
* @param ref
* @param window
* @param position Refer to https://www.zkoss.org/javadoc/latest/jsdoc/_global_/jqzk.html#position-_global_.Dimension-_global_.String-_global_.Map-
*/
public static void openEmbeddedWindow(Component ref, Window window, String position) {

View File

@ -40,6 +40,7 @@ import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.Row;
import org.adempiere.webui.component.Rows;
import org.adempiere.webui.component.Urlbox;
import org.adempiere.webui.editor.DateRangeEditor;
import org.adempiere.webui.editor.IZoomableEditor;
import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.editor.WEditorPopupMenu;
@ -61,6 +62,7 @@ import org.compiere.model.MLookup;
import org.compiere.model.MPInstance;
import org.compiere.model.MPInstancePara;
import org.compiere.model.MProcess;
import org.compiere.model.MProcessPara;
import org.compiere.model.X_AD_FieldGroup;
import org.compiere.process.ProcessInfo;
import org.compiere.process.ProcessInfoParameter;
@ -168,9 +170,13 @@ public class ProcessParameterPanel extends Panel implements
private ArrayList<GridField> m_mFields = new ArrayList<GridField>();
/** to parameter field list for range parameter **/
private ArrayList<GridField> m_mFields2 = new ArrayList<GridField>();
/** list of separators **/
private ArrayList<Space> m_separators = new ArrayList<Space>();
/** all rows of {@link #centerPanel} **/
private ArrayList<Row> m_Rows = new ArrayList<Row>();
/** list of all date range editors **/
private ArrayList<DateRangeEditor> m_dateRangeEditors = new ArrayList<DateRangeEditor>();
//
/** layout grid for parameter fields **/
private Grid centerPanel = null;
/** Group Name:Rows for parameter field **/
@ -248,7 +254,7 @@ public class ProcessParameterPanel extends Panel implements
if (Env.isBaseLanguage(Env.getCtx(), "AD_Process_Para"))
sql = "SELECT p.Name, p.Description, p.Help, "
+ "p.AD_Reference_ID, p.AD_Process_Para_ID, "
+ "p.FieldLength, p.IsMandatory, p.IsRange, p.ColumnName, "
+ "p.FieldLength, p.IsMandatory, p.IsRange, p.dateRangeOption, p.ColumnName, "
+ "p.DefaultValue, p.DefaultValue2, p.VFormat, p.ValueMin, p.ValueMax, "
+ "p.SeqNo, p.AD_Reference_Value_ID, vr.Code AS ValidationCode, "
+ "p.ReadOnlyLogic, p.DisplayLogic, p.IsEncrypted, NULL AS FormatPattern, p.MandatoryLogic, p.Placeholder, p.Placeholder2, p.isAutoComplete, "
@ -262,7 +268,7 @@ public class ProcessParameterPanel extends Panel implements
else
sql = "SELECT t.Name, t.Description, t.Help, "
+ "p.AD_Reference_ID, p.AD_Process_Para_ID, "
+ "p.FieldLength, p.IsMandatory, p.IsRange, p.ColumnName, "
+ "p.FieldLength, p.IsMandatory, p.IsRange, p.dateRangeOption, p.ColumnName, "
+ "p.DefaultValue, p.DefaultValue2, p.VFormat, p.ValueMin, p.ValueMax, "
+ "p.SeqNo, p.AD_Reference_Value_ID, vr.Code AS ValidationCode, "
+ "p.ReadOnlyLogic, p.DisplayLogic, p.IsEncrypted, NULL AS FormatPattern,p.MandatoryLogic, t.Placeholder, t.Placeholder2, p.isAutoComplete, "
@ -496,14 +502,31 @@ public class ProcessParameterPanel extends Panel implements
row.appendChild(box);
if (((mField.getDisplayType() == DisplayType.Date) || (mField.getDisplayType() == DisplayType.DateTime))
&& ((mField2.getDisplayType() == DisplayType.Date) || (mField2.getDisplayType() == DisplayType.DateTime))) {
DateRangeButton dateRangeButton = new DateRangeButton(editor, editor2);
box.appendChild(dateRangeButton);
if(MProcessPara.DATERANGEOPTION_TextAndRangePicker.equalsIgnoreCase(mField.getDateRangeOption())) {
editor.setVisible(false, true);
editor2.setVisible(false, true);
DateRangeEditor dateRangeEditor = new DateRangeEditor(editor, editor2);
box.appendChild(dateRangeEditor);
dateRangeEditor.setVisible(mField.isDisplayed(true));
label.setVisible(dateRangeEditor.isVisible());
dateRangeEditor.setReadOnly(!(editor.isReadWrite() && editor2.isReadWrite()));
m_dateRangeEditors.add(dateRangeEditor);
}
else {
DateRangeButton dateRangeButton = new DateRangeButton(editor, editor2);
box.appendChild(dateRangeButton);
m_dateRangeEditors.add(null);
}
}
else {
m_dateRangeEditors.add(null);
}
} else {
box.appendChild(editor.getComponent());
m_mFields2.add(null);
m_wEditors2.add(null);
m_separators.add(null);
m_dateRangeEditors.add(null);
//add not in support for multi selection field
if(DisplayType.isChosenMultipleSelection(mField.getDisplayType())) {
Button bNegate = ButtonFactory.createButton("", null, null);
@ -1126,6 +1149,10 @@ public class ProcessParameterPanel extends Panel implements
for (int i = 0; i < m_wEditors.size(); i++) {
WEditor editor = m_wEditors.get(i);
GridField mField = editor.getGridField();
GridField mField2 = null;
if (mField.getVO().isRange) {
mField2 = m_wEditors2.get(i).getGridField();
}
if (mField.isDisplayed(true)) {
if (!editor.isVisible()) {
editor.setVisible(true);
@ -1178,6 +1205,25 @@ public class ProcessParameterPanel extends Panel implements
LayoutUtils.addSclass("idempiere-mandatory-label", editor.getLabel());
}
}
// Handle Dynamic Display for Date Range Picker
if (((mField.getDisplayType() == DisplayType.Date) || (mField.getDisplayType() == DisplayType.DateTime))
&& mField2 != null
&& ((mField2.getDisplayType() == DisplayType.Date) || (mField2.getDisplayType() == DisplayType.DateTime))
&& MProcessPara.DATERANGEOPTION_TextAndRangePicker.equalsIgnoreCase(mField.getDateRangeOption())) {
DateRangeEditor dateRangeEditor = m_dateRangeEditors.get(i);
if(dateRangeEditor != null) {
dateRangeEditor.setVisible(editor.isVisible());
m_Rows.get(i).setVisible(editor.isVisible());
m_Rows.get(i).setAttribute(Group.GROUP_ROW_VISIBLE_KEY, editor.isVisible());
editor.setVisible(false, true);
if (mField.getVO().isRange) {
m_separators.get(i).setVisible(false);
m_wEditors2.get(i).setVisible(false ,true);
}
dateRangeEditor.setFieldMandatoryStyle();
dateRangeEditor.setReadOnly(!(editor.isReadWrite() && m_wEditors2.get(i).isReadWrite()));
}
}
}
if (getParent() != null) {
getParent().invalidate();

View File

@ -0,0 +1,172 @@
/**********************************************************************
* This file is part of iDempiere ERP Open Source *
* http://www.idempiere.org *
* *
* Copyright (C) Contributors *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - Peter Takacs, Cloudempiere *
**********************************************************************/
package org.adempiere.webui.editor;
import java.util.Objects;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.component.ZkCssHelper;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.window.DateRangePicker;
import org.compiere.util.Util;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Div;
/**
* Composite component of a read only Textbox and ToolbarButton.<br/>
* ToolbarButton open {@link DateRangePicker} to edit the value of from and to editor. Result is then shown in
* the read only Textbox.
* @author Peter Takacs, Cloudempiere
*
*/
public class DateRangeEditor extends Div implements ValueChangeListener {
/**
* generated serial id
*/
private static final long serialVersionUID = 3329360781729704243L;
private static final String IMAGES_CONTEXT_CALENDAR_PNG = "images/Calendar16.png";
private Textbox textbox;
private ToolBarButton popupBtn;
private DateRangePicker popup;
private WEditor editor;
private WEditor editor2;
private Label dateRangeText;
/**
* Constructor
* @param editor
* @param editor2
*/
public DateRangeEditor(WEditor editor, WEditor editor2) {
super();
this.editor = editor;
this.editor2 = editor2;
init();
}
/**
* Layout UI.
* Horizontal layout of Textbox and ToolBarButton.
*/
private void init() {
this.setWidth("100%");
ZkCssHelper.appendStyle(this, "display: inline-block; position: relative;");
textbox = new Textbox();
textbox.setStyle("width: 100%; background: white !important");
textbox.setReadonly(true);
this.appendChild(textbox);
popupBtn = new ToolBarButton();
popupBtn.addSclass("date-picker-calendar-button");
if (ThemeManager.isUseFontIconForImage())
popupBtn.setIconSclass("z-icon-Calendar");
else
popupBtn.setImage(ThemeManager.getThemeResource(IMAGES_CONTEXT_CALENDAR_PNG));
this.appendChild(popupBtn);
popup = new DateRangePicker(editor, editor2);
popupBtn.addEventListener(Events.ON_CLICK, event -> {
popup.setPage(popupBtn.getPage());
popup.open(popupBtn, "after_center");
LayoutUtils.autoDetachOnClose(popup);
});
popup.addValueChangeListener(this);
dateRangeText = new Label();
this.appendChild(dateRangeText);
dateRangeText.setStyle("font-size: x-small;font-weight: normal;position: absolute;display: block;");
dateRangeText.setVisible(false);
}
@Override
public void valueChange(ValueChangeEvent evt) {
textbox.setValue(evt.getNewValue() != null ? evt.getNewValue().toString() : "");
if (evt.getNewValue() != null) {
if (textbox.getValue().equals(popup.getDateRangeText())) {
dateRangeText.setValue("");
dateRangeText.setVisible(false);
} else {
dateRangeText.setValue(popup.getDateRangeText());
dateRangeText.setVisible(true);
if (getPage() != null)
LayoutUtils.positionComponent(popupBtn, dateRangeText, "start_before");
}
} else {
dateRangeText.setValue("");
dateRangeText.setVisible(false);
}
}
/**
* Set/Remove Mandatory Style
* @param applyStyle
*/
public void setFieldMandatoryStyle() {
if (isMandatoryStyle())
LayoutUtils.addSclass("idempiere-mandatory", textbox);
else
LayoutUtils.removeSclass("idempiere-mandatory", textbox);
}
private boolean isMandatoryStyle() {
return (editor.isMandatory() && editor.isReadWrite() && editor.getGridField().isEditable(true) && isNullOrEmpty(editor))
|| (editor2.isMandatory() && editor2.isReadWrite() && editor2.getGridField().isEditable(true) && isNullOrEmpty(editor2));
}
private boolean isNullOrEmpty(WEditor editor) {
Object value = editor.getValue();
return Util.isEmpty(Objects.toString(value, ""), true);
}
/**
* Set Read Only
* @param readOnly
*/
public void setReadOnly(boolean readOnly) {
popupBtn.setDisabled(readOnly);
if(readOnly)
textbox.setStyle("width: 100%;");
else
textbox.setStyle("width: 100%; background: white !important");
}
@Override
public void onPageAttached(Page newpage, Page oldpage) {
super.onPageAttached(newpage, oldpage);
if (newpage != null && dateRangeText.isVisible() && !Util.isEmpty(dateRangeText.getValue())) {
LayoutUtils.positionComponent(popupBtn, dateRangeText, "start_before");
}
}
}

View File

@ -112,17 +112,28 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
private Tabpanel toTabPanel;
private Div midDiv;
/** date editor from **/
private WEditor editor;
/** date editor to **/
private WEditor editor2;
/** value of date from **/
private Date dateFrom;
/** value of date to **/
private Date dateTo;
private Date oldValueFrom;
private Date oldValueTo;
/** current/new display value **/
private String displayValue;
/** old display value **/
private String oldDisplayValue = "";
/** if true, react to value change event from {@link #editor} and {@link #editor2} **/
private boolean enableValueChange = true;
/** is mobile version **/
private boolean isMobile = ClientInfo.isMobile() && ClientInfo.maxWidth(ClientInfo.SMALL_WIDTH-1);
/** registered value change listeners **/
protected ArrayList<ValueChangeListener> listeners = new ArrayList<ValueChangeListener>();
/** rendered list boxes on 'Quick' mode **/
private ArrayList<Listbox> quickListBoxesArray = new ArrayList<Listbox>();
/** selected list item from the list boxes on 'Quick' mode **/
private ListItem selectedQuickListItem;
/**
@ -143,7 +154,6 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
Div div = new Div();
okBtn = ButtonFactory.createNamedButton("ApplyFilter", true, false);
okBtn.setStyle("color: white; background: #A9A9A9;");
modeCombobox = new Combobox();
modeCombobox.setSclass("date-picker-component");
@ -200,14 +210,13 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
if(dateFrom != null && dateTo != null && dateTo.before(dateFrom))
throw new WrongValueException(dateTextBox, Msg.getMsg(Env.getCtx(), "EndDateAfterStartDate"));
if(Util.isEmpty(dateTextBox.getValue())) {
oldValueFrom = dateFrom;
oldValueTo = dateTo;
dateFrom = null;
dateTo = null;
}
enableValueChange = false;
editor.setValue(dateFrom);
editor2.setValue(dateTo);
fireValueChange(new ValueChangeEvent(this,"DateRangePicker",oldDisplayValue, displayValue));
enableValueChange = true;
this.detach();
});
@ -314,6 +323,7 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
String selectedMode = modeCombobox.getSelectedItem().getValue().toString();
if(selectedMode.equalsIgnoreCase(DATESELECTIONMODE_BETWEEN) && isMobile) {
updateCal1AndCal2();
cal.detach();
fromTabPanel.appendChild(cal);
cal2.detach();
@ -409,6 +419,13 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
displayValue = dateTextBoxValue;
}
/**
* @return date range text, for e.g "01/01/2023 - 01/31/2023"
*/
public String getDateRangeText() {
return dateTextBox.getValue();
}
private String getDateTextBoxValue() {
String returnVal = "";
Date[] dates;
@ -424,8 +441,6 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
break;
case DATESELECTIONMODE_BETWEEN:
returnVal = DisplayType.getDateFormat().format(cal.getValue()) + " - " + DisplayType.getDateFormat().format(cal2.getValue());
oldValueFrom = dateFrom;
oldValueTo = dateTo;
dateFrom = new Timestamp(cal.getValue().getTime());
dateTo = new Timestamp(cal2.getValue().getTime());
dates = setTimesOnDates(dateFrom, dateTo);
@ -438,8 +453,6 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
int offset = (int) selectedQuickListItem.getAttribute("Offset");
Date dateFrom = (Date) selectedQuickListItem.getAttribute("DateFrom");
dates = getInterval(unit, unit, offset, false, false, dateFrom);
this.oldValueFrom = this.dateFrom;
this.oldValueTo = this.dateTo;
this.dateFrom = new Timestamp(dates[0].getTime());
this.dateTo = new Timestamp(dates[1].getTime());
dates = setTimesOnDates(dateFrom, dateTo);
@ -490,6 +503,11 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
}
int numBoxValue = Math.abs(detectedOffset) >= 1 ? Math.abs(detectedOffset) : 1;
numberBox.setValue(numBoxValue);
updateCal1AndCal2();
setDateTextBoxAndDisplayValue();
}
private void updateCal1AndCal2() {
if(dateFrom == null) {
cal.setValue(dateTo);
cal2.setValue(dateTo);
@ -502,7 +520,6 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
cal.setValue(dateFrom);
cal2.setValue(dateTo);
}
setDateTextBoxAndDisplayValue();
}
private String autodetectMode(Timestamp today) {
@ -567,15 +584,11 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
}
else if(calendar.get(Calendar.DAY_OF_MONTH) == 1 &&
calendar2.get(Calendar.DAY_OF_MONTH) == calendar2.getActualMaximum(Calendar.DAY_OF_MONTH)) {
if((calendar.get(Calendar.MONTH) == Calendar.JANUARY ||
calendar.get(Calendar.MONTH) == Calendar.APRIL ||
calendar.get(Calendar.MONTH) == Calendar.JULY ||
calendar.get(Calendar.MONTH) == Calendar.OCTOBER) &&
(calendar2.get(Calendar.MONTH) == Calendar.MARCH ||
calendar2.get(Calendar.MONTH) == Calendar.JUNE ||
calendar2.get(Calendar.MONTH) == Calendar.SEPTEMBER ||
calendar2.get(Calendar.MONTH) == Calendar.DECEMBER) &&
(calendar.get(Calendar.MONTH) != calendar2.get(Calendar.MONTH)))
if((calendar.get(Calendar.MONTH) == Calendar.JANUARY && calendar2.get(Calendar.MONTH) == Calendar.MARCH ) ||
(calendar.get(Calendar.MONTH) == Calendar.APRIL && calendar2.get(Calendar.MONTH) == Calendar.JUNE) ||
(calendar.get(Calendar.MONTH) == Calendar.JULY && calendar2.get(Calendar.MONTH) == Calendar.SEPTEMBER) ||
(calendar.get(Calendar.MONTH) == Calendar.OCTOBER && calendar2.get(Calendar.MONTH) == Calendar.DECEMBER) &&
(calendar.get(Calendar.MONTH) != calendar2.get(Calendar.MONTH) && calendar.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR)))
detectedUnit = MChart.TIMEUNIT_Quarter;
else
detectedUnit = MChart.TIMEUNIT_Month;
@ -610,6 +623,20 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
correctedMode = DATESELECTIONMODE_BETWEEN;
}
//re-validate current month detection
if (detectedUnit == MChart.TIMEUNIT_Month ) {
if (correctedMode.equalsIgnoreCase(DATESELECTIONMODE_CURRENT)) {
if (calendar.get(Calendar.MONTH) != calendar2.get(Calendar.MONTH) || calendar.get(Calendar.YEAR) != calendar2.get(Calendar.YEAR)) {
detectedUnit = MChart.TIMEUNIT_Day;
correctedMode = DATESELECTIONMODE_BETWEEN;
} else if (calendar.get(Calendar.MONTH) != calendarToday.get(Calendar.MONTH)
|| calendar.get(Calendar.YEAR) != calendarToday.get(Calendar.YEAR)) {
detectedUnit = MChart.TIMEUNIT_Day;
correctedMode = DATESELECTIONMODE_BETWEEN;
}
}
}
return new String[] {detectedUnit, correctedMode};
}
@ -654,8 +681,6 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
if(mode.equalsIgnoreCase(DATESELECTIONMODE_AFTER)) {
displayValue = Msg.getMsg(Env.getCtx(), "AfterDate", new Object[] {DisplayType.getDateFormat().format(ts)});
oldValueFrom = dateFrom;
oldValueTo = dateTo;
dateFrom = ts;
dateFrom = setTimesOnDates(dateFrom, null)[0];
dateTo = null;
@ -663,8 +688,6 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
}
else if(mode.equalsIgnoreCase(DATESELECTIONMODE_BEFORE)) {
displayValue = Msg.getMsg(Env.getCtx(), "BeforeDate", new Object[] {DisplayType.getDateFormat().format(ts)});
oldValueFrom = dateFrom;
oldValueTo = dateTo;
dateFrom = null;
dateTo = ts;
dateTo = setTimesOnDates(null, dateTo)[1];
@ -672,8 +695,6 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
}
else if(mode.equalsIgnoreCase(DATESELECTIONMODE_ON)) {
displayValue = Msg.getMsg(Env.getCtx(), "OnDate", new Object[] {DisplayType.getDateFormat().format(ts)});
oldValueFrom = dateFrom;
oldValueTo = dateTo;
dateFrom = ts;
dateTo = ts;
dates = setTimesOnDates(dateFrom, dateTo);
@ -690,8 +711,6 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
else
dates = getInterval(unit, numBoxValue.intValue());
oldValueFrom = dateFrom;
oldValueTo = dateTo;
dateFrom = new Timestamp(dates[0].getTime());
dateTo = new Timestamp(dates[1].getTime());
dates = setTimesOnDates(dateFrom, dateTo);
@ -998,54 +1017,6 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
return div;
}
/**
* Get Date Textbox
* @return Textbox
*/
public Textbox getDateTextbox() {
return dateTextBox;
}
/**
* Get Update Button
* @return Button
*/
public Button getUpdateButton() {
return okBtn;
}
/**
* Get Value From
* @return
*/
public Date getValueFrom() {
return dateFrom;
}
/**
* Get Old Value From
* @return
*/
public Date getOldValueFrom() {
return oldValueFrom;
}
/**
* Get Value To
* @return
*/
public Date getValueTo() {
return dateTo;
}
/**
* Get Old Value To
* @return
*/
public Date getOldValueTo() {
return oldValueTo;
}
/**
* Get Display Value
* @return String
@ -1054,6 +1025,44 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
return this.displayValue;
}
/**
* Add value change listener
* @param listener
*/
public void addValueChangeListener(ValueChangeListener listener)
{
if (listener == null)
return;
if (!listeners.contains(listener))
listeners.add(listener);
}
/**
* Remove value change listener
* @param listener
* @return true if the class had the specified listener
*/
public boolean removeValuechangeListener(ValueChangeListener listener)
{
return listeners.remove(listener);
}
/**
* Fire value change event
* @param event
*/
protected void fireValueChange(ValueChangeEvent event)
{
//copy to array to avoid concurrent modification exception
ValueChangeListener[] vcl = new ValueChangeListener[listeners.size()];
listeners.toArray(vcl);
for (ValueChangeListener listener : vcl)
{
listener.valueChange(event);
}
}
@Override
public void valueChange(ValueChangeEvent evt) {
if(enableValueChange) {
@ -1073,6 +1082,7 @@ public class DateRangePicker extends Popup implements EventListener<Event>, Valu
dateTo = dates[1];
}
updateUI();
fireValueChange(new ValueChangeEvent(this,"DateRangePicker",oldDisplayValue, displayValue));
}
}
}
}

View File

@ -153,3 +153,9 @@ input[type="checkbox"]:focus
font-weight: bold;
margin: 5px;
}
.date-picker-calendar-button {
position: absolute;
right: 0px;
top: 5px;
}