Fixed bug: not displaying "add new entry" line when account is empty.
This commit is contained in:
parent
65d1b00127
commit
43c4e1f61d
@ -219,15 +219,21 @@ var ListViewModel = function() {
|
|||||||
|
|
||||||
// Function to load entries from server for a specific account and month.
|
// Function to load entries from server for a specific account and month.
|
||||||
self.loadEntries = function(account, month) {
|
self.loadEntries = function(account, month) {
|
||||||
// An account may not have any month (new account)
|
|
||||||
if(month) {
|
|
||||||
$.get("api/entries/" + account.id() + "/" + month.year() + "/" + month.month()).success(function(data) {
|
|
||||||
// Clean up selected entry.
|
// Clean up selected entry.
|
||||||
self.selectedItem(null);
|
self.selectedItem(null);
|
||||||
|
|
||||||
// Update entries
|
// An account may not have any month (new account)
|
||||||
self.clearNewEntry()
|
self.clearNewEntry()
|
||||||
var entries = [self.newEntry()].concat(ko.utils.arrayMap($.parseJSON(data), ko.mapping.fromJS));
|
var entries = [self.newEntry()];
|
||||||
|
|
||||||
|
if(month) {
|
||||||
|
$.get("api/entries/" + account.id() + "/" + month.year() + "/" + month.month()).success(function(data) {
|
||||||
|
// Update entries
|
||||||
|
var dataArray = ko.utils.arrayMap($.parseJSON(data), ko.mapping.fromJS);
|
||||||
|
|
||||||
|
if(dataArray.length > 0) {
|
||||||
|
entries = entries.concat(dataArray);
|
||||||
|
}
|
||||||
|
|
||||||
self.entries(entries);
|
self.entries(entries);
|
||||||
|
|
||||||
@ -237,8 +243,12 @@ var ListViewModel = function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// If no month, just remove all entries.
|
self.entries(entries);
|
||||||
self.entries.removeAll();
|
|
||||||
|
// Initialize date picker for operation date column.
|
||||||
|
$("#new_operation_date").datepicker().on('changeDate', function(ev){
|
||||||
|
self.newEntry().operation_date(ev.date.format(ev.currentTarget.dataset.dateFormat));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user