Skip to content

Commit

Permalink
A completed patch from Christian Carlow for "Replace EditProductAssoc…
Browse files Browse the repository at this point in the history
… 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.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1715755 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
JacquesLeRoux committed Nov 23, 2015
1 parent 8551e8e commit 0b3a656
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 392 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
20 changes: 15 additions & 5 deletions applications/product/webapp/catalog/WEB-INF/controller.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
Loading

0 comments on commit 0b3a656

Please sign in to comment.