[ofbiz-framework] branch trunk updated: Improved: Move page-specific script links to html template (OFBIZ-11799)

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

[ofbiz-framework] branch trunk updated: Improved: Move page-specific script links to html template (OFBIZ-11799)

James Yong-2
This is an automated email from the ASF dual-hosted git repository.

jamesyong pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 5088abe  Improved: Move page-specific script links to html template (OFBIZ-11799)
5088abe is described below

commit 5088abe59d2c60550fc1ae2298f264716f9bc4a3
Author: James Yong <[hidden email]>
AuthorDate: Sun Aug 23 14:24:51 2020 +0800

    Improved: Move page-specific script links to html template (OFBIZ-11799)
   
    Use importLibrary js function to load jstree js at ProductStoreGroupTree.ftl
    Tested at
    https://localhost:8443/catalog/control/ListParentProductStoreGroup
---
 .../template/store/ProductStoreGroupTree.ftl       | 47 ++++++++++++----------
 1 file changed, 26 insertions(+), 21 deletions(-)

diff --git a/applications/product/template/store/ProductStoreGroupTree.ftl b/applications/product/template/store/ProductStoreGroupTree.ftl
index 91c0027..3c17777 100644
--- a/applications/product/template/store/ProductStoreGroupTree.ftl
+++ b/applications/product/template/store/ProductStoreGroupTree.ftl
@@ -17,8 +17,6 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-<script src="/common/js/jquery/plugins/jsTree/jquery.jstree.js" type="application/javascript" data-import="head"></script>
-
 <script type="application/javascript">
 <#-- some labels are not unescaped in the JSON object so we have to do this manualy -->
 function unescapeHtmlText(text) {
@@ -47,26 +45,33 @@ var rawdata = [
  <#-- create Tree-->
   function createTree() {
     jQuery(function () {
-        jQuery("#tree").jstree({
-        "plugins" : [ "themes", "json_data","ui" ,"cookies", "types"],
-            "json_data" : {
-                "data" : rawdata,
-                "ajax" : { "url" : "<@ofbizUrl>getProductStoreGroupRollupHierarchy</@ofbizUrl>",
-                           "type" : "POST",
-                           "data" : function (n) {
-                               return {
-                                   "parentGroupId" :  n.attr ? n.attr("parentGroupId").replace("node_","") : 1,
-                                   "onclickFunction" : "callDocument"
-                               };
-                           },
-                           success : function (data) {
-                               return data.storeGroupTree;
-                           }
+        importLibrary(["/common/js/jquery/plugins/jsTree/jquery.jstree.js"], function() {
+            jQuery("#tree").jstree({
+                "plugins": ["themes", "json_data", "ui", "cookies", "types"],
+                "json_data": {
+                    "data": rawdata,
+                    "ajax": {
+                        "url": "<@ofbizUrl>getProductStoreGroupRollupHierarchy</@ofbizUrl>",
+                        "type": "POST",
+                        "data": function (n) {
+                            return {
+                                "parentGroupId": n.attr ? n.attr("parentGroupId").replace("node_", "") : 1,
+                                "onclickFunction": "callDocument"
+                            };
+                        },
+                        success: function (data) {
+                            return data.storeGroupTree;
+                        }
+                    }
+                },
+                "types": {
+                    "valid_children": ["root"]
+                },
+                "themes": {
+                    "theme": "default",
+                    "url": "/common/js/jquery/plugins/jsTree/themes/default/style.css"
                 }
-            },
-            "types" : {
-                "valid_children" : [ "root" ]
-            }
+            });
         });
     });
   }