Skip to content

Commit 8b81c53

Browse files
committed
Some fixes, added username copy button
1 parent 62325c8 commit 8b81c53

File tree

9 files changed

+93
-19
lines changed

9 files changed

+93
-19
lines changed

components/analytics/totalByPeriod.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ const formatAmount = (delta) => {
5959
const buildChart = async () => {
6060
const newSeries = [
6161
{
62-
name: "Income",
62+
name: t("analyticsPage.income"),
6363
data: []
6464
},
6565
{
66-
name: "Expanse",
66+
name: t("analyticsPage.expanse"),
6767
data: []
6868
}
6969
];

components/modal/transaction/csvImport.vue

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@
187187

188188
</div>
189189
</div>
190+
191+
<label class="label cursor-pointer">
192+
<span class="label-text">{{ $t('modals.csvImport.immediatelyApply') }}</span>
193+
<input type="checkbox" class="toggle toggle-success" v-model="immediatelyApply"/>
194+
</label>
190195
</div>
191196

192197
</template>
@@ -226,13 +231,15 @@ const tags = $transactionsTagsApi.getTags();
226231
const tagsTree = $transactionsTagsApi.getTagsTree();
227232
const tagsMap = $transactionsTagsApi.getTagsTreeMap();
228233
229-
const emit = defineEmits(['close', 'addTransactions'])
234+
const emit = defineEmits(['close', 'addTransactions', 'applyTransactions'])
230235
const step = ref(0);
231236
232237
const parsedData = ref([])
233238
const maxColumns = ref(0);
234239
const ignoreFirst = ref(1);
235240
241+
const immediatelyApply = ref(false);
242+
236243
const columTypes = [
237244
"ignore",
238245
"account",
@@ -339,8 +346,18 @@ const transformToTransactions = () => {
339346
const unknownValuesFilled = () => {
340347
let result = true;
341348
349+
if (needAccount.value && !account.value)
350+
return false;
351+
352+
if (needTag.value && !tag.value)
353+
return false;
354+
355+
if (needDate.value && !date.value)
356+
return false;
357+
342358
unknownValues.value.forEach((v, k) => {
343359
v.forEach((name) => {
360+
344361
if (!unknownMap.value.get(k)[name]) {
345362
result = false;
346363
@@ -490,13 +507,20 @@ const nextStep = () => {
490507
491508
break;
492509
case 2:
493-
if (findUnknownValues()) {
510+
if (findUnknownValues() || !unknownValuesFilled()) {
494511
highlightError.value = true;
495512
496513
break;
497514
}
515+
498516
const transactions = transformToTransactions();
499517
518+
if (immediatelyApply.value) {
519+
emit('applyTransactions', transactions)
520+
521+
return;
522+
}
523+
500524
$toastsManager.pushToast(t("modals.csvImport.importMessage", transactions.length), 2500, "success")
501525
emit('addTransactions', transactions)
502526
}

components/nav/user/avatar.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<path stroke-linecap="round" stroke-linejoin="round" d="M17.982 18.725A7.488 7.488 0 0012 15.75a7.488 7.488 0 00-5.982 2.975m11.963 0a9 9 0 10-11.963 0m11.963 0A8.966 8.966 0 0112 21a8.966 8.966 0 01-5.982-2.275M15 9.75a3 3 0 11-6 0 3 3 0 016 0z" />
55
</svg>
66

7-
<p class="font-bold">
7+
<p class="overflow-ellipsis overflow-hidden whitespace-nowrap font-bold hidden sm:block" v-if="username">
88
{{ username }}
99
</p>
1010
</div>
@@ -14,7 +14,6 @@
1414
1515
const props = defineProps({
1616
username: {
17-
required: true,
1817
type: String
1918
},
2019

components/nav/user/user.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
<avatar class="overflow-hidden" :avatar-letter="avatarLetter" :username="username"/>
66
</div>
77
<ul tabindex="0" class="dropdown-content z-[2] menu p-2 shadow bg-base-100 rounded-box w-52">
8+
<li>
9+
<div @click="copyToClipboard(username)">
10+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
11+
<path stroke-linecap="round" stroke-linejoin="round" d="M16.5 12a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Zm0 0c0 1.657 1.007 3 2.25 3S21 13.657 21 12a9 9 0 1 0-2.636 6.364M16.5 12V8.25" />
12+
</svg>
13+
14+
<p class="overflow-ellipsis overflow-hidden whitespace-nowrap">{{ username }}</p>
15+
</div>
16+
</li>
817
<li v-if="adminAllowed" @click="handleClick">
918
<nuxt-link to="admin">
1019
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
@@ -73,7 +82,8 @@
7382
import Avatar from "~/components/nav/user/avatar.vue";
7483
import ModalLanguageEdit from "~/components/modal/language/edit.vue";
7584
76-
const { $userApi, $adminApi } = useNuxtApp();
85+
const { $userApi, $adminApi, $toastsManager } = useNuxtApp();
86+
const { t, locale } = useI18n();
7787
7888
const adminAllowed = $adminApi.getAllowed();
7989
@@ -96,6 +106,14 @@ const handleClick = () => {
96106
}
97107
};
98108
109+
const copyToClipboard = (text) => {
110+
navigator.clipboard.writeText(text).then(function() {
111+
$toastsManager.pushToast(t("navigation.messages.usernameCopied"), 2500, "success");
112+
}, function(err) {
113+
$toastsManager.pushToast(t("navigation.messages.usernameCopyFail"), 3000,"error");
114+
});
115+
}
116+
99117
</script>
100118
101119
<style scoped>

components/toastsBoard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<div class="toast toast-top toast-end z-50">
33
<TransitionGroup name="alerts">
44
<div class="alert shadow-lg" v-for="toast in toasts" :key="toast" :class="'alert-' + toast.type">
5-
<div class="flex justify-between w-full">
5+
<div class="flex justify-between">
66
<div class="flex gap-2">
77
<svg v-if="toast.type === 'error'" xmlns="http://www.w3.org/2000/svg" class="stroke-current flex-shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
88
<svg v-if="toast.type === 'warning'" xmlns="http://www.w3.org/2000/svg" class="stroke-current flex-shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /></svg>
99
<svg v-if="toast.type === 'info'" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-current flex-shrink-0 w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
1010
<svg v-if="toast.type === 'success'" xmlns="http://www.w3.org/2000/svg" class="stroke-current flex-shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
1111

12-
<span>{{ toast.text }}</span>
12+
<p class="text-wrap">{{ toast.text }}</p>
1313
</div>
1414

1515
<button v-if="toast.canHide" class="btn btn-xs btn-circle btn-ghost" @click="closeToast(toast)">

lang/en-US.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
"logout": "Logout"
1818
},
1919

20+
"messages": {
21+
"usernameCopied": "Login copied",
22+
"usernameCopyFail": "Oops, failed to copy login"
23+
},
24+
2025
"themes": {
2126
"system": "System",
2227
"dark": "Dark",
@@ -132,6 +137,9 @@
132137
"radar": "Radar"
133138
},
134139

140+
"income": "Income",
141+
"expanse": "Expanse",
142+
135143
"pie": {
136144
"noData": "No data",
137145
"selects": {
@@ -359,6 +367,8 @@
359367
"warning": "Columns that have not been mapped will not be saved. You can also select multiple description columns for merging",
360368
"readLines": "{n} lines have been read",
361369

370+
"immediatelyApply": "Apply all transactions immediately",
371+
362372
"steps": {
363373
"fileSelect": "Select a file",
364374
"columnsDefining": "Defining columns",

lang/ru-RU.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
"logout": "Выйти"
1818
},
1919

20+
"messages": {
21+
"usernameCopied": "Логин скопирован",
22+
"usernameCopyFail": "Не удалось скопировать логин"
23+
},
24+
2025
"themes": {
2126
"system": "Системная",
2227
"dark": "Темная",
@@ -134,6 +139,9 @@
134139
"radar": "Паутинная"
135140
},
136141

142+
"income": "Доход",
143+
"expanse": "Расход",
144+
137145
"pie": {
138146
"noData": "Нет данных",
139147
"selects": {
@@ -360,6 +368,9 @@
360368
"importMessage": "Импортировано {n} транзакций | Импортирована {n} транзакция | Импортировано {n} транзакций | Импортировано {n} транзакций",
361369
"warning": "Колонки, которые не были размечены, не будут сохранены. Вы также можете выбрать несколько колонок описания для их объединения",
362370
"readLines": "Прочитано {n} строк | Прочитана {n} строка | Прочитано {n} строки | Прочитано {n} строк",
371+
372+
"immediatelyApply": "Сразу применить все транзакции",
373+
363374
"steps": {
364375
"fileSelect": "Выбор файла",
365376
"columnsDefining": "Определение колон",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "finwave",
3-
"version": "0.14.1",
3+
"version": "0.15.0",
44
"private": true,
55
"scripts": {
66
"build": "nuxt build",

pages/bulk.vue

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
</div>
102102
</div>
103103

104-
<csv-import :opened="csvImportOpened" @close="csvImportOpened = false" @addTransactions="addFromImport" />
104+
<csv-import :opened="csvImportOpened" @close="csvImportOpened = false" @addTransactions="addFromImport" @applyTransactions="applyFromImport" />
105105

106106
<confirmation :opened="confirmDeleteOpened"
107107
name="bulk-delete-confirm"
@@ -213,6 +213,12 @@ const addNew = (type) => {
213213
transactions.value.push(newTransaction)
214214
}
215215
216+
const applyFromImport = (t) => {
217+
csvImportOpened.value = false;
218+
219+
sendToServer(t);
220+
}
221+
216222
const addFromImport = (t) => {
217223
csvImportOpened.value = false;
218224
@@ -239,6 +245,17 @@ const accountIdToCurrencyId = (accountId) => {
239245
return accountObject.currencyId;
240246
}
241247
248+
const sendToServer = (transactions) => {
249+
return $transactionsApi.newBulkTransaction(transactions).then((s) => {
250+
if (s)
251+
$toastsManager.pushToast(t("bulkPage.messages.success"), 2500, "success")
252+
else
253+
$toastsManager.pushToast(t("bulkPage.messages.error"), 3000,"error")
254+
255+
return s;
256+
});
257+
}
258+
242259
const apply = () => {
243260
const lastCheck = checkAll();
244261
@@ -248,15 +265,10 @@ const apply = () => {
248265
return;
249266
}
250267
251-
$transactionsApi.newBulkTransaction(transactions.value).then((s) => {
252-
if (s) {
253-
$toastsManager.pushToast(t("bulkPage.messages.success"), 2500, "success")
254-
268+
sendToServer(transactions.value).then((s) => {
269+
if (s)
255270
transactions.value = [];
256-
}
257-
else
258-
$toastsManager.pushToast(t("bulkPage.messages.error"), 3000,"error")
259-
});
271+
})
260272
}
261273
262274
const deleteAll = () => {

0 commit comments

Comments
 (0)