Ver código fonte

create img item from editor

Nikolay Suslov 7 anos atrás
pai
commit
9a54f40806

+ 56 - 0
support/client/lib/vwf/view/editor-new.js

@@ -193,6 +193,21 @@ define([
                         $type: "div",
                         class: "mdc-layout-grid__inner",
                         $components: [
+                            {
+                                
+                                    $cell: true,
+                                    $type: "div",
+                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
+                                    $components: [
+                                        {
+                                            $cell: true,
+                                            $type: "h3",
+                                            class: "mdc-typography--headline",
+                                            $text: "Primitives"
+                                        }
+                                    ]
+                                
+                            },
                             {
                                 $cell: true,
                                 $type: "div",
@@ -252,7 +267,48 @@ define([
                             // }
                           
                         ]
+                    },
+                    {
+                        $cell: true,
+                        $type: "div",
+                        class: "mdc-layout-grid__inner",
+                        $components: [
+                            {
+                                $cell: true,
+                                $type: "div",
+                                class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
+                                $components: [
+                                    {
+                                        $cell: true,
+                                        $type: "h3",
+                                        class: "mdc-typography--headline",
+                                        $text: "Assets"
+                                    }
+                                ]
+                            },
+                            {
+                                $cell: true,
+                                $type: "div",
+                                class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-4",
+                                $components: [
+
+                                    widgets.simpleCard(
+                                        {
+                                            "imgSrc": "vwf/view/lib/images/ui/standard.png",
+                                            "imgHeight": "100px",
+                                            "addonClass": "create-card",
+                                            "text": "2D Image",
+                                            "onclickfunc": function(){
+                                                //let cubeName = self.GUID();
+                                                vwf_view.kernel.callMethod(vwf.application(), "createAssetItemImg")
+                                            }
+                                        }
+                                    )
+                                ]
+                            }
+                        ]
                     }
+
                 ]
             }
 

+ 33 - 0
support/proxy/vwf.example.com/aframe/ascene.js

@@ -179,4 +179,37 @@ this.GUID = function () {
         S4() + "-" +
         S4() + S4() + S4()
     );
+}
+
+this.smallRandomId = function()  {
+    return '_' + this.random().toString(36).substr(2, 9);
+}
+
+this.assetImgProto = function () {
+
+    let node = {
+        "extends": "http://vwf.example.com/aframe/a-asset-image-item.vwf",
+        "properties": {
+        },
+    }
+    return node
+}
+
+
+
+this.createAssetItemImg = function(){
+
+    console.log("create new asset item for img");
+
+    let nodeName = "asset-item-img-" + this.smallRandomId();
+    let newNode = {
+        "extends": "http://vwf.example.com/aframe/a-asset-image-item.vwf",
+        "properties": {
+            itemID:  nodeName,
+            itemSrc: ""
+        }
+    }
+
+    this.children.create(nodeName, newNode);
+
 }

+ 1 - 0
support/proxy/vwf.example.com/aframe/ascene.vwf.yaml

@@ -15,5 +15,6 @@ methods:
       - avatar
       - name
       - node
+  createAssetItemImg:
 scripts:
 - source: "http://vwf.example.com/aframe/ascene.js"