Add possibilty to add multiple entries.

This commit is contained in:
Alexis Lahouze 2015-08-20 11:43:02 +02:00
parent 156c9a3be2
commit f4f62e6e0c
2 changed files with 8 additions and 20 deletions

View File

@ -315,11 +315,9 @@ accountantApp
// Function to reset the new entry.
$scope.addEntry = function() {
if(!$scope.inserted) {
$scope.inserted = new Entries();
$scope.inserted.account_id = $routeParams.accountId;
$scope.entries.splice(0, 0, $scope.inserted);
}
entry = new Entries();
entry.account_id = $routeParams.accountId;
$scope.entries.splice(0, 0, entry);
};
// Function to load entries from server for a specific account and month.
@ -338,9 +336,9 @@ accountantApp
};
// Cancel current editing entry or clears field if a new one.
$scope.cancelEditEntry = function(entry, rowform) {
if(entry == $scope.inserted) {
$scope.entries.splice(0, 1);
$scope.cancelEditEntry = function(entry, rowform, $index) {
if(!entry.id) {
$scope.entries.splice($index, 1);
} else {
rowform.$cancel();
}
@ -383,17 +381,7 @@ accountantApp
entry.confirmed = true;
var promise = entry.$save();
if(entry == $scope.inserted) {
promise = promise.then(function(data) {
$scope.inserted = false;
return data;
});
}
return promise.then(function(data) {
return entry.$save().then(function(data) {
notificationService.success("Entry #" + data.id + " saved.");
$scope.$emit("entrySavedEvent", data);

View File

@ -100,7 +100,7 @@
<td>
<form editable-form name="rowform"
onbeforesave="saveEntry($data, $index)"
shown="entry == inserted">
shown="!entry.id">
<div class="btn-group btn-group-xs">
<!-- Save current entry, for editing and non-confirmed non-canceled entries -->
<button type="submit" class="btn btn-success"