-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f32305
commit 158d55e
Showing
10 changed files
with
119 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use crate::entities::bank_accounts; | ||
use rusqlite::Connection; | ||
use std::ops::Deref; | ||
use std::sync::Mutex; | ||
use tauri::State; | ||
|
||
#[tauri::command] | ||
pub(crate) fn bank_account_get_by_id(conn_state: State<'_, Mutex<Connection>>, id: String) -> String { | ||
let conn = conn_state | ||
.inner() | ||
.lock() | ||
.expect("Could not retrieve database connection"); | ||
let conn = conn.deref(); | ||
|
||
let id_as_u32: u32 = id.parse().unwrap(); | ||
|
||
serde_json::to_string(&bank_accounts::get_by_id(conn, id_as_u32)) | ||
.expect("Could not serialize BankAccount properly") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { | ||
CallbackStateProcessor, | ||
CallbackStateProvider, | ||
CrudDefinition, Edit, | ||
List, | ||
TextField, | ||
UrlAction, | ||
} from "@orbitale/svelte-admin"; | ||
import type {CrudBankAccount} from "@orbitale/svelte-admin/dist/Crud/BankAccounts"; | ||
import type {RequestParameters} from "@orbitale/svelte-admin/dist/request"; | ||
import {getBankAccountById, getBankAccounts} from "$lib/db/bank_accounts"; | ||
import type BankAccount from "$lib/entities/BankAccount"; | ||
|
||
const baseFields = [ | ||
new TextField('name', 'Name'), | ||
new TextField('slug', 'Identifier'), | ||
new TextField('currency', 'Currency'), | ||
]; | ||
|
||
export default new CrudDefinition<BankAccount>('bank-accounts', { | ||
defaultOperationName: "list", | ||
label: {plural: "BankAccounts", singular: "BankAccount"}, | ||
// minStateLoadingTimeMs: 0, | ||
|
||
operations: [ | ||
new List([...baseFields], | ||
[ | ||
new UrlAction('Edit', '/crud/bank-accounts/edit'), | ||
]), | ||
new Edit(baseFields), | ||
], | ||
|
||
stateProvider: new CallbackStateProvider<BankAccount>(async (bankAccount: CrudBankAccount, requestParameters: RequestParameters) => { | ||
if (typeof window === 'undefined') { | ||
// SSR, can't call Tauri API then. | ||
return Promise.resolve([]); | ||
} | ||
|
||
if (bankAccount.name === 'list') { | ||
const results = await getBankAccounts(requestParameters.page||1); | ||
return Promise.resolve(results); | ||
} | ||
|
||
if (bankAccount.name === 'view' || bankAccount.name === 'edit') { | ||
return getBankAccountById(requestParameters.id); | ||
} | ||
|
||
return Promise.resolve(null); | ||
}), | ||
stateProcessor: new CallbackStateProcessor<BankAccount>(() => {}) | ||
}); |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters