svn commit: r1715755 - in /ofbiz/trunk/applications/product: webapp/catalog/WEB-INF/ webapp/catalog/WEB-INF/actions/product/ webapp/catalog/product/ widget/catalog/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1715755 - in /ofbiz/trunk/applications/product: webapp/catalog/WEB-INF/ webapp/catalog/WEB-INF/actions/product/ webapp/catalog/product/ widget/catalog/

jleroux@apache.org
Author: jleroux
Date: Mon Nov 23 10:40:52 2015
New Revision: 1715755

URL: http://svn.apache.org/viewvc?rev=1715755&view=rev
Log:
A completed patch from Christian Carlow for "Replace EditProductAssoc ftl with widgets" https://issues.apache.org/jira/browse/OFBIZ-6320

jleroux:
Added
    bottom note (in both lists now)
    title="${uiLabelMap.ProductProductId}"
    title="${uiLabelMap.ProductProductIdTo}"
    fromDate <date-time default-value="${nowTimestamp}"
    tooltip="${uiLabelMap.ProductRecreateAssociation}"    
Removed
    EditProductAssoc.ftl
    old screen with ftl ref in screen (commented out by Christian)
    UNUSED FORMS comment
    Product column when same than picked (depend on iterate-section)

I liked the idea of changing the main product using a lookup in edit part.

Removed:
    ofbiz/trunk/applications/product/webapp/catalog/product/EditProductAssoc.ftl
Modified:
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductAssoc.groovy
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
    ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml
    ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductAssoc.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductAssoc.groovy?rev=1715755&r1=1715754&r2=1715755&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductAssoc.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductAssoc.groovy Mon Nov 23 10:40:52 2015
@@ -20,69 +20,22 @@
 import org.ofbiz.entity.*
 import org.ofbiz.base.util.*
 
-context.nowDate = UtilDateTime.nowDate();
-context.nowTimestampString = UtilDateTime.nowTimestamp().toString();
+uiLabelMap = UtilProperties.getResourceBundleMap("ProductUiLabels", locale);
 
-useValues = true;
-if (request.getAttribute("_ERROR_MESSAGE_")) {
-    useValues = false;
-}
-
-productId = parameters.productId;
-if (!productId) {
-    productId = parameters.PRODUCT_ID;
-} else {
-    context.productId = productId;
-}
+product = from("Product").where("productId", parameters.productId).queryOne();
 
-productIdTo = parameters.PRODUCT_ID_TO;
-if (productIdTo) {
-    context.productIdTo = productIdTo;
+fromDate = UtilDateTime.nowTimestamp();
+if (UtilValidate.isNotEmpty(parameters.fromDate)) {
+    fromDate = ObjectType.simpleTypeConvert(parameters.fromDate, "Timestamp", null, timeZone, locale, false);
 }
 
-productAssocTypeId = parameters.PRODUCT_ASSOC_TYPE_ID;
-if (productAssocTypeId != null) {
-    context.productAssocTypeId = productAssocTypeId;
-}
-
-fromDateStr = parameters.FROM_DATE;
+productAssoc = from("ProductAssoc").where("productId", parameters.productId, "productIdTo", parameters.productIdTo, "productAssocTypeId", parameters.productAssocTypeId, "fromDate", fromDate).queryOne();
+context.productAssoc = productAssoc;
 
-fromDate = null;
-if (UtilValidate.isNotEmpty(fromDateStr)) {
-    fromDate = ObjectType.simpleTypeConvert(fromDateStr, "Timestamp", null, timeZone, locale, false);
-}
-if (!fromDate) {
-    fromDate = request.getAttribute("ProductAssocCreateFromDate");
-} else {
-    context.fromDate = fromDate;
-}
-
-product = from("Product").where("productId", productId).queryOne();
 if (product) {
-    context.product = product;
-}
-
-productAssoc = from("ProductAssoc").where("productId", productId, "productIdTo", productIdTo, "productAssocTypeId", productAssocTypeId, "fromDate", fromDate).queryOne();
-if (productAssoc) {
-    context.productAssoc = productAssoc;
-}
-
-if ("true".equalsIgnoreCase(parameters.useValues)) {
-    useValues = true;
-}
-
-if (!productAssoc) {
-    useValues = false;
-}
-
-context.useValues = useValues;
-context.isCreate = true;
-
-assocTypes = from("ProductAssocType").orderBy("description").queryList();
-context.assocTypes = assocTypes;
-
-if (product) {
-    context.assocFromProducts = product.getRelated("MainProductAssoc", null, ['sequenceNum'], false);
-
-    context.assocToProducts = product.getRelated("AssocProductAssoc", null, null, false);
-}
+    assocFromProducts = product.getRelated("MainProductAssoc", null, ['sequenceNum'], false);
+    assocToProducts = product.getRelated("AssocProductAssoc", null, null, false);
+    assocFromMap = ["assocProducts" : assocFromProducts, "sectionTitle" : uiLabelMap.ProductAssociationsFromProduct];
+    assocToMap = ["assocProducts" : assocToProducts, "sectionTitle" : uiLabelMap.ProductAssociationsToProduct];
+    context.assocSections = [assocFromMap, assocToMap];
+}
\ No newline at end of file

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml?rev=1715755&r1=1715754&r2=1715755&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml Mon Nov 23 10:40:52 2015
@@ -822,12 +822,22 @@ under the License.
         <security https="true" auth="true"/>
         <response name="success" type="view" value="EditProductAssoc"/>
     </request-map>
