delete item from gallery
authorcavaliet
Fri, 03 Oct 2014 17:04:28 +0200
changeset 5 c6ff29914983
parent 4 28208a0ad8b9
child 6 4be9f21f2df1
delete item from gallery
client/app/gallery/gallery.html
client/app/gallery/gallery_controller.js
--- a/client/app/gallery/gallery.html	Fri Oct 03 16:15:50 2014 +0200
+++ b/client/app/gallery/gallery.html	Fri Oct 03 17:04:28 2014 +0200
@@ -6,8 +6,11 @@
     <div class="img-ctn">
         <img class="img img-responsive image" src="{{ i.url }}" />
         <p>{{ i.title }}</p>
-        <div class="gallery-buttons"><a class="btn btn-default" href="#/slideshow/edit/{{ $index }}"><span class="glyphicon glyphicon-pencil"></span></a>
-          <a class="btn btn-default" href="#/slideshow/{{ $index }}"><span class="glyphicon glyphicon-eye-open"></span></a></div>
+        <div class="gallery-buttons">
+          <a class="btn btn-default" href="#/slideshow/edit/{{ $index }}"><span class="glyphicon glyphicon-pencil"></span></a>
+          <a class="btn btn-default" href="#/slideshow/{{ $index }}"><span class="glyphicon glyphicon-eye-open"></span></a>
+          <a class="btn btn-default" ng-click="deleteItem($index)"><span class="glyphicon glyphicon-trash"></span></a>
+        </div>
     </div>
   </li>
 </ul>
--- a/client/app/gallery/gallery_controller.js	Fri Oct 03 16:15:50 2014 +0200
+++ b/client/app/gallery/gallery_controller.js	Fri Oct 03 17:04:28 2014 +0200
@@ -12,6 +12,14 @@
     .controller('galleryCtrl', function($scope, $location, slideshowModel){
       console.log('gallery 5',$scope, $location, slideshowModel);
       $scope.gallery = slideshowModel.slideshow;
+      
+      $scope.deleteItem = function(i){
+          if(0<=i && i<$scope.gallery.images.length){
+              if(window.confirm('Êtes-vous sûr(e) de vouloir effacer cet élément ? Cette action est irrémédiable.')){
+                  $scope.gallery.images.splice(i, 1);
+              }
+          }
+      };
     });
 
 })();