Implemented selector form item
authorMartin Taal <martin.taal@openbravo.com>
Tue, 04 Jan 2011 19:47:14 +0100
changeset 9553 2077aa2dcf07
parent 9552 fe1d401322eb
child 9554 2cb2e11c6e2f
Implemented selector form item
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/FKSelectorUIDefinition.java
modules/org.openbravo.userinterface.selector/src-db/database/sourcedata/OBCLKER_UIDEFINITION.xml
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorComponent.java
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorComponentProvider.java
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorConstants.java
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/templates/selector-as-link.ftl
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/templates/selector.ftl
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/FKSelectorUIDefinition.java	Tue Jan 04 19:46:08 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2010 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-package org.openbravo.client.kernel.reference;
-
-
-/**
- * Implementation of the foreign key ui definition which uses a selector for its input/filter types.
- * 
- * @author mtaal
- */
-public class FKSelectorUIDefinition extends ForeignKeyUIDefinition {
-}
--- a/modules/org.openbravo.userinterface.selector/src-db/database/sourcedata/OBCLKER_UIDEFINITION.xml	Tue Jan 04 19:46:08 2011 +0100
+++ b/modules/org.openbravo.userinterface.selector/src-db/database/sourcedata/OBCLKER_UIDEFINITION.xml	Tue Jan 04 19:47:14 2011 +0100
@@ -6,7 +6,7 @@
 <!--A687A2E863144EAE8014548E9E6BCF3D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--A687A2E863144EAE8014548E9E6BCF3D-->  <AD_MODULE_ID><![CDATA[5EB4F15C80684ACA904756BDC12ADBE5]]></AD_MODULE_ID>
 <!--A687A2E863144EAE8014548E9E6BCF3D-->  <AD_REFERENCE_ID><![CDATA[80B1630792EA46F298A3FBF81E77EF9C]]></AD_REFERENCE_ID>
-<!--A687A2E863144EAE8014548E9E6BCF3D-->  <CLASSNAME><![CDATA[org.openbravo.client.kernel.reference.FKSelectorUIDefinition]]></CLASSNAME>
+<!--A687A2E863144EAE8014548E9E6BCF3D-->  <CLASSNAME><![CDATA[org.openbravo.userinterface.selector.reference.FKSelectorLinkUIDefinition]]></CLASSNAME>
 <!--A687A2E863144EAE8014548E9E6BCF3D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--A687A2E863144EAE8014548E9E6BCF3D--></OBCLKER_UIDEFINITION>
 
@@ -16,7 +16,7 @@
 <!--A99DF9E8D2CF4C3CB5EC139079E5DC8D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--A99DF9E8D2CF4C3CB5EC139079E5DC8D-->  <AD_MODULE_ID><![CDATA[5EB4F15C80684ACA904756BDC12ADBE5]]></AD_MODULE_ID>
 <!--A99DF9E8D2CF4C3CB5EC139079E5DC8D-->  <AD_REFERENCE_ID><![CDATA[95E2A8B50A254B2AAE6774B8C2F28120]]></AD_REFERENCE_ID>
-<!--A99DF9E8D2CF4C3CB5EC139079E5DC8D-->  <CLASSNAME><![CDATA[org.openbravo.client.kernel.reference.FKSelectorUIDefinition]]></CLASSNAME>
+<!--A99DF9E8D2CF4C3CB5EC139079E5DC8D-->  <CLASSNAME><![CDATA[org.openbravo.userinterface.selector.reference.FKSelectorUIDefinition]]></CLASSNAME>
 <!--A99DF9E8D2CF4C3CB5EC139079E5DC8D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--A99DF9E8D2CF4C3CB5EC139079E5DC8D--></OBCLKER_UIDEFINITION>
 
--- a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorComponent.java	Tue Jan 04 19:46:08 2011 +0100
+++ b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorComponent.java	Tue Jan 04 19:47:14 2011 +0100
@@ -62,6 +62,8 @@
  */
 public class SelectorComponent extends BaseTemplateComponent {
 
+  public static final String SELECTOR_ITEM_PARAMETER = "IsSelectorItem";
+
   private static final String CSSSIZE = "CssSize";
   private static final String ONECELL = "OneCell";
   private static final String TWOCELLS = "TwoCells";
@@ -93,6 +95,10 @@
   @ComponentProvider.Qualifier(DataSourceConstants.DS_COMPONENT_TYPE)
   private ComponentProvider componentProvider;
 
+  public boolean isSelectorItem() {
+    return hasParameter(SELECTOR_ITEM_PARAMETER);
+  }
+
   public Module getModule() {
     return getSelector().getModule();
   }
@@ -163,6 +169,13 @@
     return Boolean.FALSE.toString();
   }
 
+  public String getTargetPropertyName() {
+    if (hasParameter(SelectorConstants.PARAM_TARGET_PROPERTY_NAME)) {
+      return getParameter(SelectorConstants.PARAM_TARGET_PROPERTY_NAME);
+    }
+    return "";
+  }
+
   public String getValueField() {
     if (getSelector().getValuefield() != null) {
       String valueField = getPropertyOrDataSourceField(getSelector().getValuefield());
--- a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorComponentProvider.java	Tue Jan 04 19:46:08 2011 +0100
+++ b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorComponentProvider.java	Tue Jan 04 19:47:14 2011 +0100
@@ -60,6 +60,8 @@
         "web/org.openbravo.userinterface.selector/js/ob-selector-widget.js", true, false));
     resources.add(createStaticResource(
         "web/org.openbravo.userinterface.selector/js/ob-selector-link-widget.js", true, false));
