-
Notifications
You must be signed in to change notification settings - Fork 1
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
b679871
commit ea1eb7b
Showing
17 changed files
with
406 additions
and
27 deletions.
There are no files selected for viewing
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,16 @@ | ||
<template> | ||
<div @click="emit('event')"> | ||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"> | ||
<path stroke-linecap="round" stroke-linejoin="round" d="M21 12a2.25 2.25 0 00-2.25-2.25H15a3 3 0 11-6 0H5.25A2.25 2.25 0 003 12m18 0v6a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 18v-6m18 0V9M3 12V9m18 0a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 9m18 0V6a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 6v3" /> | ||
</svg> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
const emit = defineEmits(['event']); | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
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,138 @@ | ||
<template> | ||
<modal-base :title="$t('modals.setAccumulation.title')" :opened="opened" :name="'accumulation-set-modal'"> | ||
<div class="w-full flex flex-col gap-2"> | ||
<div class="flex justify-center"> | ||
<accounts-entry class="templateBorder w-1/2" v-if="account" :account="account" :hide-buttons="true"/> | ||
</div> | ||
|
||
<div class="flex gap-2"> | ||
<div class="form-control w-full"> | ||
<label class="label"> | ||
<span class="label-text">{{ $t('modals.setAccumulation.placeholders.targetAccount') }}</span> | ||
</label> | ||
|
||
<select-account v-model="targetAccountId" :exclude-account="sourceAccountId" :currency-filter="currencyFilter"/> | ||
</div> | ||
|
||
<div class="form-control w-full"> | ||
<label class="label"> | ||
<span class="label-text">{{ $t('modals.setAccumulation.placeholders.tag') }}</span> | ||
</label> | ||
|
||
<select-transaction-tag v-model="tagId" :can-be-without-parent="false" :tags-tree="tagsTree"/> | ||
</div> | ||
</div> | ||
|
||
<step-entry v-for="(step, index) in steps" :model-value="step" @update:model-value="args => steps[index] = args"/> | ||
|
||
<div class="w-full" v-if="configs.maxStepsPerAccount > steps.length"> | ||
<plus-button class="btn w-full" @event="steps.push({from: null, to: null, step: null})" /> | ||
</div> | ||
</div> | ||
|
||
<div class="modal-action justify-between"> | ||
<delete-button @click="deleteAccumulation" class="btn btn-sm btn-error" :class="{'btn-warning' : !allValid}">{{ $t('modals.buttons.delete') }}</delete-button> | ||
|
||
<div class="flex gap-2"> | ||
<button @click="close" class="btn btn-sm btn-ghost">{{ $t('modals.buttons.cancel') }}</button> | ||
<button @click="set" class="btn btn-sm btn-success" :class="{'btn-warning' : !allValid}">{{ $t('modals.buttons.set') }}</button> | ||
</div> | ||
</div> | ||
</modal-base> | ||
</template> | ||
|
||
<script setup> | ||
import StepEntry from "~/components/modal/accumulation/stepEntry.vue"; | ||
import PlusButton from "~/components/buttons/plusButton.vue"; | ||
import DeleteButton from "~/components/buttons/deleteButton.vue"; | ||
const props = defineProps({ | ||
opened: { | ||
type: Boolean, | ||
required: true | ||
}, | ||
account: { | ||
required: true | ||
} | ||
}) | ||
const { t } = useI18n(); | ||
const emit = defineEmits(['close']) | ||
const close = () => { | ||
emit('close') | ||
} | ||
const {$serverConfigs, $accumulationsApi, $transactionsTagsApi, $toastsManager} = useNuxtApp(); | ||
const configs = $serverConfigs.configs.accumulation; | ||
const accumulationMap = $accumulationsApi.getAccumulationMap(); | ||
const tagsTree = $transactionsTagsApi.getTagsTree(); | ||
const highlightErrors = ref(false); | ||
const allValid = computed(() => sourceAccountId.value && targetAccountId.value && tagId.value && steps.value.length > 0 && !steps.value.find(v => !v.step)) | ||
const account = ref(); | ||
const steps = ref([]); | ||
const sourceAccountId = ref(); | ||
const targetAccountId = ref(); | ||
const tagId = ref(); | ||
const currencyFilter = ref(); | ||
watch(() => props.opened, (value) => { | ||
if (!value) | ||
return; | ||
const v = accumulationMap.value.get(props.account.accountId) || {}; | ||
sourceAccountId.value = props.account.accountId; | ||
targetAccountId.value = v.targetAccountId; | ||
tagId.value = v.tagId; | ||
steps.value = v.steps || [{from: null, to: null, steps: null}]; | ||
account.value = props.account; | ||
currencyFilter.value = props.account.currencyId; | ||
}) | ||
const set = () => { | ||
if (!allValid.value) { | ||
highlightErrors.value = true; | ||
return; | ||
} | ||
const result = { | ||
sourceAccountId: sourceAccountId.value, | ||
targetAccountId: targetAccountId.value, | ||
tagId: tagId.value, | ||
steps: steps.value | ||
} | ||
highlightErrors.value = false; | ||
close(); | ||
$accumulationsApi.setAccumulation(result).then((s) => { | ||
if (s) | ||
$toastsManager.pushToast(t("modals.setAccumulation.messages.success"), 2500, "success") | ||
else | ||
$toastsManager.pushToast(t("modals.setAccumulation.messages.error"), 3000,"error") | ||
}); | ||
} | ||
const deleteAccumulation = () => { | ||
close(); | ||
$accumulationsApi.removeAccumulation(sourceAccountId.value).then((s) => { | ||
if (s) | ||
$toastsManager.pushToast(t("modals.setAccumulation.messages.deleted"), 2500, "success") | ||
else | ||
$toastsManager.pushToast(t("modals.setAccumulation.messages.error"), 3000,"error") | ||
}); | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
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 @@ | ||
<template> | ||
<div class="join flex"> | ||
<input class="input input-bordered join-item w-full" :placeholder="t('modals.setAccumulation.placeholders.stepEntry.from')" v-model.lazy="from" @change="update"/> | ||
<input class="input input-bordered join-item w-full" :placeholder="t('modals.setAccumulation.placeholders.stepEntry.to')" v-model.lazy="to" @change="update"/> | ||
<input class="input input-bordered join-item w-full" :placeholder="t('modals.setAccumulation.placeholders.stepEntry.step')" v-model.lazy="step" @change="update"/> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
const props = defineProps({ | ||
modelValue: { | ||
} | ||
}) | ||
const { t } = useI18n(); | ||
const from = ref(null); | ||
const to = ref(null); | ||
const step = ref(10); | ||
const emit = defineEmits(['update:modelValue', 'updated']) | ||
const update = () => { | ||
if (from.value === props.modelValue.from && to.value === props.modelValue.to && step.value === props.modelValue.step) | ||
return; | ||
emit("update:modelValue", { | ||
from: from.value, | ||
to: to.value, | ||
step: step.value | ||
}); | ||
emit("updated"); | ||
} | ||
watch(() => props.modelValue, () => { | ||
from.value = props.modelValue.from; | ||
to.value = props.modelValue.to; | ||
step.value = props.modelValue.step; | ||
}); | ||
from.value = props.modelValue.from; | ||
to.value = props.modelValue.to; | ||
step.value = props.modelValue.step; | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
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
Oops, something went wrong.