Merge branch 'next' of groeger-clan.duckdns.org:newgeruecht-vue into next

This commit is contained in:
Dominik 2021-02-01 20:18:41 +01:00
commit 8dbd6cc5eb
9 changed files with 30 additions and 21 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 998 B

After

Width:  |  Height:  |  Size: 967 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

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

View File

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

View File

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

View File

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