chore(cleanup): Run prettier + Fix some eslint issues
continuous-integration/woodpecker the build was successful Details

This commit is contained in:
Ferdinand Thiessen 2021-12-14 14:15:40 +01:00
parent ef5c8eec5b
commit 8fe73b2cab
8 changed files with 51 additions and 113 deletions

View File

@ -1,26 +1,10 @@
<template>
<div class="col-sm-4 col-xs-12">
<q-input
v-model.number="amount"
type="number"
filled
label="Eigener Betrag"
step="0.1"
min="0"
suffix="€"
/>
<q-input v-model.number="amount" type="number" filled label="Eigener Betrag" step="0.1" min="0" suffix="€" />
</div>
<div class="col-sm-4 col-xs-6">
<q-btn
v-close-popup
style="width: 100%"
color="primary"
label="Anschreiben"
@click="changeBalance(amount * -1)"
>
<q-tooltip v-if="canAddShortcut">
Rechtsklick um Betrag als Verknüpfung hinzuzufügen
</q-tooltip>
<q-btn v-close-popup style="width: 100%" color="primary" label="Anschreiben" @click="changeBalance(amount * -1)">
<q-tooltip v-if="canAddShortcut"> Rechtsklick um Betrag als Verknüpfung hinzuzufügen </q-tooltip>
<q-menu v-if="canAddShortcut" anchor="bottom middle" self="top middle" context-menu>
<q-btn label="neue Verknüpfung" @click="addShortcut"></q-btn>
</q-menu>

View File

