Skip to content

Commit

Permalink
Ask confirmation from the user when deleting a category
Browse files Browse the repository at this point in the history
  • Loading branch information
valtterikantanen committed May 3, 2022
1 parent e3c1d95 commit a31873e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ui/budget_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def select_item(a):
transaction_id = transactions[i][0]
datetime_object = datetime.strptime(transactions[i][1], "%Y-%m-%d")
date = datetime.strftime(datetime_object, "%-d.%-m.%Y")
amount = f"{('%.2f' % (transactions[i][2] / 100)).replace('.', ',')} €"
amount = f"{('%.2f' % (transactions[i][2] / 100)).replace('.', ',').replace('-', '−')} €"
category = transactions[i][3]
description = transactions[i][4]
transaction_list.insert(parent="", index="end", iid=i, text="", values=(transaction_id, date, amount, category, description))
Expand Down
8 changes: 4 additions & 4 deletions src/ui/category_view.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from datetime import datetime

import tkinter as tk
from tkinter import ttk, messagebox

Expand Down Expand Up @@ -54,8 +52,10 @@ def select_item(a):
def delete():
selected_item = category_list.selection()[0] if category_list.selection() else None
if selected_item:
budget_service.delete_category(self._selected_category_id)
category_list.delete(selected_item)
answer = messagebox.askyesno(message="Haluatko varmasti poistaa kategorian?", icon="warning")
if answer:
budget_service.delete_category(self._selected_category_id)
category_list.delete(selected_item)
else:
messagebox.showerror(message="Valitse kategoria!")

Expand Down

0 comments on commit a31873e

Please sign in to comment.