From 12668eea9f4569bcc80d6d8f626f258096c1a172 Mon Sep 17 00:00:00 2001 From: Tilman Liero Date: Sun, 31 Jul 2016 01:01:08 +0200 Subject: [PATCH] Categories can now be retired --- .../de/tilman/transactions/domain/Category.java | 10 ++++++++++ src/main/resources/data-h2.sql | 17 +++++++++-------- src/main/resources/static/app/controllers.js | 8 ++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/tilman/transactions/domain/Category.java b/src/main/java/de/tilman/transactions/domain/Category.java index 84320d2..49bd04e 100644 --- a/src/main/java/de/tilman/transactions/domain/Category.java +++ b/src/main/java/de/tilman/transactions/domain/Category.java @@ -19,6 +19,8 @@ public class Category { private String name; private Integer position; + + private Boolean retired = false; public Account getAccount() { return account; @@ -47,5 +49,13 @@ public class Category { public Long getId() { return id; } + + public Boolean isRetired() { + return retired; + } + + public void setRetired(Boolean retired) { + this.retired = retired; + } } diff --git a/src/main/resources/data-h2.sql b/src/main/resources/data-h2.sql index b278ad1..515afa9 100644 --- a/src/main/resources/data-h2.sql +++ b/src/main/resources/data-h2.sql @@ -1,14 +1,15 @@ INSERT INTO User (id, name, username) VALUES (1, 'Adam', 'adam'), (2, 'Betty', 'betty'), (3, 'Curt', 'curt'); INSERT INTO Account (id, name, owner_id) VALUES (1, 'Gemeinschaftskonto', 1), (2, 'Konto Adam', 1); -INSERT INTO Category (id, name, account_id, position) VALUES - (null, 'Essen - Lebensmittel', 1, 2), - (null, 'Einnahmen - Gehalt', 1, 1), - (null, 'Essen - Arbeit', 1, 3), - (null, 'Wohnen - Haushalt', 1, 4), - (null, 'Private Entnahme', 1, 5), - (null, 'Einnahmen - Gehalt', 2, 1), - (null, 'Technik - Server und Hosting', 2, 2); +INSERT INTO Category (id, name, account_id, position, retired) VALUES + (null, 'Essen - Lebensmittel', 1, 2, false), + (null, 'Einnahmen - Gehalt', 1, 1, false), + (null, 'Essen - Arbeit', 1, 3, false), + (null, 'Sonstiges - Projekt 1000', 1, 4, true), + (null, 'Wohnen - Haushalt', 1, 4, false), + (null, 'Private Entnahme', 1, 5, false), + (null, 'Einnahmen - Gehalt', 2, 1, false), + (null, 'Technik - Server und Hosting', 2, 2, false); INSERT INTO Account_User (account_id, user_id) VALUES (1, 1), (1, 2), (1, 3), (2, 1); diff --git a/src/main/resources/static/app/controllers.js b/src/main/resources/static/app/controllers.js index dc115fc..5421d5a 100644 --- a/src/main/resources/static/app/controllers.js +++ b/src/main/resources/static/app/controllers.js @@ -149,6 +149,14 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara var categories = $resource('/api/categories/search/listForAccount', { accountId: $scope.account.id }).get(); categories.$promise.then(function(data) { $scope.categories = categories._embedded.categories; + + // remove retired categories + for (i = 0; i < $scope.categories.length; i++) { + if ($scope.categories[i].retired) { + $scope.categories.splice(i, 1); + } + } + $scope.refreshList(); }); });