Zmiana $.log na console.log (IMHO nie warto używać tak skomplikowanego wrappera,...
[redakcja.git] / project / static / js / models.js
index 13dc2ea..8e4f74d 100644 (file)
@@ -181,7 +181,8 @@ Editor.HTMLModel = Editor.Model.extend({
 
 Editor.ImageGalleryModel = Editor.Model.extend({
   _className: 'Editor.ImageGalleryModel',
-  serverURL: null,  
+  serverURL: null,
+  data: [],
   state: 'empty',
 
   init: function(serverURL) {
@@ -208,7 +209,15 @@ Editor.ImageGalleryModel = Editor.Model.extend({
       alert('erroneous state:', this.get('state'));
     }
 
-    this.set('pages', data[0].pages);
+    console.log('galleries:', data);
+
+    if (data.length === 0) {
+        this.set('data', []);
+    } else {
+        console.log('dupa');
+        this.set('data', data[0].pages);
+    }  
+
     this.set('state', 'synced');
   },
 
@@ -310,7 +319,7 @@ Editor.DocumentModel = Editor.Model.extend({
         this.contentModels[key].set('revision', this.data.user_revision);
         this.contentModels[key].set('state', 'empty');
       }
-    } else if (xhr.status == 202) { // Wygenerowano PullRequest
+    } else if (xhr.status == 202) { // Wygenerowano PullRequest (tutaj?)
     } else if (xhr.status == 204) { // Nic nie zmieniono
     } else if (xhr.status == 409) { // Konflikt podczas operacji
     } 
@@ -342,7 +351,7 @@ Editor.DocumentModel = Editor.Model.extend({
         this.contentModels[key].set('revision', this.data.user_revision);
         this.contentModels[key].set('state', 'empty');
       }
-    } else if (xhr.status == 202) { // Wygenerowano PullRequest (tutaj?)
+    } else if (xhr.status == 202) { // Wygenerowano PullRequest
     } else if (xhr.status == 204) { // Nic nie zmieniono
     } else if (xhr.status == 409) { // Konflikt podczas operacji
     }