-    <request-map uri="UpdateProductAssoc">
+    <request-map uri="createProductAssoc">
         <security https="true" auth="true"/>
-        <event type="java" path="org.ofbiz.product.product.ProductEvents" invoke="updateProductAssoc"/>
-        <response name="success" type="request-redirect" value="EditProductAssoc">
-            <redirect-parameter name="productId"/>
-        </response>
+        <event type="service" invoke="createProductAssoc"/>
+        <response name="success" type="view" value="EditProductAssoc"/>
+        <response name="error" type="view" value="EditProductAssoc"/>
+    </request-map>
+    <request-map uri="updateProductAssoc">
+        <security https="true" auth="true"/>
+        <event type="service" invoke="updateProductAssoc"/>
+        <response name="success" type="view" value="EditProductAssoc"/>
+        <response name="error" type="view" value="EditProductAssoc"/>
+    </request-map>
+    <request-map uri="deleteProductAssoc">
+        <security https="true" auth="true"/>
+        <event type="service" invoke="deleteProductAssoc"/>
+        <response name="success" type="view" value="EditProductAssoc"/>
         <response name="error" type="view" value="EditProductAssoc"/>
     </request-map>
 

Modified: ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml?rev=1715755&r1=1715754&r2=1715755&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml Mon Nov 23 10:40:52 2015
@@ -1137,29 +1137,94 @@ under the License.
         <field name="submitButton" title="${uiLabelMap.CommonUpdate}" widget-style="smallSubmit"><submit button-type="button"/></field>
     </form>
 
