You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2011/03/25 08:43:19 UTC
svn commit: r1085269 - in /ofbiz/trunk/applications/product:
src/org/ofbiz/product/category/CategoryServices.java
webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy
webapp/catalog/category/CategoryTree.ftl
Author: hansbak
Date: Fri Mar 25 07:43:18 2011
New Revision: 1085269
URL: http://svn.apache.org/viewvc?rev=1085269&view=rev
Log:
update of the category tree in the catalog, which now also works for large trees. IE and blankscreen problems solved. sort by sequencenum, do not show rollup expired dates
Modified:
ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy
ofbiz/trunk/applications/product/webapp/catalog/category/CategoryTree.ftl
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java?rev=1085269&r1=1085268&r2=1085269&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java Fri Mar 25 07:43:18 2011
@@ -406,6 +406,7 @@ public class CategoryServices {
Delegator delegator = (Delegator) request.getAttribute("delegator");
String productCategoryId = request.getParameter("productCategoryId");
String isCatalog = request.getParameter("isCatalog");
+ String isCategoryType = request.getParameter("isCategoryType");
String entityName = null;
String primaryKeyName = null;
@@ -423,14 +424,20 @@ public class CategoryServices {
try {
GenericValue category = delegator.findByPrimaryKey(entityName ,UtilMisc.toMap(primaryKeyName, productCategoryId));
if (UtilValidate.isNotEmpty(category)) {
- if (isCatalog.equals("true")) {
+ if (isCatalog.equals("true") && isCategoryType.equals("false")) {
CategoryWorker.getRelatedCategories(request, "ChildCatalogList", CatalogWorker.getCatalogTopCategoryId(request, productCategoryId), true);
- childOfCats = (List<GenericValue>) request.getAttribute("ChildCatalogList");
+ childOfCats = EntityUtil.filterByDate((List<GenericValue>) request.getAttribute("ChildCatalogList"));
+
+ } else if(isCatalog.equals("false") && isCategoryType.equals("false")){
+ List<String> sortList = org.ofbiz.base.util.UtilMisc.toList("sequenceNum", "productCategoryId", "parentProductCategoryId");
+ childOfCats = EntityUtil.filterByDate(delegator.findByAnd("ProductCategoryRollup", UtilMisc.toMap(
+ "parentProductCategoryId", productCategoryId ), sortList));
} else {
- childOfCats = delegator.findByAnd("ProductCategoryRollup", UtilMisc.toMap(
- "parentProductCategoryId", productCategoryId ));
+ List<String> sortList = org.ofbiz.base.util.UtilMisc.toList("sequenceNum", "prodCatalogCategoryTypeId", "productCategoryId");
+ childOfCats = EntityUtil.filterByDate(delegator.findByAnd("ProdCatalogCategory", UtilMisc.toMap("prodCatalogId", productCategoryId), sortList));
}
if (UtilValidate.isNotEmpty(childOfCats)) {
+
for (GenericValue childOfCat : childOfCats ) {
Object catId = null;
@@ -443,8 +450,8 @@ public class CategoryServices {
List<GenericValue> childList = null;
// Get the child list of chosen category
- childList = delegator.findByAnd("ProductCategoryRollup", UtilMisc.toMap(
- "parentProductCategoryId", catId));
+ childList = EntityUtil.filterByDate(delegator.findByAnd("ProductCategoryRollup", UtilMisc.toMap(
+ "parentProductCategoryId", catId)));
// Get the chosen category information for the categoryContentWrapper
GenericValue cate = delegator.findByPrimaryKey("ProductCategory" ,UtilMisc.toMap("productCategoryId",catId));
@@ -458,7 +465,7 @@ public class CategoryServices {
CategoryContentWrapper categoryContentWrapper = new CategoryContentWrapper(cate, request);
if (UtilValidate.isNotEmpty(categoryContentWrapper.get(catNameField))) {
- dataMap.put("title", categoryContentWrapper.get(catNameField)+"["+catId+"]");
+ dataMap.put("title", categoryContentWrapper.get(catNameField)+" "+"["+catId+"]");
} else {
dataMap.put("title", catId);
}
Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy?rev=1085269&r1=1085268&r2=1085269&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy Fri Mar 25 07:43:18 2011
@@ -31,46 +31,37 @@ import javolution.util.FastList.*;
import org.ofbiz.entity.*;
import java.util.List;
-// Put the result of CategoryWorker.getRelatedCategories into the fillTree function as attribute.
-// The fillTree function will return the complete list of category of given catalog.
-// PLEASE NOTE : The structure of the complete list of fillTree function is according to the JSON_DATA plugin of the jsTree.
-
-List fillTree(rootCat) {
- if (rootCat) {
- rootCat.sort{ it.productCategoryId }
- def listTree = FastList.newInstance();
- for (root in rootCat) {
- preCatChilds = delegator.findByAnd("ProductCategoryRollup", ["parentProductCategoryId": root.productCategoryId]);
- catChilds = EntityUtil.getRelated("CurrentProductCategory",preCatChilds);
- def childList = FastList.newInstance();
- def rootMap = FastMap.newInstance();
- category = delegator.findByPrimaryKey("ProductCategory", ["productCategoryId": root.productCategoryId]);
- categoryContentWrapper = new CategoryContentWrapper(category, request);
- context.title = categoryContentWrapper.CATEGORY_NAME;
- categoryDescription = categoryContentWrapper.DESCRIPTION;
+// Put the result of CategoryWorker.getRelatedCategories into the separateRootType function as attribute.
+// The separateRootType function will return the list of category of given catalog.
+// PLEASE NOTE : The structure of the list of separateRootType function is according to the JSON_DATA plugin of the jsTree.
+
+completedTree = FastList.newInstance();
+
+List separateRootType(roots) {
+ if(roots) {
+ prodRootTypeTree = FastList.newInstance();
+ def i = 0;
+ for(root in roots) {
+ prodCatalogMap2 = FastMap.newInstance();
+ prodCatalogTree2 = FastList.newInstance();
+ prodCatalogCategories = FastList.newInstance();
+ prodCatalog = root.getRelatedOne("ProductCategory");
+
+ productCat = root.getRelatedOne("ProductCategory");
+ prodCatalogId = productCat.getString("productCategoryId");
+ prodCatalogMap2.put("productCategoryId", prodCatalogId);
+ prodCatalogMap2.put("categoryName", productCat.getString("categoryName"));
+ prodCatalogMap2.put("isCatalog", false)
+ prodCatalogMap.put("isCategoryType", true);
- if (categoryContentWrapper.CATEGORY_NAME) {
- rootMap["categoryName"] = categoryContentWrapper.CATEGORY_NAME;
- } else {
- rootMap["categoryName"] = root.categoryName;
- }
- if (categoryContentWrapper.DESCRIPTION) {
- rootMap["categoryDescription"] = categoryContentWrapper.DESCRIPTION;
- } else {
- rootMap["categoryDescription"] = root.description;
- }
- rootMap["productCategoryId"] = root.productCategoryId;
- rootMap["child"] = catChilds;
- rootMap["isCatalog"] = false;
- listTree.add(rootMap);
+ i++;
+ prodRootTypeTree.add(prodCatalogMap2);
}
- return listTree;
+ return prodRootTypeTree;
}
}
-completedTree = FastList.newInstance();
-
// Get the Catalogs
prodCatalogs = delegator.findByAnd("ProdCatalog");
@@ -83,14 +74,14 @@ if (prodCatalogs.size() > 0) {
prodCatalogMap.put("productCategoryId", prodCatalogId);
prodCatalogMap.put("categoryName", prodCatalog.getString("catalogName"));
prodCatalogMap.put("isCatalog", true);
+ prodCatalogMap.put("isCategoryType", false);
+
+ prodCatalogCategories = EntityUtil.filterByDate(delegator.findByAnd("ProdCatalogCategory", ["prodCatalogId" : prodCatalog.prodCatalogId]));
- CategoryWorker.getRelatedCategories(request, "CatalogList_"+i, CatalogWorker.getCatalogTopCategoryId(request, prodCatalogId), true);
- categoryList = null;
- categoryList = request.getAttribute("CatalogList_"+i);
prodCatalogTree = FastList.newInstance();
- if (categoryList) {
- prodCatalogTree = fillTree(categoryList);
+ if (prodCatalogCategories) {
+ prodCatalogTree = separateRootType(prodCatalogCategories);
prodCatalogMap.put("child", prodCatalogTree);
completedTree.add(prodCatalogMap);
}
Modified: ofbiz/trunk/applications/product/webapp/catalog/category/CategoryTree.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/category/CategoryTree.ftl?rev=1085269&r1=1085268&r2=1085269&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/category/CategoryTree.ftl (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/category/CategoryTree.ftl Fri Mar 25 07:43:18 2011
@@ -36,7 +36,7 @@ var rawdata = [
<#list rootCat as root>
{
"data": {"title" : unescapeHtmlText("<#if root.categoryName?exists>${root.categoryName?js_string} [${root.productCategoryId}]<#else>${root.productCategoryId?js_string}</#if>"), "attr": {"onClick" : "window.location.href='<@o...@ofbizUrl>'; return false;"}},
- "attr": {"id" : "${root.productCategoryId}", "rel" : "root", "isCatalog" : "${root.isCatalog?string}"}
+ "attr": {"id" : "${root.productCategoryId}", "rel" : "root", "isCatalog" : "${root.isCatalog?string}" ,"isCategoryType" : "${root.isCategoryType?string}"}
<#if root.child?exists>
,"state" : "closed"
</#if>
@@ -68,12 +68,24 @@ var rawdata = [
"ajax" : { "url" : "<@o...@ofbizUrl>", "type" : "POST",
"data" : function (n) {
return {
+ "isCategoryType" : n.attr ? n.attr("isCatalog").replace("node_","") : 1 ,
"isCatalog" : n.attr ? n.attr("isCatalog").replace("node_","") : 1 ,
"productCategoryId" : n.attr ? n.attr("id").replace("node_","") : 1
};
}
}
- }
+ },
+ "types" : {
+ "valid_children" : [ "root" ],
+ "types" : {
+ "CATEGORY" : {
+ "icon" : {
+ "image" : "/images/jquery/plugins/jsTree/themes/apple/d.png",
+ "position" : "10px40px"
+ }
+ }
+ }
+ }
});
});
}
Re: svn commit: r1085269 - in /ofbiz/trunk/applications/product: src/org/ofbiz/product/category/CategoryServices.java webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy webapp/catalog/category/CategoryTree.ftl
Posted by Jacques Le Roux <jl...@les7arts.com>.
Unfortunately, it's certainly not enough
BTW how are doing your addons with FF4?
Jacques
Hans Bakker wrote:
> Yes i noticed that too...
>
> it seems to work on firefox4 though....
>
> Regards,
> Hans
>
>
> On Fri, 2011-03-25 at 17:42 +0100, Erwan de FERRIERES wrote:
>> Le 25/03/2011 08:43, hansbak@apache.org a écrit :
>>> Author: hansbak
>>> Date: Fri Mar 25 07:43:18 2011
>>> New Revision: 1085269
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1085269&view=rev
>>> Log:
>>> update of the category tree in the catalog, which now also works for large trees. IE and blankscreen problems solved. sort by
>>> sequencenum, do not show rollup expired dates
>>>
>>> Modified:
>>> ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java
>>> ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy
>>> ofbiz/trunk/applications/product/webapp/catalog/category/CategoryTree.ftl
>>>
>>> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java
>>
>> Hi Hans,
>>
>> I just tried navigating into the catalog app. Still got some
>> blankscreens... or screens which doesn't loaded completly.
>>
>> Cheers,
Re: svn commit: r1085269 - in /ofbiz/trunk/applications/product:
src/org/ofbiz/product/category/CategoryServices.java
webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy
webapp/catalog/category/CategoryTree.ftl
Posted by Hans Bakker <ma...@antwebsystems.com>.
Yes i noticed that too...
it seems to work on firefox4 though....
Regards,
Hans
--
Ofbiz on twitter: http://twitter.com/apache_ofbiz
Myself on twitter: http://twitter.com/hansbak
Antwebsystems.com: Quality services for competitive rates.
On Fri, 2011-03-25 at 17:42 +0100, Erwan de FERRIERES wrote:
> Le 25/03/2011 08:43, hansbak@apache.org a écrit :
> > Author: hansbak
> > Date: Fri Mar 25 07:43:18 2011
> > New Revision: 1085269
> >
> > URL: http://svn.apache.org/viewvc?rev=1085269&view=rev
> > Log:
> > update of the category tree in the catalog, which now also works for large trees. IE and blankscreen problems solved. sort by sequencenum, do not show rollup expired dates
> >
> > Modified:
> > ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java
> > ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy
> > ofbiz/trunk/applications/product/webapp/catalog/category/CategoryTree.ftl
> >
> > Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java
>
> Hi Hans,
>
> I just tried navigating into the catalog app. Still got some
> blankscreens... or screens which doesn't loaded completly.
>
> Cheers,
>
Re: svn commit: r1085269 - in /ofbiz/trunk/applications/product:
src/org/ofbiz/product/category/CategoryServices.java webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy
webapp/catalog/category/CategoryTree.ftl
Posted by Erwan de FERRIERES <er...@nereide.fr>.
Le 25/03/2011 08:43, hansbak@apache.org a écrit :
> Author: hansbak
> Date: Fri Mar 25 07:43:18 2011
> New Revision: 1085269
>
> URL: http://svn.apache.org/viewvc?rev=1085269&view=rev
> Log:
> update of the category tree in the catalog, which now also works for large trees. IE and blankscreen problems solved. sort by sequencenum, do not show rollup expired dates
>
> Modified:
> ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java
> ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy
> ofbiz/trunk/applications/product/webapp/catalog/category/CategoryTree.ftl
>
> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java
Hi Hans,
I just tried navigating into the catalog app. Still got some
blankscreens... or screens which doesn't loaded completly.
Cheers,
--
Erwan de FERRIERES
www.nereide.biz