Improve User Management GUI
This commit is contained in:
parent
ead829d322
commit
3b16004f73
@ -4,7 +4,7 @@ from typing import Optional
|
|||||||
|
|
||||||
from rio import Column, Component, event, TextStyle, Text, TextInput, ThemeContextSwitcher, Grid, \
|
from rio import Column, Component, event, TextStyle, Text, TextInput, ThemeContextSwitcher, Grid, \
|
||||||
PointerEventListener, PointerEvent, Rectangle, Color, TextInputChangeEvent, Spacer, Row, Switch, \
|
PointerEventListener, PointerEvent, Rectangle, Color, TextInputChangeEvent, Spacer, Row, Switch, \
|
||||||
SwitchChangeEvent, EventHandler
|
SwitchChangeEvent, EventHandler, Icon
|
||||||
|
|
||||||
from src.ezgg_lan_manager import ConfigurationService, UserService, AccountingService, SeatingService, MailingService
|
from src.ezgg_lan_manager import ConfigurationService, UserService, AccountingService, SeatingService, MailingService
|
||||||
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
@ -73,12 +73,18 @@ class ManageUsersPage(Component):
|
|||||||
seat = await self.session[SeatingService].get_user_seat(self.selected_user.user_id)
|
seat = await self.session[SeatingService].get_user_seat(self.selected_user.user_id)
|
||||||
self.user_seat = seat.seat_id if seat else "-"
|
self.user_seat = seat.seat_id if seat else "-"
|
||||||
self.is_user_account_locked = not self.selected_user.is_active
|
self.is_user_account_locked = not self.selected_user.is_active
|
||||||
|
await self.on_search_parameters_changed(TextInputChangeEvent(self.selected_user.user_name))
|
||||||
|
|
||||||
async def on_search_parameters_changed(self, e: TextInputChangeEvent) -> None:
|
async def on_search_parameters_changed(self, e: TextInputChangeEvent) -> None:
|
||||||
self.search_results = list(
|
self.search_results = list(
|
||||||
filter(lambda user: (e.text.lower() in user.user_name.lower()) or e.text.lower() in str(user.user_id),
|
filter(lambda user: (e.text.lower() in user.user_name.lower()) or e.text.lower() in str(user.user_id),
|
||||||
self.all_users))
|
self.all_users))
|
||||||
|
|
||||||
|
async def reset_view(self, _: PointerEvent) -> None:
|
||||||
|
self.selected_user = None
|
||||||
|
self.search_results = self.all_users
|
||||||
|
await self.on_search_parameters_changed(TextInputChangeEvent(""))
|
||||||
|
|
||||||
async def change_account_active(self, _: SwitchChangeEvent) -> None:
|
async def change_account_active(self, _: SwitchChangeEvent) -> None:
|
||||||
self.selected_user.is_active = not self.is_user_account_locked
|
self.selected_user.is_active = not self.is_user_account_locked
|
||||||
await self.session[UserService].update_user(self.selected_user)
|
await self.session[UserService].update_user(self.selected_user)
|
||||||
@ -98,7 +104,7 @@ class ManageUsersPage(Component):
|
|||||||
|
|
||||||
if transaction.is_debit:
|
if transaction.is_debit:
|
||||||
try:
|
try:
|
||||||
await self.session[AccountingService].remove_balance(
|
new_total_balance = await self.session[AccountingService].remove_balance(
|
||||||
transaction.user_id,
|
transaction.user_id,
|
||||||
transaction.value,
|
transaction.value,
|
||||||
transaction.reference
|
transaction.reference
|
||||||
@ -122,6 +128,7 @@ class ManageUsersPage(Component):
|
|||||||
|
|
||||||
self.accounting_section_result_text = f"Guthaben {'entfernt' if transaction.is_debit else 'hinzugefügt'}!"
|
self.accounting_section_result_text = f"Guthaben {'entfernt' if transaction.is_debit else 'hinzugefügt'}!"
|
||||||
self.accounting_section_result_success = True
|
self.accounting_section_result_success = True
|
||||||
|
self.user_account_balance = self.session[AccountingService].make_euro_string_from_decimal(new_total_balance)
|
||||||
|
|
||||||
def build(self) -> Component:
|
def build(self) -> Component:
|
||||||
return Column(
|
return Column(
|
||||||
@ -164,15 +171,32 @@ class ManageUsersPage(Component):
|
|||||||
),
|
),
|
||||||
MainViewContentBox(
|
MainViewContentBox(
|
||||||
Column(
|
Column(
|
||||||
Text(
|
Row(
|
||||||
text="Konto & Sitzplatz",
|
Spacer(),
|
||||||
style=TextStyle(
|
PointerEventListener(
|
||||||
fill=self.session.theme.background_color,
|
content=Icon("material/cancel", fill="background", min_width=2.5, margin_top=1, margin_right=1),
|
||||||
font_size=1.2
|
on_press=self.reset_view
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
Text(
|
||||||
|
text=f"Konto von ",
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=1.2
|
||||||
|
),
|
||||||
|
justify="right"
|
||||||
),
|
),
|
||||||
margin_top=2,
|
Text(
|
||||||
margin_bottom=2,
|
text=self.selected_user.user_name,
|
||||||
align_x=0.5
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.hud_color,
|
||||||
|
font_size=1.2
|
||||||
|
),
|
||||||
|
justify="left"
|
||||||
|
),
|
||||||
|
margin_top=0.5,
|
||||||
|
margin_bottom=2
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user