-    <!-- UNUSED FORMS
-    <form name="ListProductAssocs" type="list" use-row-submit="true"  title="" list-name="productAssocs"
-        odd-row-style="alternate-row" default-table-style="basic-table" paginate-target="EditProductAssoc">
-        <auto-fields-entity entity-name="ProductAssoc" default-field-type="display"/>
-        <field name="productId"><hidden/></field>
-        <field name="productIdTo" title="${uiLabelMap.CommonEdit}" widget-style="buttontext">
-            <hyperlink also-hidden="false" description="${productIdTo}" target="EditProduct">
-                <parameter param-name="productId" from-field="productIdTo"/>
-            </hyperlink>
+    <form name="EditProductAssoc" type="single" use-row-submit="true"  title="" default-map-name="productAssoc" target="createProductAssoc"
+         default-table-style="basic-table" paginate-target="EditProductAssoc">
+        <alt-target use-when="productAssoc!=null" target="updateProductAssoc"/>
+        <field name="productId" use-when="productAssoc==null" title="${uiLabelMap.ProductProductId}"><lookup target-form-name="LookupProduct"/></field>
+        <field name="productId" use-when="productAssoc!=null" title="${uiLabelMap.ProductProductId}" tooltip="${uiLabelMap.ProductRecreateAssociation}" ><display/></field>
+        <field name="productIdTo" use-when="productAssoc==null" title="${uiLabelMap.ProductProductIdTo}">
+            <lookup target-form-name="LookupProduct"/>
+        </field>
+        <field name="productIdTo" use-when="productAssoc!=null" title="${uiLabelMap.ProductProductIdTo}" tooltip="${uiLabelMap.ProductRecreateAssociation}"><display/></field>
+        <field name="productAssocTypeId" use-when="productAssoc==null" title="${uiLabelMap.ProductAssociationType}">
+            <drop-down>
+                <entity-options description="${description}" entity-name="ProductAssocType">
+                    <entity-order-by field-name="description"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <field name="productAssocTypeId" use-when="productAssoc!=null" title="${uiLabelMap.ProductAssociationType}" tooltip="${uiLabelMap.ProductRecreateAssociation}"><display/></field>
+        <field name="fromDate" use-when="productAssoc==null" tooltip="${uiLabelMap.CommonSetNowEmpty}"><date-time default-value="${nowTimestamp}"/></field>
+        <field name="fromDate" use-when="productAssoc!=null" tooltip="${uiLabelMap.ProductRecreateAssociation}"><display type="date-time"/></field>
+        <field name="thruDate"><date-time/></field>
+        <field name="sequenceNum"><text size="6"/></field>
+        <field name="reason"><text/></field>
+        <field name="instruction"><text/></field>
+        <field name="quantity"><text size="6" default-value="${quantity}"/></field>
+        <field name="scrapFactor"><hidden/></field>
+        <field name="routingWorkEffortId"><hidden/></field>
+        <field name="estimateCalcMethod"><hidden/></field>
+        <field name="recurrenceInfoId"><hidden/></field>
+        <field name="createButton" use-when="productAssoc == null">
+            <submit/>
+        </field>
+        <field name="updateButton" use-when="productAssoc != null">
+            <submit/>
         </field>
-
     </form>
-    <form name="ListProductAssocsTo" type="list" use-row-submit="true" title="" list-name="productAssocsTo"
+    <form name="ListProductAssocs" type="list" use-row-submit="true"  title="" list-name="assocProducts"
         odd-row-style="alternate-row" default-table-style="basic-table" paginate-target="EditProductAssoc">
-        <auto-fields-entity entity-name="ProductAssoc" default-field-type="display"/>
-        <field name="productIdTo"><hidden/></field>
-        <field name="productId" title="${uiLabelMap.CommonEdit}" widget-style="buttontext">
-            <hyperlink also-hidden="false" description="${productId}" target="EditProduct">
+        <actions>
+            <set field="labelFrom" from-field="uiLabelMap.ProductAssociationsFromProduct"/>
+            <set field="labelTo" from-field="uiLabelMap.ProductAssociationsToProduct"/>
+            <set field="sectionTitle" from-field="assocSection.sectionTitle"/>
+        </actions>
+        <row-actions>
+            <entity-one value-field="product" entity-name="Product">
+                <field-map field-name="productId" value="${parameters.productId}"/>
+            </entity-one>
+        </row-actions>
+        <field name="productId" widget-style="buttontext" ignore-when="sectionTitle.equals(labelFrom)" title="${uiLabelMap.ProductProductId}">
+            <display-entity entity-name="Product" description="${internalName}">
+                <sub-hyperlink description="${productId}" link-style="buttontext" target="EditProductAssoc">
+                    <parameter param-name="productId"/>
+                </sub-hyperlink>
+            </display-entity>
+        </field>
+        <field name="productIdTo" widget-style="buttontext" ignore-when="sectionTitle.equals(labelTo)" title="${uiLabelMap.ProductProductId}">
+            <display-entity entity-name="Product" key-field-name="productId" description="${internalName}">
+                <sub-hyperlink description="${productIdTo}" link-style="buttontext" target="EditProductAssoc">
+                    <parameter param-name="productId" value="${productIdTo}"/>
+                </sub-hyperlink>
+            </display-entity>
+        </field>
+        <field name="productAssocTypeId" title="${uiLabelMap.ProductAssociationType}" >
+            <display-entity entity-name="ProductAssocType"></display-entity>
+        </field>
+        <field name="fromDate"><display/></field>
+        <field name="thruDate"><display/></field>
+        <field name="sequenceNum"><display/></field>
+        <field name="reason"><display/></field>
+        <field name="instruction"><display/></field>
+        <field name="quantity"><display/></field>
+        <field name="editLink" widget-style="buttontext">
+            <hyperlink target="EditProductAssoc" description="${uiLabelMap.CommonEdit}">
+                <parameter param-name="productId"/>
+                <parameter param-name="productIdTo"/>
+                <parameter param-name="productAssocTypeId"/>
+                <parameter param-name="fromDate"/>
+            </hyperlink>
+        </field>
+        <field name="deleteButton" widget-style="buttontext">
+            <hyperlink target="deleteProductAssoc" description="${uiLabelMap.CommonDelete}">
                 <parameter param-name="productId"/>
