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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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