Add entry deletion.
This commit is contained in:
parent
ad60e19617
commit
156c9a3be2
@ -292,6 +292,11 @@ accountantApp
|
||||
$scope.loadSolds();
|
||||
});
|
||||
|
||||
// Reload solds when an entry is deleted.
|
||||
$rootScope.$on("entryDeletedEvent", function(e, entry) {
|
||||
$scope.loadSolds();
|
||||
});
|
||||
|
||||
// Update authorized overdraft on account loading.
|
||||
$rootScope.$on("accountLoadedEvent", function(e, account) {
|
||||
$scope.config.yAxis.plotLines[1].value = account.authorized_overdraft;
|
||||
@ -396,6 +401,29 @@ accountantApp
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Delete an entry and emit entryDeletedEvent.
|
||||
*/
|
||||
$scope.deleteEntry = function(entry, $index) {
|
||||
var id = entry.id;
|
||||
|
||||
bootbox.confirm(
|
||||
"Voulez-vous supprimer l'entrée \"" + entry.label + "\" ?",
|
||||
function(result) {
|
||||
if(result) {
|
||||
entry.$delete().then(function() {
|
||||
notificationService.success("Entry #" + id + " deleted.");
|
||||
|
||||
// Remove entry from array.
|
||||
$scope.entries.splice($index, 1);
|
||||
|
||||
$scope.$emit("entryDeletedEvent", entry);
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
// Reload entries on range selection.
|
||||
$rootScope.$on("rangeSelectedEvent", function(e, args) {
|
||||
$scope.loadEntries(args.begin, args.end);
|
||||
|
@ -40,7 +40,7 @@
|
||||
<th class="col-md-1">Montant</th>
|
||||
<th class="col-md-1">Solde</th>
|
||||
<th class="col-md-2">Catégorie</th>
|
||||
<th class="col-md-1">Actions</th>
|
||||
<th class="col-md-2">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -138,6 +138,13 @@
|
||||
ng-class="{active: entry.canceled}" title="cancel">
|
||||
<span class="fa fa-remove"></span>
|
||||
</button>
|
||||
|
||||
<!-- Delete entry, with confirm. -->
|
||||
<button type="button" class="btn btn-default"
|
||||
ng-if="entry.id"
|
||||
ng-click="deleteEntry(entry, $index)">
|
||||
<span class="fa fa-trash-o"></span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
|
Loading…
Reference in New Issue
Block a user