Add CategoryTypes

This commit is contained in:
William Brawner 2018-08-30 18:14:39 -05:00
parent 2c8801fa53
commit 7fe7b67c29
5 changed files with 14 additions and 1 deletions

View file

@ -21,6 +21,10 @@
<mat-form-field>
<input matInput type="number" [(ngModel)]="currentCategory.amount" placeholder="Amount" required>
</mat-form-field>
<mat-radio-group [(ngModel)]="currentCategory.type">
<mat-radio-button [value]="categoryType.LIMIT">Limit</mat-radio-button>
<mat-radio-button [value]="categoryType.GOAL">Goal</mat-radio-button>
</mat-radio-group>
<mat-form-field>
<input type="color" matInput [(ngModel)]="currentCategory.color" placeholder="Color">
</mat-form-field>

View file

@ -1,6 +1,7 @@
import { Component, OnInit, Input } from '@angular/core';
import { CategoryService } from '../category.service'
import { Category } from '../category'
import { CategoryType } from '../category.type'
import { Location } from '@angular/common';
@Component({
@ -12,6 +13,7 @@ export class AddEditCategoryComponent implements OnInit {
@Input() title: string;
@Input() currentCategory: Category;
public categoryType = CategoryType;
constructor(
private categoryService: CategoryService,

View file

@ -15,7 +15,7 @@ export class BudgetDatabase extends Dexie {
super('BudgetDatabase')
this.version(1).stores({
transactions: `++id, title, description, amount, date, category, type`,
categories: `++id, name, amount, repeat, color`
categories: `++id, name, amount, repeat, color, type-`
})
this.transactions.mapToClass(Transaction)
this.categories.mapToClass(Category)
@ -38,4 +38,5 @@ export interface ICategory{
amount: number;
repeat: string;
color: string;
type: CategoryType;
}

View file

@ -1,4 +1,5 @@
import { ICategory } from './budget-database'
import { CategoryType } from './category.type'
export class Category implements ICategory {
id: number;
@ -6,4 +7,5 @@ export class Category implements ICategory {
amount: number;
repeat: string;
color: string;
type: CategoryType = CategoryType.LIMIT;
}

4
src/app/category.type.ts Normal file
View file

@ -0,0 +1,4 @@
export enum CategoryType {
LIMIT,
GOAL
}