Commit a01405e3 authored by Ivaylo Ivanov's avatar Ivaylo Ivanov

US06: Add a button for the owner create form to the owners list, fix bug where...

US06: Add a button for the owner create form to the owners list, fix bug where all whitespaces were considered valid input
parent be37d5ce
...@@ -127,7 +127,7 @@ public class OwnerJdbcDao implements OwnerDao { ...@@ -127,7 +127,7 @@ public class OwnerJdbcDao implements OwnerDao {
int changes = jdbcTemplate.update(connection -> { int changes = jdbcTemplate.update(connection -> {
PreparedStatement ps = connection.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS); 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(2, owner.getCreatedAt());
ps.setObject(3, owner.getUpdatedAt()); ps.setObject(3, owner.getUpdatedAt());
return ps; return ps;
......
...@@ -12,7 +12,7 @@ import java.util.Map; ...@@ -12,7 +12,7 @@ import java.util.Map;
@Component @Component
public class Validator { public class Validator {
public void validateNewOwner(Owner owner) throws ValidationException { 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"); throw new ValidationException("Required value name missing");
} }
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<form (ngSubmit)="addOwner()" #ownerForm="ngForm"> <form (ngSubmit)="addOwner()" #ownerForm="ngForm">
<div class="form-group"> <div class="form-group">
<label for="name">Name</label> <label for="name">Name</label>
<input type="text" class="form-control" name="name" [(ngModel)]="owner.name" required> <input type="text" class="form-control" name="name" [(ngModel)]="owner.name" pattern="\s*\S+.*" required>
</div> </div>
<button type="submit" class="btn btn-success" [disabled]="!ownerForm.form.valid" (submit)="addOwner()">Submit</button> <button type="submit" class="btn btn-success" [disabled]="!ownerForm.form.valid" (submit)="addOwner()">Submit</button>
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
</div> </div>
<button type="submit" class="btn btn-primary"><i class="fas fa-search"></i></button> <button type="submit" class="btn btn-primary"><i class="fas fa-search"></i></button>
<button type="button" onclick="document.getElementById('searchForm').reset();" class="btn btn-danger"><i class="fas fa-times"></i></button> <button type="button" onclick="document.getElementById('searchForm').reset();" class="btn btn-danger"><i class="fas fa-times"></i></button>
<a href="owner/add" class="btn btn-success"><i class="fas fa-plus"></i></a>
</div> </div>
</form> </form>
<table class="table"> <table class="table">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment