Showing
1 changed file
with
12 additions
and
4 deletions
| ... | @@ -9,7 +9,9 @@ window.ImageManager = new Vue({ | ... | @@ -9,7 +9,9 @@ window.ImageManager = new Vue({ |
| 9 | hasMore: false, | 9 | hasMore: false, |
| 10 | page: 0, | 10 | page: 0, |
| 11 | cClickTime: 0, | 11 | cClickTime: 0, |
| 12 | - selectedImage: false | 12 | + selectedImage: false, |
| 13 | + dependantPages: false, | ||
| 14 | + deleteForm: {} | ||
| 13 | }, | 15 | }, |
| 14 | 16 | ||
| 15 | created: function () { | 17 | created: function () { |
| ... | @@ -63,6 +65,7 @@ window.ImageManager = new Vue({ | ... | @@ -63,6 +65,7 @@ window.ImageManager = new Vue({ |
| 63 | this.hide(); | 65 | this.hide(); |
| 64 | } else { | 66 | } else { |
| 65 | this.selectedImage = (this.selectedImage === image) ? false : image; | 67 | this.selectedImage = (this.selectedImage === image) ? false : image; |
| 68 | + this.dependantPages = false; | ||
| 66 | } | 69 | } |
| 67 | this.cClickTime = cTime; | 70 | this.cClickTime = cTime; |
| 68 | }, | 71 | }, |
| ... | @@ -106,15 +109,20 @@ window.ImageManager = new Vue({ | ... | @@ -106,15 +109,20 @@ window.ImageManager = new Vue({ |
| 106 | deleteImage: function (e) { | 109 | deleteImage: function (e) { |
| 107 | e.preventDefault(); | 110 | e.preventDefault(); |
| 108 | var _this = this; | 111 | var _this = this; |
| 109 | - var form = $(_this.$$.imageDeleteForm); | 112 | + _this.deleteForm.force = _this.dependantPages !== false; |
| 110 | $.ajax('/images/' + _this.selectedImage.id, { | 113 | $.ajax('/images/' + _this.selectedImage.id, { |
| 111 | method: 'DELETE', | 114 | method: 'DELETE', |
| 112 | - data: form.serialize() | 115 | + data: _this.deleteForm |
| 113 | }).done(function () { | 116 | }).done(function () { |
| 114 | _this.images.splice(_this.images.indexOf(_this.selectedImage), 1); | 117 | _this.images.splice(_this.images.indexOf(_this.selectedImage), 1); |
| 115 | _this.selectedImage = false; | 118 | _this.selectedImage = false; |
| 116 | $(_this.$$.imageTitle).showSuccess('Image Deleted'); | 119 | $(_this.$$.imageTitle).showSuccess('Image Deleted'); |
| 117 | - }) | 120 | + }).fail(function(jqXHR, textStatus) { |
| 121 | + // Pages failure | ||
| 122 | + if(jqXHR.status === 400) { | ||
| 123 | + _this.dependantPages = jqXHR.responseJSON; | ||
| 124 | + } | ||
| 125 | + }); | ||
| 118 | } | 126 | } |
| 119 | 127 | ||
| 120 | } | 128 | } | ... | ... |
-
Please register or sign in to post a comment