+                <parameter param-name="productIdTo"/>
+                <parameter param-name="productAssocTypeId"/>
+                <parameter param-name="fromDate"/>
+                <parameter param-name="lastProductId" from-field="parameters.productId"/>
             </hyperlink>
         </field>
     </form>
-    -->
 
     <form name="ListProductComponents" type="list" use-row-submit="true" title="" list-name="components"
         odd-row-style="alternate-row" default-table-style="basic-table" paginate-target="ViewProductManufacturing">

Modified: ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml?rev=1715755&r1=1715754&r2=1715755&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml Mon Nov 23 10:40:52 2015
@@ -986,56 +986,33 @@ under the License.
                 <set field="titleProperty" value="PageTitleEditProductAssociations"/>
                 <set field="tabButtonItem" value="EditProductAssoc"/>
                 <set field="labelTitleProperty" value="ProductAssociations"/>
-
                 <script location="component://product/webapp/catalog/WEB-INF/actions/product/EditProductAssoc.groovy"/>
             </actions>
             <widgets>
                 <decorator-screen name="CommonProductDecorator" location="${parameters.productDecoratorLocation}">
                     <decorator-section name="body">
-                        <container>
+                        <screenlet title="${uiLabelMap.PageTitleEditProductAssociations}">
+                            <include-form name="EditProductAssoc" location="component://product/widget/catalog/ProductForms.xml"/>
+                        </screenlet>
+                        <iterate-section entry="assocSection" list="assocSections">
                             <section>
+                                <actions>
+                                    <set field="assocProducts" from-field="assocSection.assocProducts"/>
+                                </actions>
                                 <widgets>
-                                    <platform-specific>
-                                        <html><html-template location="component://product/webapp/catalog/product/EditProductAssoc.ftl"/></html>
-                                    </platform-specific>
+                                    <screenlet title="${assocSection.sectionTitle}">
+                                        <include-form name="ListProductAssocs" location="component://product/widget/catalog/ProductForms.xml"/>
+                                    </screenlet>
+                                    <label style="tooltip">${uiLabelMap.CommonNote} : ${uiLabelMap.ProductHighlightedExplanation}</label>
                                 </widgets>
                             </section>
-                        </container>
+                        </iterate-section>  
                     </decorator-section>
                 </decorator-screen>
             </widgets>
         </section>
     </screen>
-    <!--
-    <screen name="EditProductAssoc">
-        <section>
-            <actions>
-                <set field="titleProperty" value="PageTitleEditProductAssociations"/>
-                <set field="tabButtonItem" value="EditProductAssoc"/>
-                <set field="labelTitleProperty" value="EditProductAssoc"/>
 
-                <set field="productId" from-field="parameters.productId"/>
-                <entity-one entity-name="Product" value-field="product"/>
-                <entity-and entity-name="ProductAssoc" list-name="productAssocs">
-                    <field-map field-name="productId"/>
-                    <order-by field-name="productAssocTypeId"/>
-                </entity-and>
-                <entity-and entity-name="ProductAssoc" list-name="productAssocsTo">
-                    <field-map from-field="productId" field-name="productIdTo"/>
-                    <order-by field-name="productAssocTypeId"/>
-                </entity-and>
-            </actions>
-            <widgets>
-                <decorator-screen name="CommonProductDecorator" location="${parameters.productDecoratorLocation}">
-                    <decorator-section name="body">
-                        <include-form name="ListProductAssocs" location="component://product/widget/catalog/ProductForms.xml"/>
-                        <include-form name="ListProductAssocsTo" location="component://product/widget/catalog/ProductForms.xml"/>
-                    </decorator-section>
-                </decorator-screen>
-            </widgets>
-        </section>
-    </screen>
-    -->
     <screen name="ApplyFeaturesFromCategory">
         <section>
             <actions>