IDEMPIERE-1973:Info Window - parameters - field Mandatory Logic missing

This commit is contained in:
hieplq 2014-06-11 10:50:58 +07:00
parent 0a2d49f857
commit 80c39dce09
7 changed files with 257 additions and 4 deletions

View File

@ -0,0 +1,75 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- May 30, 2014 10:02:41 PM ICT
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES (0,'N',0,211273,'N','N','N',0,'N',1,'N','N','N','Y','bf98ee02-ec0f-4279-8577-11b8d267c7a7','Y','IsMandatory','Data entry is required in this column','N','The field must have a value for the record to be saved to the database.','Mandatory','Y',TO_DATE('2014-05-30 22:02:40','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-05-30 22:02:40','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N',392,20,897)
;
-- May 30, 2014 10:02:47 PM ICT
ALTER TABLE AD_InfoColumn ADD IsMandatory CHAR(1) DEFAULT 'N' CHECK (IsMandatory IN ('Y','N'))
;
-- May 30, 2014 10:02:56 PM ICT
UPDATE AD_Column SET IsMandatory='Y',Updated=TO_DATE('2014-05-30 22:02:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=211273
;
-- May 30, 2014 10:05:01 PM ICT
INSERT INTO AD_Field (SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES (0,'N',844,0,'N','N',250,'Y',203049,'N','The field must have a value for the record to be saved to the database.','Data entry is required in this column','Mandatory','0a2c4d46-748b-4451-988b-d9f6931ed62d','Y','N',100,0,100,TO_DATE('2014-05-30 22:05:00','YYYY-MM-DD HH24:MI:SS'),'Y','Y',160,1,'N',0,1,1,'N','N',211273,'D',TO_DATE('2014-05-30 22:05:00','YYYY-MM-DD HH24:MI:SS'))
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=150, IsDisplayed='Y', XPosition=2, ColumnSpan=2,Updated=TO_DATE('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203049
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=160, IsDisplayed='Y', XPosition=4,Updated=TO_DATE('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201719
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=170, IsDisplayed='Y', XPosition=7, ColumnSpan=2,Updated=TO_DATE('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201720
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=180,Updated=TO_DATE('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201625
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=190,Updated=TO_DATE('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203048
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=200,Updated=TO_DATE('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201635
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=210,Updated=TO_DATE('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201636
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=220,Updated=TO_DATE('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=13603
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=230,Updated=TO_DATE('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201622
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=240,Updated=TO_DATE('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201623
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=250,Updated=TO_DATE('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=13597
;
UPDATE ad_infocolumn SET ismandatory = 'N'
;
ALTER TABLE ad_infocolumn ALTER COLUMN ismandatory SET NOT NULL
;
-- Jun 11, 2014 8:59:36 AM ICT
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Field SET DisplayLogic='@IsQueryCriteria@=Y',Updated=TO_DATE('2014-06-11 08:59:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203049
;
SELECT register_migration_script('201405301604_IDEMPIERE-1973.sql') FROM dual
;

View File

@ -0,0 +1,71 @@
-- May 30, 2014 10:02:41 PM ICT
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES (0,'N',0,211273,'N','N','N',0,'N',1,'N','N','N','Y','bf98ee02-ec0f-4279-8577-11b8d267c7a7','Y','IsMandatory','Data entry is required in this column','N','The field must have a value for the record to be saved to the database.','Mandatory','Y',TO_TIMESTAMP('2014-05-30 22:02:40','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-05-30 22:02:40','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N',392,20,897)
;
-- May 30, 2014 10:02:47 PM ICT
ALTER TABLE AD_InfoColumn ADD COLUMN IsMandatory CHAR(1) DEFAULT 'N' CHECK (IsMandatory IN ('Y','N'))
;
-- May 30, 2014 10:02:56 PM ICT
UPDATE AD_Column SET IsMandatory='Y',Updated=TO_TIMESTAMP('2014-05-30 22:02:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=211273
;
-- May 30, 2014 10:05:01 PM ICT
INSERT INTO AD_Field (SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,Created) VALUES (0,'N',844,0,'N','N',250,'Y',203049,'N','The field must have a value for the record to be saved to the database.','Data entry is required in this column','Mandatory','0a2c4d46-748b-4451-988b-d9f6931ed62d','Y','N',100,0,100,TO_TIMESTAMP('2014-05-30 22:05:00','YYYY-MM-DD HH24:MI:SS'),'Y','Y',160,1,'N',0,1,1,'N','N',211273,'D',TO_TIMESTAMP('2014-05-30 22:05:00','YYYY-MM-DD HH24:MI:SS'))
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=150, IsDisplayed='Y', XPosition=2, ColumnSpan=2,Updated=TO_TIMESTAMP('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203049
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=160, IsDisplayed='Y', XPosition=4,Updated=TO_TIMESTAMP('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201719
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=170, IsDisplayed='Y', XPosition=7, ColumnSpan=2,Updated=TO_TIMESTAMP('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201720
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=180,Updated=TO_TIMESTAMP('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201625
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=190,Updated=TO_TIMESTAMP('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203048
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=200,Updated=TO_TIMESTAMP('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201635
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=210,Updated=TO_TIMESTAMP('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201636
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=220,Updated=TO_TIMESTAMP('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=13603
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=230,Updated=TO_TIMESTAMP('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201622
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=240,Updated=TO_TIMESTAMP('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201623
;
-- May 30, 2014 10:06:40 PM ICT
UPDATE AD_Field SET SeqNo=250,Updated=TO_TIMESTAMP('2014-05-30 22:06:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=13597
;
UPDATE ad_infocolumn SET ismandatory = 'N'
;
ALTER TABLE ad_infocolumn ALTER COLUMN ismandatory SET NOT NULL
;
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Field SET DisplayLogic='@IsQueryCriteria@=Y',Updated=TO_TIMESTAMP('2014-06-11 08:59:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203049
;
SELECT register_migration_script('201405301604_IDEMPIERE-1973.sql') FROM dual
;

View File

@ -309,6 +309,19 @@ public interface I_AD_InfoColumn
*/
public boolean isIdentifier();
/** Column name IsMandatory */
public static final String COLUMNNAME_IsMandatory = "IsMandatory";
/** Set Mandatory.
* Data entry is required in this column
*/
public void setIsMandatory (boolean IsMandatory);
/** Get Mandatory.
* Data entry is required in this column
*/
public boolean isMandatory();
/** Column name IsQueryCriteria */
public static final String COLUMNNAME_IsQueryCriteria = "IsQueryCriteria";

View File

@ -30,7 +30,7 @@ public class X_AD_InfoColumn extends PO implements I_AD_InfoColumn, I_Persistent
/**
*
*/
private static final long serialVersionUID = 20140529L;
private static final long serialVersionUID = 20140530L;
/** Standard Constructor */
public X_AD_InfoColumn (Properties ctx, int AD_InfoColumn_ID, String trxName)
@ -49,6 +49,8 @@ public class X_AD_InfoColumn extends PO implements I_AD_InfoColumn, I_Persistent
setIsDisplayed (true);
// Y
setIsIdentifier (false);
// N
setIsMandatory (false);
// N
setIsQueryCriteria (false);
setName (null);
@ -440,6 +442,30 @@ public class X_AD_InfoColumn extends PO implements I_AD_InfoColumn, I_Persistent
return false;
}
/** Set Mandatory.
@param IsMandatory
Data entry is required in this column
*/
public void setIsMandatory (boolean IsMandatory)
{
set_Value (COLUMNNAME_IsMandatory, Boolean.valueOf(IsMandatory));
}
/** Get Mandatory.
@return Data entry is required in this column
*/
public boolean isMandatory ()
{
Object oo = get_Value(COLUMNNAME_IsMandatory);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Query Criteria.
@param IsQueryCriteria
The column is also used as a query criteria

View File

@ -141,6 +141,8 @@ public class InfoProductWindow extends InfoWindow {
super.createParameterPanel();
initParameters();
dynamicDisplay(null);
// update display of mandatory field
validateParameters();
}
@Override

View File

@ -369,9 +369,11 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
gridFields = new ArrayList<GridField>();
for(MInfoColumn infoColumn : infoColumns) {
String columnName = infoColumn.getColumnName();
/*!m_lookup && infoColumn.isMandatory():apply Mandatory only case open as window and only for criteria field*/
boolean isMandatory = !m_lookup && infoColumn.isMandatory() && infoColumn.isQueryCriteria();
GridFieldVO vo = GridFieldVO.createParameter(infoContext, p_WindowNo, 0,
columnName, infoColumn.get_Translation("Name"), infoColumn.getAD_Reference_ID(),
infoColumn.getAD_Reference_Value_ID(), false, false);
infoColumn.getAD_Reference_Value_ID(), isMandatory, false);
if (infoColumn.getAD_Val_Rule_ID() > 0) {
vo.ValidationCode = infoColumn.getAD_Val_Rule().getCode();
if (vo.lookupInfo != null) {
@ -1016,7 +1018,6 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
else
{
editor = WebEditorFactory.getEditor(mField, false);
editor.setMandatory(false);
editor.setReadWrite(true);
editor.dynamicDisplay();
editor.addValueChangeListener(this);
@ -1082,7 +1083,13 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
}
if (!(fieldEditor instanceof Checkbox))
{
panel.appendChild(label.rightAlign());
Div div = new Div();
div.setStyle("text-align: right;");
div.appendChild(label);
if (label.getDecorator() != null){
div.appendChild (label.getDecorator());
}
panel.appendChild(div);
} else {
panel.appendChild(new Space());
}
@ -1225,6 +1232,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
}
protected void dynamicDisplay(WEditor editor) {
validateField(editor);
// if attribute set changed (from any value to any value) clear the attribute set instance m_pAttributeWhere
boolean asiChanged = false;
if (editor != null && editor instanceof WTableDirEditor && editor.getColumnName().equals("M_AttributeSet_ID"))
@ -1594,4 +1602,51 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
return data;
}
/**
* {@inheritDoc}
* eval input value of mandatory field, if null show field in red color
*/
@Override
public boolean validateParameters() {
boolean isValid = true;
for (int i = 0; i < editors.size(); i++){
WEditor wEditor = (WEditor) editors.get(i);
// cancel editor not display
if (wEditor == null || !wEditor.isVisible() || wEditor.getGridField() == null){
continue;
}
isValid = isValid & validateField (wEditor);
}
return isValid;
}
/**
* valid mandatory of a not null, display field
* display red color when a mandatory field is not input
* @param wEditor
* @return
*/
protected boolean validateField (WEditor wEditor){
if (wEditor == null || !wEditor.isVisible() || wEditor.getGridField() == null){
return true;
}
GridField validateGrid = wEditor.getGridField();
// eval only mandatory field
if (validateGrid.isMandatory(true)){
// update color of field
wEditor.updateLabelStyle();
Object data = wEditor.getValue();
if (data == null || data.toString().length() == 0) {
return false;
}
}
return true;
}
}

View File

@ -32,6 +32,7 @@ import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.logging.Level;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.apps.BusyDialog;
@ -1235,10 +1236,20 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
* Call query when user click to query button enter in parameter field
*/
public void onUserQuery (){
if (validateParameters()){
showBusyDialog();
isQueryByUser = true;
Clients.response(new AuEcho(this, "onQueryCallback", null));
}
}
/**
* validate parameter before run query
* @return
*/
public boolean validateParameters(){
return true;
}
void preRunProcess (Integer processId){
// disable all control button when run process