release v2.0.0 #4

Merged
crimsen merged 481 commits from develop into master 2024-01-18 15:15:08 +00:00
4 changed files with 30 additions and 21 deletions
Showing only changes of commit 44b50edf82 - Show all commits

View File

@ -10,7 +10,7 @@
track-color="grey-3"
>
<q-avatar size="60px">
<img src="logo-dark.svg" />
<img src="flaschengeist-logo.svg" />
</q-avatar>
</q-circular-progress>
</template>

View File

@ -10,7 +10,7 @@
track-color="grey-3"
>
<q-avatar size="60px">
<img src="logo.svg" />
<img src="flaschengeist-logo.svg" />
</q-avatar>
</q-circular-progress>
</template>

View File

@ -42,10 +42,10 @@
animated
>
<q-tab-panel name="add" class="q-px-xs">
<BalanceAdd @open-history="showDrawer = !showDrawer; show = showDrawer"/>
<BalanceAdd @open-history="showDrawer = !showDrawer; show = true"/>
</q-tab-panel>
<q-tab-panel name="transfer" class="q-px-xs">
<BalanceTransfer @open-history="showDrawer = !showDrawer; show = showDrawer"/>
<BalanceTransfer @open-history="showDrawer = !showDrawer; show = true"/>
</q-tab-panel>
</q-tab-panels>
</q-page>
@ -70,13 +70,17 @@ export default defineComponent({
const store = <Store<StateInterfaceBalance>>root.$store;
const now = new Date()
onMounted(() => {
void store.dispatch('balance/getTransactions', {filter: {from: new Date(now.getFullYear(), now.getMonth(), now.getDay())}})
void store.dispatch('balance/getTransactions', {filter: {from: new Date(now.getFullYear(), now.getMonth(), now.getDate())}})
})
const transactions = computed(() =>
store.state.balance.transactions
{
const a =store.state.balance.transactions
.filter(t => t.original_id == undefined)
.filter(t => t.time > new Date(now.getFullYear(), now.getMonth(), now.getDate()))
.sort((a, b) => (a.time >= b.time ? -1 : 1))
);
console.log(a)
return a
});
const canAdd = () =>
hasSomePermissions([PERMISSIONS.DEBIT, PERMISSIONS.CREDIT, PERMISSIONS.DEBIT_OWN], store);
@ -95,7 +99,7 @@ export default defineComponent({
const drawer = ref<boolean>(false);
const showDrawer = computed({
/* const showDrawer = computed({
get: () => {
return !Screen.gt.sm && drawer.value;
},
@ -103,7 +107,8 @@ export default defineComponent({
drawer.value = val;
}
});
*/
const showDrawer = ref<boolean>(false);
const tab = ref<string>(canAdd() ? 'add' : 'transfer');
const show = ref<boolean>(false);
return {

View File

@ -37,7 +37,7 @@ const state: BalanceInterface = {
balances: new Map<string, UserBalance>(),
shortcuts: [],
transactions: [],
loading: 0
loading: 0,
};
function fixTransaction(t: FG.Transaction) {
@ -73,15 +73,19 @@ const mutations: MutationTree<BalanceInterface> = {
state.transactions.push(data);
},
addTransactions(state, data: [FG.Transaction]) {
state.transactions.push(...data);
data.forEach((transaction) => {
if (!state.transactions.find((t) => t.id == transaction.id)) {
state.transactions.push(transaction);
}
});
state.transactions.sort((a, b) => (a.time <= b.time ? -1 : 1));
},
reverseTransaction(state, data: { transaction: FG.Transaction; reversal: FG.Transaction }) {
const idx = state.transactions.findIndex(value => value.id === data.transaction.id);
const idx = state.transactions.findIndex((value) => value.id === data.transaction.id);
data.transaction.reversal_id = data.reversal.id;
if (idx > -1) state.transactions[idx] = data.transaction;
else state.transactions.push(data.transaction);
}
},
};
const actions: ActionTree<BalanceInterface, StateInterface> = {
@ -151,7 +155,7 @@ const actions: ActionTree<BalanceInterface, StateInterface> = {
return axios
.get(`/users/${payload.userid}/balance/transactions`, { params: payload.filter || {} })
.then(({ data }: AxiosResponse<TransactionsResponse>) => {
data.transactions.forEach(t => fixTransaction(t));
data.transactions.forEach((t) => fixTransaction(t));
commit('addTransactions', data.transactions);
return data;
})
@ -165,7 +169,7 @@ const actions: ActionTree<BalanceInterface, StateInterface> = {
.then(({ data }) => {
console.log(data);
})
.catch(err => {
.catch((err) => {
console.warn(err);
})
.finally(() => commit('setLoading', false));
@ -176,7 +180,7 @@ const actions: ActionTree<BalanceInterface, StateInterface> = {
.then(({ data }: AxiosResponse<FG.Transaction>) => {
fixTransaction(data);
commit('reverseTransaction', { transaction: transaction, reversal: data });
dispatch('getBalance').catch(err => console.warn(err));
dispatch('getBalance').catch((err) => console.warn(err));
});
},
changeBalance(
@ -196,23 +200,23 @@ const actions: ActionTree<BalanceInterface, StateInterface> = {
commit('addTransaction', transaction);
commit(state.balances.has(data.user) ? 'changeBalance' : 'setBalance', {
userid: data.user,
amount: data.amount
amount: data.amount,
});
if (data.sender)
commit(state.balances.has(data.sender) ? 'changeBalance' : 'setBalance', {
userid: data.sender,
amount: -1 * data.amount
amount: -1 * data.amount,
});
return transaction;
})
.catch(err => {
.catch((err) => {
console.debug(err);
// Maybe Balance changed
void dispatch('getTransactions', {});
return dispatch('getBalance', data.sender ? data.sender : data.user);
})
.finally(() => commit('setLoading', false));
}
},
};
const getters: GetterTree<BalanceInterface, StateInterface> = {};
@ -222,7 +226,7 @@ const balance: Module<BalanceInterface, StateInterface> = {
state,
mutations,
actions,
getters
getters,
};
export default balance;