Add basic Feedback button for POS screen
this will definitely need to change, but wanted it on screen at least
This commit is contained in:
parent
6448fc139c
commit
51c1094e1c
|
@ -38,6 +38,9 @@ include_package_data = True
|
|||
console_scripts =
|
||||
wuttapos = wuttapos.commands:main
|
||||
|
||||
rattail.config.extensions =
|
||||
wuttapos = wuttapos.config:WuttaConfigExtension
|
||||
|
||||
wuttapos.commands =
|
||||
open = wuttapos.commands:Open
|
||||
serve = wuttapos.commands:Serve
|
||||
|
|
|
@ -27,6 +27,7 @@ WuttaPOS app
|
|||
import json
|
||||
import os
|
||||
|
||||
from rattail import app as base
|
||||
from rattail.config import make_config
|
||||
|
||||
import flet as ft
|
||||
|
@ -35,6 +36,20 @@ import wuttapos
|
|||
from wuttapos.util import get_pos_batch_handler
|
||||
|
||||
|
||||
class WuttaAppHandler(base.AppHandler):
|
||||
"""
|
||||
Custom app handler for WuttaPOS
|
||||
"""
|
||||
|
||||
def get_title(self, **kwargs):
|
||||
kwargs.setdefault('default', 'WuttaPOS')
|
||||
return super().get_title(**kwargs)
|
||||
|
||||
def get_node_title(self, **kwargs):
|
||||
kwargs.setdefault('default', 'WuttaPOS')
|
||||
return super().get_node_title(**kwargs)
|
||||
|
||||
|
||||
def main(page: ft.Page):
|
||||
config = make_config()
|
||||
app = config.get_app()
|
||||
|
|
38
wuttapos/config.py
Normal file
38
wuttapos/config.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# WuttaPOS -- Pythonic Point of Sale System
|
||||
# Copyright © 2023 Lance Edgar
|
||||
#
|
||||
# This file is part of WuttaPOS.
|
||||
#
|
||||
# WuttaPOS is free software: you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# WuttaPOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# WuttaPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
WuttaPOS config extension
|
||||
"""
|
||||
|
||||
|
||||
from rattail.config import ConfigExtension
|
||||
|
||||
|
||||
class WuttaConfigExtension(ConfigExtension):
|
||||
"""
|
||||
Rattail config extension for WuttaPOS
|
||||
"""
|
||||
key = 'wuttapos'
|
||||
|
||||
def configure(self, config):
|
||||
config.setdefault('rattail', 'app.handler', 'wuttapos.app:WuttaAppHandler')
|
|
@ -476,6 +476,84 @@ class POSView(WuttaView):
|
|||
expand=1,
|
||||
)
|
||||
|
||||
def feedback_click(e):
|
||||
|
||||
message = ft.TextField(label="Message",
|
||||
multiline=True, min_lines=5,
|
||||
autofocus=True)
|
||||
|
||||
def send_feedback(e):
|
||||
self.app.send_email('pos_feedback', data={
|
||||
'user_name': self.page.shared['user_display'],
|
||||
'message': message.value,
|
||||
})
|
||||
|
||||
dlg.open = False
|
||||
|
||||
self.page.snack_bar = ft.SnackBar(ft.Text(f"MESSAGE WAS SENT",
|
||||
color='black',
|
||||
weight=ft.FontWeight.BOLD),
|
||||
bgcolor='green',
|
||||
duration=1500)
|
||||
self.page.snack_bar.open = True
|
||||
|
||||
self.main_input.focus()
|
||||
self.page.update()
|
||||
|
||||
def cancel(e):
|
||||
dlg.open = False
|
||||
self.main_input.focus()
|
||||
self.page.update()
|
||||
|
||||
button_height = self.default_button_size * 0.8
|
||||
dlg = ft.AlertDialog(
|
||||
modal=True,
|
||||
title=ft.Text("User Feedback"),
|
||||
content=ft.Container(
|
||||
content=ft.Column(
|
||||
[
|
||||
ft.Text("Questions, suggestions, comments, complaints, etc. "
|
||||
"are welcome and may be submitted below. "),
|
||||
ft.Divider(),
|
||||
message,
|
||||
],
|
||||
expand=True,
|
||||
),
|
||||
height=500,
|
||||
),
|
||||
actions=[
|
||||
ft.Row(
|
||||
[
|
||||
ft.Container(content=ft.Text("Send Message",
|
||||
size=self.default_font_size,
|
||||
color='black',
|
||||
weight=ft.FontWeight.BOLD),
|
||||
height=button_height,
|
||||
width=self.default_button_size * 3,
|
||||
alignment=ft.alignment.center,
|
||||
bgcolor='blue',
|
||||
border=ft.border.all(1, 'black'),
|
||||
border_radius=ft.border_radius.all(5),
|
||||
on_click=send_feedback),
|
||||
ft.Container(content=ft.Text("Cancel",
|
||||
size=self.default_font_size,
|
||||
weight=ft.FontWeight.BOLD),
|
||||
height=button_height,
|
||||
width=self.default_button_size * 2.5,
|
||||
alignment=ft.alignment.center,
|
||||
border=ft.border.all(1, 'black'),
|
||||
border_radius=ft.border_radius.all(5),
|
||||
on_click=cancel),
|
||||
],
|
||||
alignment=ft.MainAxisAlignment.CENTER,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
self.page.dialog = dlg
|
||||
dlg.open = True
|
||||
self.page.update()
|
||||
|
||||
def tenkey_click(e):
|
||||
value = e.control.content.value
|
||||
|
||||
|
@ -561,13 +639,14 @@ class POSView(WuttaView):
|
|||
bgcolor='green',
|
||||
height=tenkey_button_size,
|
||||
width=tenkey_button_size,
|
||||
on_click=tenkey_click,
|
||||
on_long_press=None,
|
||||
):
|
||||
return ft.Container(content=ft.Text(text, size=tenkey_font_size,
|
||||
weight=ft.FontWeight.BOLD),
|
||||
height=height,
|
||||
width=width,
|
||||
on_click=tenkey_click,
|
||||
on_click=on_click,
|
||||
on_long_press=on_long_press,
|
||||
alignment=ft.alignment.center,
|
||||
border=ft.border.all(1, 'black'),
|
||||
|
@ -707,12 +786,19 @@ class POSView(WuttaView):
|
|||
|
||||
ft.Row(
|
||||
[
|
||||
self.set_quantity,
|
||||
self.main_input,
|
||||
tenkey_button("⌫", height=70, width=70),
|
||||
tenkey_button("CE", height=70, width=70),
|
||||
tenkey_button("Feedback", height=70, width=200,
|
||||
bgcolor='blue', on_click=feedback_click),
|
||||
ft.Row(
|
||||
[
|
||||
self.set_quantity,
|
||||
self.main_input,
|
||||
tenkey_button("⌫", height=70, width=70),
|
||||
tenkey_button("CE", height=70, width=70),
|
||||
],
|
||||
alignment=ft.MainAxisAlignment.CENTER,
|
||||
expand=True,
|
||||
),
|
||||
],
|
||||
alignment=ft.MainAxisAlignment.CENTER,
|
||||
),
|
||||
|
||||
ft.Row(),
|
||||
|
|
Loading…
Reference in a new issue