@ -2,7 +2,7 @@
<q-card-section class="fit row justify-left content-center items-center q-col-gutter-sm">
<div class="col-5">
<div v-if="balance" class="text-h6">
Aktueller Stand: {{ balance.balance ? balance.balance.toFixed(2) : "" }}
Aktueller Stand: {{ balance.balance ? balance.balance.toFixed(2) : '' }}
<q-badge v-if="isLocked" color="negative" align="top"> gesperrt </q-badge>
</div>
<q-spinner v-else color="primary" size="3em" />
@ -22,7 +22,6 @@ import UserSelector from '@flaschengeist/users/src/components/UserSelector.vue';
import { useMainStore } from '@flaschengeist/api';
import { useBalanceStore } from '../store';
export default defineComponent({
name: 'BalanceHeader',
components: { UserSelector },
@ -40,9 +39,7 @@ export default defineComponent({
onBeforeMount(() => void store.getBalance(mainStore.currentUser));
const balance = computed(() =>
store.balances.find((x) => x.userid === props.modelValue.userid)
);
const balance = computed(() => store.balances.find((x) => x.userid === props.modelValue.userid));
const isLocked = computed(
() =>

View File

@ -35,7 +35,7 @@ import { ref, computed, defineComponent, onUnmounted, onMounted, PropType } from
import { useBalanceStore } from '../store';
export default defineComponent({
name: 'Transaction',
name: 'BalanceTransaction',
props: {
transaction: {
required: true,

View File

@ -1,10 +1,10 @@
<template>
<q-card>
<BalanceHeader v-model="sender" :show-selector="showSelector" @open-history="openHistory" />
<q-separator />
<q-card-section class="row q-col-gutter-md items-center">
<balance-transfer-body :user="sender" />
</q-card-section>
<BalanceHeader v-model="sender" :show-selector="showSelector" @open-history="openHistory" />
<q-separator />
<q-card-section class="row q-col-gutter-md items-center">
<balance-transfer-body :user="sender" />
</q-card-section>
</q-card>
</template>

View File

@ -1,14 +1,6 @@
<template>
<div class="col-sm-4 col-xs-12">
<q-input
v-model.number="amount"
type="number"
filled
label="Betrag"
step="0.1"
min="0"
suffix="€"
/>
<q-input v-model.number="amount" type="number" filled label="Betrag" step="0.1" min="0" suffix="€" />
</div>
<div class="col-sm-4 col-xs-6">
<UserSelector v-model="receiver" label="Empfänger" />
@ -53,12 +45,7 @@ export default defineComponent({
);
const sendDisabled = computed(() => {
return !(
receiver.value &&
sender.value &&
sender.value.userid != receiver.value.userid &&
amount.value > 0
);
return !(receiver.value && sender.value && sender.value.userid != receiver.value.userid && amount.value > 0);
});
async function sendAmount() {

View File

@ -1,18 +1,10 @@
<template>
<div>
<q-page padding>
<q-table :rows="rows" row-key="userid" :columns="columns" v-model:pagination="pagination" @request="onRequest">
<q-table v-model:pagination="pagination" :rows="rows" row-key="userid" :columns="columns" @request="onRequest">
<template #top-right>
<div class="full-width row q-gutter-sm">
<q-input
v-model.number="limit"
label="Limit"
type="number"
step="0.01"
suffix="€"
filled
dense
/>
<q-input v-model.number="limit" label="Limit" type="number" step="0.01" suffix="€" filled dense />
<q-btn label="Limits Setzen" color="primary" dense @click="setLimits(limit)" />
</div>
</template>
@ -22,7 +14,7 @@
{{ getFirstname(props.row.userid) }}
</q-td>
<q-td key="lastname" :props="props">
{{ getLastname(props.row.userid)}}
{{ getLastname(props.row.userid) }}
</q-td>
<q-td key="limit" :props="props">
{{ getLimit(props.row.userid) || 'Kein Limit' }}
@ -35,15 +27,7 @@
@save="setLimit(props.row.userid)"
@cancel="limit = undefined"
>
<q-input
v-model.number="scope.value"
label="Limit"
type="number"
step="0.01"
suffix="€"
filled
dense
/>
<q-input v-model.number="scope.value" label="Limit" type="number" step="0.01" suffix="€" filled dense />
</q-popup-edit>
</q-td>
<q-td key="balance" :props="props">
@ -56,14 +40,11 @@
<balance-add-body
:user="props.row.userid"
:can-add-shortcut="false"
@changeBalance="updateBalance"
@change-balance="updateBalance"
/>
</q-tab-panel>
<q-tab-panel name="transfer" class="fit column q-gutter-sm">
<balance-transfer-body
:user="props.row.userid"
@changeBalance="updateBalances"
/>
<balance-transfer-body :user="props.row.userid" @change-balance="updateBalances" />
</q-tab-panel>
</q-tab-panels>
</q-card-section>
@ -97,21 +78,21 @@
import { ref, defineComponent, computed, onBeforeMount } from 'vue';
import { useBalanceStore } from '../store';
import {useUserStore} from '@flaschengeist/api';
import { useUserStore } from '@flaschengeist/api';
import BalanceAddBody from '../components/BalanceAddBody.vue';
import BalanceTransferBody from '../components/BalanceTransferBody.vue';
export default defineComponent({
name: 'BalanceAdminPage',
components: { BalanceTransferBody, BalanceAddBody },
// name: 'PageName'
setup() {
const store = useBalanceStore();
const userStore = useUserStore();
onBeforeMount( () => {
onBeforeMount(() => {
void userStore.getUsers();
void store.getLimits();
void onRequest({pagination: pagination.value, filter: undefined})
void onRequest({ pagination: pagination.value, filter: undefined });
});
const rows = computed(() => store.balances);
@ -123,14 +104,14 @@ export default defineComponent({
label: 'Vorname',
field: 'userid',
align: 'left',
sortable: true
sortable: true,
},
{
name: 'lastname',
label: 'Vorname',
field: 'userid',
align: 'left',
sortable: true
sortable: true,
},
{
name: 'limit',
@ -138,15 +119,14 @@ export default defineComponent({
align: 'right',
field: 'userid',
format: (_: undefined, row: { userid: string }) => getLimit(row.userid),
sortable: true
sortable: true,
},
{
name: 'balance',
label: 'Kontostand',
align: 'right',
field: 'userid',
format: (_: undefined, row: { debit: number; credit: number }) =>
getBalance(row.debit, row.credit),
format: (_: undefined, row: { debit: number; credit: number }) => getBalance(row.debit, row.credit),
sortable: true,
},
];
@ -165,12 +145,12 @@ export default defineComponent({
rowsNumber: 10,
descending: false,
page: 1,
})
});
const loading = ref(false)
const loading = ref(false);
async function onRequest(props: {pagination: PaginationInterface; filter?: string}) {
const {page, rowsPerPage, sortBy, descending} = props.pagination;
async function onRequest(props: { pagination: PaginationInterface; filter?: string }) {
const { page, rowsPerPage, sortBy, descending } = props.pagination;
loading.value = true;
const fetchCount = rowsPerPage === 0 ? pagination.value.rowsNumber : rowsPerPage;
const startRow = (page - 1) * rowsPerPage;
@ -181,17 +161,17 @@ export default defineComponent({
offset: startRow,
descending: descending ? true : undefined,
sortBy,
})
});
pagination.value.page = page;
pagination.value.rowsPerPage = rowsPerPage;
pagination.value.sortBy = sortBy;
pagination.value.descending = descending;
if (result.count) pagination.value.rowsNumber = result.count;
} catch (error) {
console.warn(error)
console.warn(error);
}
console.log(pagination.value)
loading.value = false
console.log(pagination.value);
loading.value = false;
}
function getName(val: string) {
@ -200,7 +180,7 @@ export default defineComponent({
function getLimit(val: string) {
const limit = store.user_limits.find((a) => a.userid === val)?.limit?.toFixed(2);
return limit ? `${limit}` : undefined
return limit ? `${limit}` : undefined;
}
function getBalance(debit: number, credit: number) {
@ -226,11 +206,11 @@ export default defineComponent({
}
function getFirstname(userid: string) {
return userStore.users.find((a) => a.userid === userid)?.firstname
return userStore.users.find((a) => a.userid === userid)?.firstname;
}
function getLastname(userid: string) {
return userStore.users.find((a) => a.userid === userid)?.lastname
return userStore.users.find((a) => a.userid === userid)?.lastname;
}
const tab = ref('add');
@ -239,7 +219,7 @@ export default defineComponent({
rows,
columns,
limit,
setLimits: store.setLimits,
setLimits: (l: number) => store.setLimits(l),
getName,
getLimit,
setLimit,

View File

@ -42,7 +42,7 @@ import { computed, defineComponent, onMounted, ref } from 'vue';
import { useBalanceStore } from '../store';
export default defineComponent({
// name: 'PageName'
name: 'BalanceOverviewPage',
setup() {
const store = useBalanceStore();
const mainStore = useMainStore();

View File

@ -1,12 +1,7 @@
<template>
<q-page padding class="fit row justify-center content-start items-start q-gutter-sm">
<q-tabs v-if="$q.screen.gt.sm" v-model="tab">
<q-tab
v-for="(tabindex, index) in tabs"
:key="'tab' + index"
:name="tabindex.name"
:label="tabindex.label"
/>
<q-tab v-for="(tabindex, index) in tabs" :key="'tab' + index" :name="tabindex.name" :label="tabindex.label" />
</q-tabs>
<div v-else class="fit row justify-end">
<q-btn
@ -33,18 +28,13 @@
</q-list>
<q-list v-if="show">
<div v-for="(transaction, index) in transactions" :key="index" class="col-sm-12">
<Transaction v-model:transaction="transactions[index]" />
<balance-transaction v-model:transaction="transactions[index]" />
</div>
</q-list>
</q-drawer>
<q-tab-panels
v-model="tab"
style="background-color: transparent"
class="q-pa-none col-12"
animated
>
<q-tab-panels v-model="tab" style="background-color: transparent" class="q-pa-none col-12" animated>
<q-tab-panel name="add" class="q-px-xs">
<BalanceAdd
<balance-add
@open-history="
showDrawer = !showDrawer;
show = true;
@ -52,7 +42,7 @@
/>
</q-tab-panel>
<q-tab-panel name="transfer" class="q-px-xs">
<BalanceTransfer
<balance-transfer
@open-history="
showDrawer = !showDrawer;
show = true;
@ -66,15 +56,16 @@
<script lang="ts">
import { computed, defineComponent, ref, onMounted } from 'vue';
import { hasSomePermissions, useMainStore } from '@flaschengeist/api';
import BalanceTransfer from '../components/BalanceTransfer.vue';
import Transaction from '../components/Transaction.vue';
import BalanceAdd from '../components/BalanceAdd.vue';
import { useBalanceStore } from '../store';
import PERMISSIONS from '../permissions';
import BalanceTransaction from '../components/BalanceTransaction.vue';
import BalanceTransfer from '../components/BalanceTransfer.vue';
import BalanceAdd from '../components/BalanceAdd.vue';
export default defineComponent({
name: 'BalanceManage',
components: { BalanceAdd, BalanceTransfer, Transaction },
components: { BalanceAdd, BalanceTransfer, BalanceTransaction },
setup() {
const balanceStore = useBalanceStore();
const mainStore = useMainStore();
@ -93,8 +84,7 @@ export default defineComponent({
.sort((a, b) => (a.time >= b.time ? -1 : 1));
});
const canAdd = () =>
hasSomePermissions([PERMISSIONS.DEBIT, PERMISSIONS.CREDIT, PERMISSIONS.DEBIT_OWN]);
const canAdd = () => hasSomePermissions([PERMISSIONS.DEBIT, PERMISSIONS.CREDIT, PERMISSIONS.DEBIT_OWN]);
interface Tab {
name: string;