mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 09:14:27 +08:00
migrate transaction template store to composition API and typescript
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { TransactionTemplate } from '@/models/transaction_template.ts';
|
||||
|
||||
export function isNoAvailableTemplate(templates: TransactionTemplate[], showHidden: boolean): boolean {
|
||||
for (let i = 0; i < templates.length; i++) {
|
||||
if (showHidden || !templates[i].hidden) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function getAvailableTemplateCount(templates: TransactionTemplate[], showHidden: boolean): number {
|
||||
let count = 0;
|
||||
|
||||
for (let i = 0; i < templates.length; i++) {
|
||||
if (showHidden || !templates[i].hidden) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
export function getFirstShowingId(templates: TransactionTemplate[], showHidden: boolean): string | null {
|
||||
for (let i = 0; i < templates.length; i++) {
|
||||
if (showHidden || !templates[i].hidden) {
|
||||
return templates[i].id;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getLastShowingId(templates: TransactionTemplate[], showHidden: boolean): string | null {
|
||||
for (let i = templates.length - 1; i >= 0; i--) {
|
||||
if (showHidden || !templates[i].hidden) {
|
||||
return templates[i].id;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user