From 53ab313da375a0affef9f39d12be093d07a64e77 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Mon, 20 Jul 2015 00:16:56 +0200 Subject: [PATCH] Improve CSS classes, buttons and entry states handling. --- accountant/frontend/static/js/entries.js | 56 +++--------------- .../frontend/static/templates/entries.html | 59 +++++++------------ 2 files changed, 31 insertions(+), 84 deletions(-) diff --git a/accountant/frontend/static/js/entries.js b/accountant/frontend/static/js/entries.js index bd1381c..038d6a9 100644 --- a/accountant/frontend/static/js/entries.js +++ b/accountant/frontend/static/js/entries.js @@ -333,56 +333,11 @@ accountantApp }); }; - // Returns the CSS class for an entry row. - $scope.entryRowClass = function(entry) { - if($scope.isSaved(entry)) { - cssclass=""; - } else { - cssclass="italic"; - } - - if(entry.canceled) { - cssclass += " stroke"; - } - - if(entry.sold < $scope.account.authorized_overdraft) { - cssclass += " danger"; - } else if (entry.sold < 0) { - cssclass += " warning"; - } - - return cssclass; - }; - - // Returns the CSS class for an entry sold. - $scope.entryValueClass = function(sold) { - if(sold && sold < $scope.account.authorized_overdraft) { - return 'text-danger'; - } else if (sold && sold < 0) { - return 'text-warning'; - } - }; - // Starts editing an entry $scope.editEntry = function(entry) { // Enter edit state. entry.confirmed=true; - entry.state='edit'; - }; - - // Returns true if the entry is in editing state. - $scope.isEditing = function(entry) { - return entry.state === 'edit'; - }; - - // Returns true if the entry is in displaying state. - $scope.isDisplaying = function(entry) { - return !entry.state || entry.state === 'display'; - }; - - // Returns true if the entry is a scheduled one. - $scope.isSaved = function(entry) { - return entry.confirmed; + entry.editing=true; }; // Cancel current editing entry or clears field if a new one. @@ -394,7 +349,7 @@ accountantApp }; // Points an entry. - $scope.pointEntry = function(entry) { + $scope.togglePointedEntry = function(entry) { entry.confirmed = true; entry.pointed = !entry.pointed; @@ -408,6 +363,13 @@ accountantApp $scope.saveEntry(entry); }; + // Confirm an entry. + $scope.toggleCanceledEntry = function(entry) { + entry.canceled = !entry.canceled; + + $scope.saveEntry(entry); + }; + // Create an new entry. $scope.createEntry = function(entry) { entry.account_id = $scope.account.id; diff --git a/accountant/frontend/static/templates/entries.html b/accountant/frontend/static/templates/entries.html index 5caf851..e69f2cc 100644 --- a/accountant/frontend/static/templates/entries.html +++ b/accountant/frontend/static/templates/entries.html @@ -71,14 +71,14 @@ @@ -86,8 +86,8 @@ + ng-class="{stroke: entry.canceled, italic: !entry.confirmed, warning: entry.sold < 0, danger: entry.sold < account.authorized_overdraft}" + ng-repeat-start="entry in entries" ng-if="entry.editing"> @@ -100,7 +100,7 @@ - + {{entry.sold}} @@ -119,9 +119,9 @@ @@ -129,8 +129,8 @@ + ng-class="{stroke: entry.canceled, italic: !entry.confirmed, warning: entry.sold < 0, danger: entry.sold < account.authorized_overdraft}" + ng-repeat-end ng-if="!entry.editing"> {{entry.operation_date | date:"yyyy-MM-dd"}} @@ -143,7 +143,7 @@ {{entry.value}} - + {{entry.sold}} @@ -153,36 +153,21 @@ -
- - - - - -
- - -
- - - + +