Skip to content

Commit

Permalink
Merge branch 'feat/operation_comment' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rednez committed Jan 21, 2023
2 parents 81993f6 + c4059ab commit 81f781c
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libs/api/data-access/src/lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class OperationCreateInput {
dateTime?: Nullable<string>;
withdrawalAmount?: Nullable<number>;
withdrawalCurrencyId?: Nullable<number>;
comment?: Nullable<string>;
}

export class OperationUpdateInput {
Expand All @@ -64,6 +65,7 @@ export class OperationUpdateInput {
dateTime?: Nullable<string>;
withdrawalAmount?: Nullable<number>;
withdrawalCurrencyId?: Nullable<number>;
comment?: Nullable<string>;
}

export class BudgetSummaryParams {
Expand Down Expand Up @@ -114,6 +116,7 @@ export class Operation {
withdrawalAmount?: Nullable<number>;
withdrawalCurrencyId?: Nullable<number>;
withdrawalCurrencyName?: Nullable<string>;
comment?: Nullable<string>;
}

export class BudgetRecord {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Operation" ADD COLUMN "comment" VARCHAR(128);
1 change: 1 addition & 0 deletions libs/api/db/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ model Operation {
groupId Int
withdrawalAmount Float?
withdrawalCurrencyId Int?
comment String? @db.VarChar(128)
}

model BudgetRecord {
Expand Down
11 changes: 11 additions & 0 deletions libs/front/data-access/src/lib/graphql/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export type Operation = {
__typename?: 'Operation';
amount: Scalars['Float'];
category: Category;
comment?: Maybe<Scalars['String']>;
currency: Currency;
dateTime: Scalars['String'];
group: Group;
Expand All @@ -210,6 +211,7 @@ export type Operation = {
export type OperationCreateInput = {
amount: Scalars['Float'];
categoryId: Scalars['Int'];
comment?: InputMaybe<Scalars['String']>;
currencyId: Scalars['Int'];
dateTime?: InputMaybe<Scalars['String']>;
groupId: Scalars['Int'];
Expand All @@ -220,6 +222,7 @@ export type OperationCreateInput = {
export type OperationUpdateInput = {
amount?: InputMaybe<Scalars['Float']>;
categoryId?: InputMaybe<Scalars['Int']>;
comment?: InputMaybe<Scalars['String']>;
currencyId?: InputMaybe<Scalars['Int']>;
dateTime?: InputMaybe<Scalars['String']>;
groupId?: InputMaybe<Scalars['Int']>;
Expand Down Expand Up @@ -370,6 +373,7 @@ export type OperationsQuery = {
withdrawalAmount?: number | null;
withdrawalCurrencyId?: number | null;
withdrawalCurrencyName?: string | null;
comment?: string | null;
currency: { __typename?: 'Currency'; id: number; name: string };
category: {
__typename?: 'Category';
Expand Down Expand Up @@ -399,6 +403,7 @@ export type OperationQuery = {
dateTime: string;
withdrawalAmount?: number | null;
withdrawalCurrencyId?: number | null;
comment?: string | null;
currency: { __typename?: 'Currency'; id: number; name: string };
group: { __typename?: 'Group'; id: number; name: string };
category: { __typename?: 'Category'; id: number; name: string };
Expand Down Expand Up @@ -478,6 +483,7 @@ export type UpdateOperationMutation = {
dateTime: string;
withdrawalAmount?: number | null;
withdrawalCurrencyId?: number | null;
comment?: string | null;
currency: { __typename?: 'Currency'; id: number; name: string };
group: { __typename?: 'Group'; id: number; name: string };
category: { __typename?: 'Category'; id: number; name: string };
Expand All @@ -497,6 +503,7 @@ export type CreateOperationMutation = {
dateTime: string;
withdrawalAmount?: number | null;
withdrawalCurrencyId?: number | null;
comment?: string | null;
currency: { __typename?: 'Currency'; id: number; name: string };
group: { __typename?: 'Group'; id: number; name: string };
category: { __typename?: 'Category'; id: number; name: string };
Expand Down Expand Up @@ -695,6 +702,7 @@ export const OperationsDocument = gql`
withdrawalAmount
withdrawalCurrencyId
withdrawalCurrencyName
comment
}
}
`;
Expand Down Expand Up @@ -732,6 +740,7 @@ export const OperationDocument = gql`
dateTime
withdrawalAmount
withdrawalCurrencyId
comment
}
}
`;
Expand Down Expand Up @@ -886,6 +895,7 @@ export const UpdateOperationDocument = gql`
dateTime
withdrawalAmount
withdrawalCurrencyId
comment
}
}
`;
Expand Down Expand Up @@ -923,6 +933,7 @@ export const CreateOperationDocument = gql`
dateTime
withdrawalAmount
withdrawalCurrencyId
comment
}
}
`;
Expand Down
4 changes: 4 additions & 0 deletions libs/front/data-access/src/lib/graphql/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ query Operations($params: OperationsParams!) {
withdrawalAmount
withdrawalCurrencyId
withdrawalCurrencyName
comment
}
}

Expand All @@ -105,6 +106,7 @@ query Operation($operationId: Int!) {
dateTime
withdrawalAmount
withdrawalCurrencyId
comment
}
}

Expand Down Expand Up @@ -186,6 +188,7 @@ mutation UpdateOperation($params: OperationUpdateInput!) {
dateTime
withdrawalAmount
withdrawalCurrencyId
comment
}
}

Expand All @@ -208,6 +211,7 @@ mutation CreateOperation($params: OperationCreateInput!) {
dateTime
withdrawalAmount
withdrawalCurrencyId
comment
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h1 class="mb-4">{{ headerTitle | translate }}</h1>
</mat-form-field>
</div>

<mat-form-field appearance="fill">
<mat-form-field appearance="fill" style="width: 50%">
<mat-label>{{ 'Date' | translate }}</mat-label>
<input matInput readonly formControlName="date" [matDatepicker]="picker" />
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
Expand All @@ -71,6 +71,14 @@ <h1 class="mb-4">{{ headerTitle | translate }}</h1>
}}</mat-error>
</mat-form-field>

<mat-form-field appearance="fill" style="width: 100%">
<mat-label>{{ 'Comment' | translate }}</mat-label>
<input matInput [maxLength]="maxCommentLength" formControlName="comment" />
<mat-error *ngIf="hasErrorIn('comment')">{{
'Max Length is 128 chars' | translate
}}</mat-error>
</mat-form-field>

<mat-checkbox
color="primary"
class="mb-2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface SubmitEventData {
isOtherWithdrawalCurrency: boolean;
withdrawalAmount?: number;
withdrawalCurrencyId?: number;
comment?: string;
}

@Component({
Expand All @@ -54,6 +55,8 @@ export class EditorFormComponent implements OnInit, OnChanges, OnDestroy {
@Output() createGroup = new EventEmitter();
@Output() createCategory = new EventEmitter<{ parentGroupId: number }>();

readonly maxCommentLength = 128;

operationForm!: FormGroup;
rate = 0;
categories: Category[] = [];
Expand Down Expand Up @@ -99,6 +102,7 @@ export class EditorFormComponent implements OnInit, OnChanges, OnDestroy {
dateTime,
withdrawalAmount,
withdrawalCurrencyId,
comment,
} = operation.currentValue as Operation;
this.operationForm?.setValue({
amount: amount,
Expand All @@ -109,6 +113,7 @@ export class EditorFormComponent implements OnInit, OnChanges, OnDestroy {
withdrawalAmount: withdrawalAmount,
withdrawalCurrencyId: withdrawalCurrencyId,
isOtherWithdrawalCurrency: !!withdrawalCurrencyId,
comment,
});
}

Expand Down Expand Up @@ -168,6 +173,7 @@ export class EditorFormComponent implements OnInit, OnChanges, OnDestroy {
isOtherWithdrawalCurrency: false,
withdrawalAmount: null,
withdrawalCurrencyId: null,
comment: ['', [Validators.maxLength(this.maxCommentLength)]],
});
}

Expand Down
3 changes: 3 additions & 0 deletions libs/shared/data-access/src/lib/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type Operation {
withdrawalAmount: Float
withdrawalCurrencyId: Int
withdrawalCurrencyName: String
comment: String
}

input OperationCreateInput {
Expand All @@ -72,6 +73,7 @@ input OperationCreateInput {
dateTime: String
withdrawalAmount: Float
withdrawalCurrencyId: Int
comment: String
}

input OperationUpdateInput {
Expand All @@ -83,6 +85,7 @@ input OperationUpdateInput {
dateTime: String
withdrawalAmount: Float
withdrawalCurrencyId: Int
comment: String
}

enum BudgetSummaryType {
Expand Down

0 comments on commit 81f781c

Please sign in to comment.