WIP: Add new field e-mail
This commit is contained in:
@@ -106,7 +106,7 @@ class Application:
|
|||||||
self.table = ttk.Treeview(
|
self.table = ttk.Treeview(
|
||||||
data_frame,
|
data_frame,
|
||||||
yscrollcommand=scrollbar.set,
|
yscrollcommand=scrollbar.set,
|
||||||
columns=("0", "1", "2", "3", "4", "5"),
|
columns=("0", "1", "2", "3", "4", "5", "6"),
|
||||||
show="headings",
|
show="headings",
|
||||||
)
|
)
|
||||||
scrollbar.config(command=self.table.yview)
|
scrollbar.config(command=self.table.yview)
|
||||||
@@ -116,7 +116,8 @@ class Application:
|
|||||||
self.table.heading("2", text="Name")
|
self.table.heading("2", text="Name")
|
||||||
self.table.heading("3", text="Strasse")
|
self.table.heading("3", text="Strasse")
|
||||||
self.table.heading("4", text="Plz/Ort")
|
self.table.heading("4", text="Plz/Ort")
|
||||||
self.table.heading("5", text="Anzahl")
|
self.table.heading("5", text="E-Mail")
|
||||||
|
self.table.heading("6", text="Anzahl")
|
||||||
self.table.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
|
self.table.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
|
||||||
scrollbar.pack(side=tk.LEFT, fill=tk.Y)
|
scrollbar.pack(side=tk.LEFT, fill=tk.Y)
|
||||||
|
|
||||||
@@ -170,6 +171,7 @@ class Application:
|
|||||||
"name": "Name",
|
"name": "Name",
|
||||||
"strasse": "Strasse",
|
"strasse": "Strasse",
|
||||||
"plzort": "Plz/Ort",
|
"plzort": "Plz/Ort",
|
||||||
|
"email": "E-Mail",
|
||||||
"anzahl": "1",
|
"anzahl": "1",
|
||||||
}
|
}
|
||||||
self.model.create_new(values)
|
self.model.create_new(values)
|
||||||
@@ -263,6 +265,8 @@ class Application:
|
|||||||
case "#5":
|
case "#5":
|
||||||
field = "plzort"
|
field = "plzort"
|
||||||
case "#6":
|
case "#6":
|
||||||
|
field = "email"
|
||||||
|
case "#7":
|
||||||
field = "anzahl"
|
field = "anzahl"
|
||||||
case _:
|
case _:
|
||||||
field = "name"
|
field = "name"
|
||||||
@@ -319,6 +323,7 @@ class Application:
|
|||||||
# skip inactive records if filter is true
|
# skip inactive records if filter is true
|
||||||
if self.filter_active.get() and address["aktiv"] != "x":
|
if self.filter_active.get() and address["aktiv"] != "x":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.table.insert(
|
self.table.insert(
|
||||||
"",
|
"",
|
||||||
"end",
|
"end",
|
||||||
@@ -329,6 +334,7 @@ class Application:
|
|||||||
address["name"],
|
address["name"],
|
||||||
address["strasse"],
|
address["strasse"],
|
||||||
address["plzort"],
|
address["plzort"],
|
||||||
|
address["email"],
|
||||||
address["anzahl"],
|
address["anzahl"],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -43,7 +43,21 @@ class JSONConnector(Connector):
|
|||||||
def get_all(self) -> list:
|
def get_all(self) -> list:
|
||||||
try:
|
try:
|
||||||
with open(self.json_file, "r") as f:
|
with open(self.json_file, "r") as f:
|
||||||
return json.load(f)
|
data = json.load(f)
|
||||||
|
fields = [
|
||||||
|
"aktiv",
|
||||||
|
"firma",
|
||||||
|
"name",
|
||||||
|
"strasse",
|
||||||
|
"plzort",
|
||||||
|
"email",
|
||||||
|
"anzahl",
|
||||||
|
]
|
||||||
|
for record in data:
|
||||||
|
for field in fields:
|
||||||
|
if field not in record.keys():
|
||||||
|
record[field] = ""
|
||||||
|
return data
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class EditRecord(Window):
|
|||||||
self.name = tk.StringVar(value=record.get("name"))
|
self.name = tk.StringVar(value=record.get("name"))
|
||||||
self.strasse = tk.StringVar(value=record.get("strasse"))
|
self.strasse = tk.StringVar(value=record.get("strasse"))
|
||||||
self.plz_ort = tk.StringVar(value=record.get("plzort"))
|
self.plz_ort = tk.StringVar(value=record.get("plzort"))
|
||||||
|
self.email = tk.StringVar(value=record.get("email"))
|
||||||
self.anzahl = tk.StringVar(value=record.get("anzahl"))
|
self.anzahl = tk.StringVar(value=record.get("anzahl"))
|
||||||
|
|
||||||
edit_frame = tk.Frame(self)
|
edit_frame = tk.Frame(self)
|
||||||
@@ -57,7 +58,8 @@ class EditRecord(Window):
|
|||||||
tk.Label(edit_frame, text="Name").grid(row=0, column=2)
|
tk.Label(edit_frame, text="Name").grid(row=0, column=2)
|
||||||
tk.Label(edit_frame, text="Strasse").grid(row=0, column=3)
|
tk.Label(edit_frame, text="Strasse").grid(row=0, column=3)
|
||||||
tk.Label(edit_frame, text="Plz/Ort").grid(row=0, column=4)
|
tk.Label(edit_frame, text="Plz/Ort").grid(row=0, column=4)
|
||||||
tk.Label(edit_frame, text="Anzahl").grid(row=0, column=5)
|
tk.Label(edit_frame, text="E-Mail").grid(row=0, column=5)
|
||||||
|
tk.Label(edit_frame, text="Anzahl").grid(row=0, column=6)
|
||||||
edit_aktiv = tk.Checkbutton(edit_frame, variable=self.aktiv, onvalue="x", offvalue="")
|
edit_aktiv = tk.Checkbutton(edit_frame, variable=self.aktiv, onvalue="x", offvalue="")
|
||||||
edit_aktiv.grid(row=1, column=0)
|
edit_aktiv.grid(row=1, column=0)
|
||||||
edit_firma = tk.Entry(edit_frame, textvariable=self.firma)
|
edit_firma = tk.Entry(edit_frame, textvariable=self.firma)
|
||||||
@@ -68,8 +70,10 @@ class EditRecord(Window):
|
|||||||
edit_strasse.grid(row=1, column=3)
|
edit_strasse.grid(row=1, column=3)
|
||||||
edit_plz_ort = tk.Entry(edit_frame, textvariable=self.plz_ort)
|
edit_plz_ort = tk.Entry(edit_frame, textvariable=self.plz_ort)
|
||||||
edit_plz_ort.grid(row=1, column=4)
|
edit_plz_ort.grid(row=1, column=4)
|
||||||
|
edit_email= tk.Entry(edit_frame, textvariable=self.email)
|
||||||
|
edit_email.grid(row=1, column=5)
|
||||||
edit_anzahl = tk.Entry(edit_frame, textvariable=self.anzahl)
|
edit_anzahl = tk.Entry(edit_frame, textvariable=self.anzahl)
|
||||||
edit_anzahl.grid(row=1, column=5)
|
edit_anzahl.grid(row=1, column=6)
|
||||||
|
|
||||||
button_frame = tk.Frame(self)
|
button_frame = tk.Frame(self)
|
||||||
button_frame.pack(side=tk.TOP, pady=10)
|
button_frame.pack(side=tk.TOP, pady=10)
|
||||||
@@ -84,6 +88,7 @@ class EditRecord(Window):
|
|||||||
"name": self.name.get(),
|
"name": self.name.get(),
|
||||||
"strasse": self.strasse.get(),
|
"strasse": self.strasse.get(),
|
||||||
"plzort": self.plz_ort.get(),
|
"plzort": self.plz_ort.get(),
|
||||||
|
"email": self.email.get(),
|
||||||
"anzahl": self.anzahl.get(),
|
"anzahl": self.anzahl.get(),
|
||||||
}
|
}
|
||||||
self.model.update_record(new_record)
|
self.model.update_record(new_record)
|
||||||
|
|||||||
Reference in New Issue
Block a user