Remove event from view (scope) after deleting it

This commit is contained in:
Kyle Johnson 2015-01-09 14:24:45 -05:00
parent 8279f71266
commit 0b0545823d
3 changed files with 13 additions and 8 deletions

View File

@ -57,16 +57,20 @@ ZoneMinder.controller('EventsController', function($scope, Events, $modal) {
// This is called when a user clicks on an event.
// It fires up a modal and passes it the EventId of the clicked event
// EventController takes over from there.
$scope.displayEvent = function (eventId) {
$scope.eventId = eventId;
$scope.displayEvent = function (index) {
var event = $scope.events[index];
var modalInstance = $modal.open({
templateUrl: '/?view=event&skin=bootstrap',
controller: 'EventController',
resolve: { eventId: function () { return $scope.eventId; } }
resolve: {
eventId: function () { return event.Event.Id; },
index: function () { return index; }
}
});
modalInstance.result.then(function (selectedItem) {
modalInstance.result.then(function (index) {
$scope.events.splice(index, 1);
}, function () {
console.log('Modal dismissed at: ' + new Date());
}
@ -74,7 +78,7 @@ ZoneMinder.controller('EventsController', function($scope, Events, $modal) {
};
});
ZoneMinder.controller('EventController', function($scope, Event, $modalInstance, eventId) {
ZoneMinder.controller('EventController', function($scope, Event, $modalInstance, eventId, index) {
Event.get(eventId).then(function(results) {
$scope.eventId = eventId;
@ -96,8 +100,9 @@ ZoneMinder.controller('EventController', function($scope, Event, $modalInstance,
$modalInstance.dismiss('cancel');
};
$scope.deleteEvent = function() {
$scope.delete= function() {
Event.delete(eventId).then(function(results) {
$modalInstance.close(index);
console.log(results);
});
};

View File

@ -20,7 +20,7 @@
<div class="modal-footer">
<span class="pull-right glyphicon glyphicon-chevron-right"><span class="sr-only">Next</span></span>
<button type="button" class="btn btn-danger" ng-click="deleteEvent()">Delete</button>
<button type="button" class="btn btn-danger" ng-click="delete()">Delete</button>
<button type="button" class="btn btn-warning" ng-click="cancel()">Cancel</button>
<span class="pull-left glyphicon glyphicon-chevron-left"><span class="sr-only">Previous</span></span>
</div>

View File

@ -20,7 +20,7 @@
<div class="col-md-10">
<div class="clearfix events">
<div class="event" dir-paginate="event in events | itemsPerPage: eventsPerPage" total-items="totalEvents" ng-click="displayEvent(event.Event.Id)">
<div class="event" dir-paginate="event in events | itemsPerPage: eventsPerPage" total-items="totalEvents" ng-click="displayEvent($index)">
<img ng-src="/events/{{ event.thumbData.Path }}" class="img-thumbnail" alt="..."/>
<div class="over">
<div class="info">