+    resources.add(createStaticResource(
+        "web/org.openbravo.userinterface.selector/js/ob-selector-item.js", false, true));
     return resources;
   }
 
--- a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorConstants.java	Tue Jan 04 19:46:08 2011 +0100
+++ b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorConstants.java	Tue Jan 04 19:47:14 2011 +0100
@@ -33,6 +33,7 @@
   public static final String PARAM_CALLOUT = "callOut";
   public static final String PARAM_TAB_ID = "adTabId";
   public static final String PARAM_COMBO_RELOAD = "comboReload";
+  public static final String PARAM_TARGET_PROPERTY_NAME = "targetProperty";
 
   // Reference definition IDs
   public static final String SELECTOR_REFERENCE_ID = "95E2A8B50A254B2AAE6774B8C2F28120";
--- a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/templates/selector-as-link.ftl	Tue Jan 04 19:46:08 2011 +0100
+++ b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/templates/selector-as-link.ftl	Tue Jan 04 19:47:14 2011 +0100
@@ -11,12 +11,45 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010 Openbravo SLU
+ * All portions are Copyright (C) 2010-2011 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
 */
-
+<#if data.selectorItem>
+    popupTextMatchStyle: '${data.selector.popuptextmatchstyle}',
+    suggestionTextMatchStyle: '${data.selector.suggestiontextmatchstyle}',
+    defaultPopupFilterField : '${data.defaultPopupFilterField}',
+    displayField: '${data.targetPropertyName?js_string}._identifier',
+    valueField: '${data.targetPropertyName?js_string}',
+    gridDisplayField: '${data.displayField?js_string}',
+    gridValueField: '${data.valueField?js_string}',    
+    pickListFields: [
+    <#list data.pickListFields as pickListField>
+        {<#list pickListField.properties as property>
+        ${property.name}: ${property.value}<#if property_has_next>,</#if>
+         </#list>
+        }<#if pickListField_has_next>,</#if>
+    </#list>
+    ],
+    showSelectorGrid: ${data.showSelectorGrid},
+    selectorGridFields : [
+    <#list data.selectorGridFields as selectorGridField>
+        {<#list selectorGridField.properties as property>
+        ${property.name}: ${property.value}<#if property_has_next>,</#if>
+         </#list>
+        }<#if selectorGridField_has_next>,</#if>
+    </#list>
+    ],
+    outFields : {
+    <#list data.outFields as selectorOutField>
+    '${selectorOutField.outFieldName}':'${selectorOutField.tabFieldName}'<#if selectorOutField_has_next>,</#if>
+    </#list>
+    },
+    extraSearchFields: [${data.extraSearchFields}],
+    dataSource: ${data.dataSourceJavascript},
+    whereClause : '${data.whereClause?js_string}'
+<#else>
 /* jslint */
 sc_${data.columnName} = isc.OBSelectorLinkWidget.create({
     popupTextMatchStyle: '${data.selector.popuptextmatchstyle}',
@@ -56,3 +89,4 @@
     callOut: ${data.callOut},
     title : '${data.title}'
 });
+</#if>
--- a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/templates/selector.ftl	Tue Jan 04 19:46:08 2011 +0100
+++ b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/templates/selector.ftl	Tue Jan 04 19:47:14 2011 +0100
@@ -11,12 +11,45 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2009-2010 Openbravo SLU
+ * All portions are Copyright (C) 2009-2011 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
 */
 
+<#if data.selectorItem>
+    selectorDefinitionId: '${data.id}',
+    popupTextMatchStyle: '${data.selector.popuptextmatchstyle}',
+    textMatchStyle: '${data.selector.suggestiontextmatchstyle}',
+    defaultPopupFilterField : '${data.defaultPopupFilterField}',
+    displayField: '${data.displayField?js_string}',
+    valueField: '${data.valueField?js_string}',
+    pickListFields: [
+    <#list data.pickListFields as pickListField>
+        {<#list pickListField.properties as property>
+        ${property.name}: ${property.value}<#if property_has_next>,</#if>
+         </#list>       
+        }<#if pickListField_has_next>,</#if>
+    </#list>
+    ],
+    showSelectorGrid: ${data.showSelectorGrid},
+    selectorGridFields : [
+    <#list data.selectorGridFields as selectorGridField>
+        {<#list selectorGridField.properties as property>
+        ${property.name}: ${property.value}<#if property_has_next>,</#if>
+         </#list>
+        }<#if selectorGridField_has_next>,</#if>
+    </#list>
+    ],
+    outFields : {
+    <#list data.outFields as selectorOutField>
+    '${selectorOutField.outFieldName}':'${selectorOutField.tabFieldName}'<#if selectorOutField_has_next>,</#if>
+    </#list>
+    },
+    extraSearchFields: [${data.extraSearchFields}],
+    optionDataSource: ${data.dataSourceJavascript},
+    whereClause : '${data.whereClause?js_string}'
+<#else>
 /* jslint */
 sc_${data.columnName} = isc.OBSelectorWidget.create({
     selectorDefinitionId: '${data.id}',
@@ -58,3 +91,4 @@
     title : '${data.title}',
     comboReload: ${data.comboReload}
 });
+</#if>
\ No newline at end of file