Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class ValidationConstants {
public static final int CATEGORY_NAME_MIN_LENGTH = 1;
public static final int CATEGORY_NAME_MAX_LENGTH = 25;
public static final int CATEGORY_EMOJI_MAX_LENGTH = 50;
public static final int CATEGORY_NOTE_MAX_LENGTH = 500;

// Transaction validations
public static final int TRANSACTION_TITLE_MIN_LENGTH = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import static com.exence.finance.common.util.ValidationConstants.CATEGORY_NAME_MAX_LENGTH;
import static com.exence.finance.common.util.ValidationConstants.CATEGORY_NAME_MIN_LENGTH;
import static com.exence.finance.common.util.ValidationConstants.CATEGORY_NOTE_MAX_LENGTH;

@SuperBuilder
@NoArgsConstructor
Expand All @@ -33,4 +34,8 @@ public class CategoryDTO {

@ValidEmoji(allowEmpty = false, message = "Must contain exactly one emoji character")
private String emoji;

@Size(max = CATEGORY_NOTE_MAX_LENGTH,
message = "Note can be a maximum of " + CATEGORY_NOTE_MAX_LENGTH + " characters.")
private String note;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import static com.exence.finance.common.util.ValidationConstants.CATEGORY_EMOJI_MAX_LENGTH;
import static com.exence.finance.common.util.ValidationConstants.CATEGORY_NAME_MAX_LENGTH;
import static com.exence.finance.common.util.ValidationConstants.CATEGORY_NOTE_MAX_LENGTH;

@SuperBuilder
@Entity
Expand All @@ -53,6 +54,9 @@ public class Category extends BaseAuditableEntity {
@Column(name = "emoji", length = CATEGORY_EMOJI_MAX_LENGTH)
private String emoji;

@Column(name = "note", length = CATEGORY_NOTE_MAX_LENGTH)
private String note;

@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "user_id", nullable = false)
private User user;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ databaseChangeLog:
file: v1.0.0/changelog-v1.0.0.yaml
relativeToChangelogFile: true

- include:
file: v1.1.0/changelog-v1.1.0.yaml
relativeToChangelogFile: true

# Test data
- include:
file: data/test-data.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
databaseChangeLog:
- changeSet:
id: add-note-to-category
author: tamibalogh
comment: Create note column in category table
changes:
- addColumn:
tableName: category
columns:
- column:
name: note
type: VARCHAR(500)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
databaseChangeLog:
- include:
file: add-note-to-category.yaml
relativeToChangelogFile: true
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export interface Category {
id?: number;
name: string;
emoji: string;
note?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ <h3 class="fs-1 fw-bold">New category</h3>
</div>
}
</div>

@let noteControl = form.controls.note;
<mat-form-field>
<mat-label>Note</mat-label>
<textarea matInput cdkTextareaAutosize cdkAutosizeMinRows="4" [formControl]="noteControl"></textarea>
<mat-error>
<ex-validator [control]="noteControl" />
</mat-error>
</mat-form-field>
</mat-card-content>

<mat-card-actions class="justify-content-end align-items-center gap-2 w-100 px-4 pt-0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class CreateCategoryDialogComponent extends DialogComponent<undefined, bo
form = this.fb.group({
name: this.fb.control<string>('', [Validators.required, Validators.maxLength(255)]),
emoji: this.fb.control<string>('', [Validators.required]),
note: this.fb.control<string>('', [Validators.maxLength(500)]),
});

emojiInvalid = false;
Expand All @@ -69,6 +70,7 @@ export class CreateCategoryDialogComponent extends DialogComponent<undefined, bo
const request: Category = {
name: formValue.name,
emoji: formValue.emoji,
note: formValue.note,
};
try {
const newCategory = await this.categoryService.create(request);
Expand Down
Loading