Roo/bootstrap/CardUploader.js
[roojs1] / Roo / bootstrap / CardUploader.js
index 840bd89..d5e87b0 100644 (file)
@@ -193,6 +193,7 @@ Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Input,  {
             title : file.name,
             mimetype : file.type,
             preview : false,
+            is_deleted : 0
         })
         
     },
@@ -260,7 +261,7 @@ Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Input,  {
                 closeable : true,
                 header : !data.mimetype.match(/image/) && !data.preview ? "Document": false,
                 header_image : data.mimetype.match(/image/) ? data.src  : data.preview,
-                header_image_fit_square: true,
+                header_image_fit_square: true, // fixme  - we probably need to use the 'Img' element to do stuff like this.
                 data : data,
                 html : false,
                  
@@ -280,23 +281,40 @@ Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Input,  {
             }
         );
         // dont' really need ot update items.
-        //this.items.push(cn);
+        // this.items.push(cn);
         this.fileCollection.add(cn);
+        this.updateInput();
         
     },
     removeCard : function(id)
     {
         
         var card  = this.fileCollection.get(id);
+        card.data.is_deleted = 1;
+        card.data.src = ''; /// delete the source - so it reduces size of not uploaded images etc.
         this.fileCollection.remove(card);
         //this.items = this.items.filter(function(e) { return e != card });
         // dont' really need ot update items.
         card.el.dom.parentNode.removeChild(card.el.dom);
         
     },
+    reset: function()
+    {
+        this.fileCollection.each(function(card) {
+            card.el.dom.parentNode.removeChild(card.el.dom);    
+        });
+        this.fileCollection.clear();
+        this.updateInput();
+    },
+    
     updateInput : function()
     {
-        this.fileCo
+        var data = [];
+        this.fileCollection.each(function(e) {
+            data.push(e.data);
+        });
+        
+        this.inputEl().dom.value = JSON.stringify(data);
     }