From a01405e3ccc6b17f8c7aa610fe39d2a6b6f9315f Mon Sep 17 00:00:00 2001 From: Ivaylo Ivanov Date: Sun, 5 Apr 2020 18:14:03 +0200 Subject: [PATCH] US06: Add a button for the owner create form to the owners list, fix bug where all whitespaces were considered valid input --- .../assignment/individual/persistence/impl/OwnerJdbcDao.java | 2 +- .../at/ac/tuwien/sepm/assignment/individual/util/Validator.java | 2 +- .../src/app/component/add-owner/add-owner.component.html | 2 +- .../src/app/component/list-owners/list-owners.component.html | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/persistence/impl/OwnerJdbcDao.java b/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/persistence/impl/OwnerJdbcDao.java index 14d41d5..4d51cfc 100644 --- a/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/persistence/impl/OwnerJdbcDao.java +++ b/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/persistence/impl/OwnerJdbcDao.java @@ -127,7 +127,7 @@ public class OwnerJdbcDao implements OwnerDao { int changes = jdbcTemplate.update(connection -> { PreparedStatement ps = connection.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS); - ps.setString(1, owner.getName()); + ps.setString(1, owner.getName().trim()); ps.setObject(2, owner.getCreatedAt()); ps.setObject(3, owner.getUpdatedAt()); return ps; diff --git a/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/util/Validator.java b/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/util/Validator.java index 1198ed6..7c19ead 100644 --- a/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/util/Validator.java +++ b/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/util/Validator.java @@ -12,7 +12,7 @@ import java.util.Map; @Component public class Validator { public void validateNewOwner(Owner owner) throws ValidationException { - if(owner.getName() == null || owner.getName().isEmpty()) { + if(owner.getName() == null || owner.getName().isEmpty() || owner.getName().isBlank()) { throw new ValidationException("Required value name missing"); } } diff --git a/frontend/wendys-friends/src/app/component/add-owner/add-owner.component.html b/frontend/wendys-friends/src/app/component/add-owner/add-owner.component.html index b8d9309..fd4662c 100644 --- a/frontend/wendys-friends/src/app/component/add-owner/add-owner.component.html +++ b/frontend/wendys-friends/src/app/component/add-owner/add-owner.component.html @@ -17,7 +17,7 @@
- +
diff --git a/frontend/wendys-friends/src/app/component/list-owners/list-owners.component.html b/frontend/wendys-friends/src/app/component/list-owners/list-owners.component.html index ed10cb3..ee4ecb6 100644 --- a/frontend/wendys-friends/src/app/component/list-owners/list-owners.component.html +++ b/frontend/wendys-friends/src/app/component/list-owners/list-owners.component.html @@ -14,6 +14,7 @@ +