IDEMPIERE-5644 : Allow to set an image per form (#1751)

* IDEMPIERE-5644 : Allow to set an image per form

https://idempiere.atlassian.net/browse/IDEMPIERE-5644

* IDEMPIERE-5644 : Allow to set an image per form - fix suggested by hengsin

Co-Authored-By: hengsin <152246+hengsin@users.noreply.github.com>

---------

Co-authored-by: hengsin <152246+hengsin@users.noreply.github.com>
This commit is contained in:
Nicolas Micoud 2023-03-27 12:26:20 +02:00 committed by GitHub
parent 0dbba5a3c8
commit 59069f4cfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 127 additions and 11 deletions

View File

@ -0,0 +1,26 @@
-- IDEMPIERE-5644
SELECT register_migration_script('202303241449_IDEMPIERE-5644.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Mar 24, 2023, 2:49:11 PM CET
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,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 (215794,0,'Image URL','URL of image','URL of image; The image is not stored in the database, but retrieved at runtime. The image can be a gif, jpeg or png.',376,'ImageURL',120,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_TIMESTAMP('2023-03-24 14:49:10','YYYY-MM-DD HH24:MI:SS'),10,TO_TIMESTAMP('2023-03-24 14:49:10','YYYY-MM-DD HH24:MI:SS'),10,1720,'N','N','D','N','N','N','Y','e40c4dbe-eb3d-4698-9b63-2549c8723366','Y',0,'N','N','N')
;
-- Mar 24, 2023, 2:49:20 PM CET
ALTER TABLE AD_Form ADD ImageURL VARCHAR2(120 CHAR) DEFAULT NULL
;
-- Mar 24, 2023, 2:49:32 PM CET
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,ColumnSpan) VALUES (207581,'Image URL','URL of image','URL of image; The image is not stored in the database, but retrieved at runtime. The image can be a gif, jpeg or png.',302,215794,'Y',120,120,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2023-03-24 14:49:31','YYYY-MM-DD HH24:MI:SS'),10,TO_TIMESTAMP('2023-03-24 14:49:31','YYYY-MM-DD HH24:MI:SS'),10,'N','Y','D','552aebfc-40bb-458a-83dd-f157003ef60c','Y',110,5)
;
-- Mar 24, 2023, 2:49:41 PM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=120, XPosition=4, ColumnSpan=2,Updated=TO_TIMESTAMP('2023-03-24 14:49:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=10 WHERE AD_Field_ID=207581
;
-- Mar 24, 2023, 2:53:50 PM CET
UPDATE AD_Column SET IsUpdateable='Y',Updated=TO_TIMESTAMP('2023-03-24 14:53:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=215794
;

View File

@ -0,0 +1,23 @@
-- IDEMPIERE-5644
SELECT register_migration_script('202303241449_IDEMPIERE-5644.sql') FROM dual;
-- Mar 24, 2023, 2:49:11 PM CET
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,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 (215794,0,'Image URL','URL of image','URL of image; The image is not stored in the database, but retrieved at runtime. The image can be a gif, jpeg or png.',376,'ImageURL',120,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_TIMESTAMP('2023-03-24 14:49:10','YYYY-MM-DD HH24:MI:SS'),10,TO_TIMESTAMP('2023-03-24 14:49:10','YYYY-MM-DD HH24:MI:SS'),10,1720,'N','N','D','N','N','N','Y','e40c4dbe-eb3d-4698-9b63-2549c8723366','Y',0,'N','N','N')
;
-- Mar 24, 2023, 2:49:20 PM CET
ALTER TABLE AD_Form ADD COLUMN ImageURL VARCHAR(120) DEFAULT NULL
;
-- Mar 24, 2023, 2:49:32 PM CET
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,ColumnSpan) VALUES (207581,'Image URL','URL of image','URL of image; The image is not stored in the database, but retrieved at runtime. The image can be a gif, jpeg or png.',302,215794,'Y',120,120,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2023-03-24 14:49:31','YYYY-MM-DD HH24:MI:SS'),10,TO_TIMESTAMP('2023-03-24 14:49:31','YYYY-MM-DD HH24:MI:SS'),10,'N','Y','D','552aebfc-40bb-458a-83dd-f157003ef60c','Y',110,5)
;
-- Mar 24, 2023, 2:49:41 PM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=120, XPosition=4, ColumnSpan=2,Updated=TO_TIMESTAMP('2023-03-24 14:49:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=10 WHERE AD_Field_ID=207581
;
-- Mar 24, 2023, 2:53:50 PM CET
UPDATE AD_Column SET IsUpdateable='Y',Updated=TO_TIMESTAMP('2023-03-24 14:53:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=215794
;

View File

@ -22,7 +22,7 @@ import org.compiere.util.KeyNamePair;
/** Generated Interface for AD_Form
* @author iDempiere (generated)
* @version Release 10
* @version Release 11
*/
public interface I_AD_Form
{
@ -178,6 +178,19 @@ public interface I_AD_Form
*/
public String getHelp();
/** Column name ImageURL */
public static final String COLUMNNAME_ImageURL = "ImageURL";
/** Set Image URL.
* URL of image
*/
public void setImageURL (String ImageURL);
/** Get Image URL.
* URL of image
*/
public String getImageURL();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";

View File

@ -22,16 +22,16 @@ import java.util.Properties;
import org.compiere.util.KeyNamePair;
/** Generated Model for AD_Form
* @author iDempiere (generated)
* @version Release 10 - $Id$ */
* @author iDempiere (generated)
* @version Release 11 - $Id$ */
@org.adempiere.base.Model(table="AD_Form")
public class X_AD_Form extends PO implements I_AD_Form, I_Persistent
public class X_AD_Form extends PO implements I_AD_Form, I_Persistent
{
/**
*
*/
private static final long serialVersionUID = 20221224L;
private static final long serialVersionUID = 20230324L;
/** Standard Constructor */
public X_AD_Form (Properties ctx, int AD_Form_ID, String trxName)
@ -63,6 +63,36 @@ public class X_AD_Form extends PO implements I_AD_Form, I_Persistent
} */
}
/** Standard Constructor */
public X_AD_Form (Properties ctx, String AD_Form_UU, String trxName)
{
super (ctx, AD_Form_UU, trxName);
/** if (AD_Form_UU == null)
{
setAccessLevel (null);
setAD_Form_ID (0);
setEntityType (null);
// @SQL=SELECT CASE WHEN '@P|AdempiereSys:N@'='Y' THEN 'D' ELSE get_sysconfig('DEFAULT_ENTITYTYPE','U',0,0) END FROM Dual
setIsBetaFunctionality (false);
setName (null);
} */
}
/** Standard Constructor */
public X_AD_Form (Properties ctx, String AD_Form_UU, String trxName, String ... virtualColumns)
{
super (ctx, AD_Form_UU, trxName, virtualColumns);
/** if (AD_Form_UU == null)
{
setAccessLevel (null);
setAD_Form_ID (0);
setEntityType (null);
// @SQL=SELECT CASE WHEN '@P|AdempiereSys:N@'='Y' THEN 'D' ELSE get_sysconfig('DEFAULT_ENTITYTYPE','U',0,0) END FROM Dual
setIsBetaFunctionality (false);
setName (null);
} */
}
/** Load Constructor */
public X_AD_Form (Properties ctx, ResultSet rs, String trxName)
{
@ -70,7 +100,7 @@ public class X_AD_Form extends PO implements I_AD_Form, I_Persistent
}
/** AccessLevel
* @return 4 - System
* @return 4 - System
*/
protected int get_AccessLevel()
{
@ -253,6 +283,22 @@ public class X_AD_Form extends PO implements I_AD_Form, I_Persistent
return (String)get_Value(COLUMNNAME_Help);
}
/** Set Image URL.
@param ImageURL URL of image
*/
public void setImageURL (String ImageURL)
{
set_ValueNoCheck (COLUMNNAME_ImageURL, ImageURL);
}
/** Get Image URL.
@return URL of image
*/
public String getImageURL()
{
return (String)get_Value(COLUMNNAME_ImageURL);
}
/** Set Beta Functionality.
@param IsBetaFunctionality This functionality is considered Beta
*/
@ -267,10 +313,10 @@ public class X_AD_Form extends PO implements I_AD_Form, I_Persistent
public boolean isBetaFunctionality()
{
Object oo = get_Value(COLUMNNAME_IsBetaFunctionality);
if (oo != null)
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
@ -311,7 +357,7 @@ public class X_AD_Form extends PO implements I_AD_Form, I_Persistent
/** Get Record ID/ColumnName
@return ID/ColumnName pair
*/
public KeyNamePair getKeyNamePair()
public KeyNamePair getKeyNamePair()
{
return new KeyNamePair(get_ID(), getName());
}

View File

@ -25,6 +25,7 @@ import org.adempiere.webui.adwindow.ADWindow;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ManageImageCache;
import org.compiere.model.MForm;
import org.compiere.model.MImage;
import org.compiere.model.MInfoWindow;
import org.compiere.model.MUserDefInfo;
@ -155,6 +156,12 @@ public class Tab extends org.zkoss.zul.Tab
}
return null;
}
public static DecorateInfo get(MForm form){
if (form != null && !Util.isEmpty(form.getImageURL(), true))
return new DecorateInfo(form.getImageURL());
return null;
}
}
/**

View File

@ -33,6 +33,7 @@ import org.adempiere.webui.part.WindowContainer;
import org.adempiere.webui.util.ZKUpdateUtil;
import org.adempiere.webui.window.Dialog;
import org.adempiere.webui.window.WTask;
import org.compiere.model.MForm;
import org.compiere.model.MInfoWindow;
import org.compiere.model.MQuery;
import org.compiere.model.MTask;
@ -95,7 +96,7 @@ public abstract class TabbedDesktop extends AbstractDesktop {
//do not show window title when open as tab
form.setTitle(null);
preOpenNewTab();
windowContainer.addWindow(tabPanel, form.getFormName(), true, null);
windowContainer.addWindow(tabPanel, form.getFormName(), true, DecorateInfo.get(MForm.get(formId)));
form.focus();
} else {
form.setAttribute(Window.MODE_KEY, form.getWindowMode());