mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 23:47:33 +08:00
migrate transaction tag store to composition API and typescript
This commit is contained in:
@@ -1,3 +1,48 @@
|
||||
export class TransactionTag implements TransactionTagInfoResponse {
|
||||
public id: string;
|
||||
public name: string;
|
||||
public displayOrder: number;
|
||||
public hidden: boolean;
|
||||
|
||||
private constructor(id: string, name: string, displayOrder: number, hidden: boolean) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.displayOrder = displayOrder;
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
public toCreateRequest(): TransactionTagCreateRequest {
|
||||
return {
|
||||
name: this.name
|
||||
};
|
||||
}
|
||||
|
||||
public toModifyRequest(): TransactionTagModifyRequest {
|
||||
return {
|
||||
id: this.id,
|
||||
name: this.name
|
||||
};
|
||||
}
|
||||
|
||||
public static of(tagResponse: TransactionTagInfoResponse): TransactionTag {
|
||||
return new TransactionTag(tagResponse.id, tagResponse.name, tagResponse.displayOrder, tagResponse.hidden);
|
||||
}
|
||||
|
||||
public static ofMany(tagResponses: TransactionTagInfoResponse[]): TransactionTag[] {
|
||||
const tags: TransactionTag[] = [];
|
||||
|
||||
for (const tagResponse of tagResponses) {
|
||||
tags.push(TransactionTag.of(tagResponse));
|
||||
}
|
||||
|
||||
return tags;
|
||||
}
|
||||
|
||||
public static createNewTag(): TransactionTag {
|
||||
return new TransactionTag('', '', 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
export interface TransactionTagCreateRequest {
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user