Remove category types
This commit is contained in:
parent
2b8580f8e8
commit
b4d7c831e9
6 changed files with 11 additions and 23 deletions
|
@ -21,10 +21,6 @@
|
|||
<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">
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
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({
|
||||
|
@ -13,7 +12,6 @@ export class AddEditCategoryComponent implements OnInit {
|
|||
|
||||
@Input() title: string;
|
||||
@Input() currentCategory: Category;
|
||||
public categoryType = CategoryType;
|
||||
|
||||
constructor(
|
||||
private categoryService: CategoryService,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import Dexie from 'dexie';
|
||||
import { Category } from './category'
|
||||
import { CategoryType } from './category.type';
|
||||
import { Transaction } from './transaction'
|
||||
import { TransactionType } from './transaction.type';
|
||||
|
||||
|
@ -22,6 +21,10 @@ export class BudgetDatabase extends Dexie {
|
|||
transactions: `++id, title, description, amount, date, category_id, type`,
|
||||
categories: `++id, name, amount, repeat, color, type`
|
||||
})
|
||||
this.version(3).stores({
|
||||
transactions: `++id, title, description, amount, date, category_id, type`,
|
||||
categories: `++id, name, amount, repeat, color`
|
||||
})
|
||||
this.transactions.mapToClass(Transaction)
|
||||
this.categories.mapToClass(Category)
|
||||
}
|
||||
|
@ -43,5 +46,4 @@ export interface ICategory{
|
|||
amount: number;
|
||||
repeat: string;
|
||||
color: string;
|
||||
type: CategoryType;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { Category } from '../category'
|
||||
import { CategoryType } from '../category.type'
|
||||
|
||||
@Component({
|
||||
selector: 'app-category-list',
|
||||
|
@ -53,15 +52,14 @@ export class CategoryListComponent implements OnInit {
|
|||
categoryBalance = 0
|
||||
}
|
||||
|
||||
if (category.type === CategoryType.LIMIT) {
|
||||
// If the category is a limit, then a negative balance needs to be turned into positive
|
||||
// and vice-versa for the completion to be properly calculated
|
||||
// Invert the negative/positive values for calculating progress
|
||||
// since the limit for a category is saved as a positive but the
|
||||
// balance is used in the calculation.
|
||||
if (categoryBalance < 0) {
|
||||
categoryBalance = Math.abs(categoryBalance)
|
||||
} else {
|
||||
categoryBalance -= (categoryBalance * 2)
|
||||
}
|
||||
}
|
||||
|
||||
return categoryBalance / category.amount * 100;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { ICategory } from './budget-database'
|
||||
import { CategoryType } from './category.type'
|
||||
|
||||
export class Category implements ICategory {
|
||||
id: number;
|
||||
|
@ -7,5 +6,4 @@ export class Category implements ICategory {
|
|||
amount: number;
|
||||
repeat: string;
|
||||
color: string;
|
||||
type: CategoryType = CategoryType.LIMIT;
|
||||
}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
export enum CategoryType {
|
||||
LIMIT,
|
||||
GOAL
|
||||
}
|
Loading…
Reference in a new issue