From 2a5895a6c69df6c73edf8a8de52f1232132820ed Mon Sep 17 00:00:00 2001
From: Frederick Muriuki Muriithi
Date: Tue, 29 Aug 2023 10:18:50 +0300
Subject: UI for case-attribute editing.
---
.../wqflask/templates/edit_case_attributes.html | 98 ++++++++++++++++++++++
wqflask/wqflask/views.py | 27 ++++++
2 files changed, 125 insertions(+)
create mode 100644 wqflask/wqflask/templates/edit_case_attributes.html
diff --git a/wqflask/wqflask/templates/edit_case_attributes.html b/wqflask/wqflask/templates/edit_case_attributes.html
new file mode 100644
index 00000000..e3b6a715
--- /dev/null
+++ b/wqflask/wqflask/templates/edit_case_attributes.html
@@ -0,0 +1,98 @@
+{%extends "base.html"%}
+{%block title%}Edit Case Attributes{%endblock%}
+
+{%block css%}
+
+
+
+
+
+{%endblock%}
+
+{%block content%}
+
+
{{inbredset_group.InbredSetName}}: Edit Case-Attributes
+
+
Instructions
+
+ -
+ The table is scrollable. Scroll to find the strain(s) you want to edit.
+
+ - Change value(s) to edit them in the database.
+ - Delete value(s) to delete them from the database.
+ - Click "Submit" to submit all the changes you have made
+ -
+ Click "Reset" to undo ALL the changes you have made and
+ start over.
+
+
+
+
+
+{%endblock%}
+
+{%block js%}
+
+{%endblock%}
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 87202170..eba9dedb 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -1154,3 +1154,30 @@ def get_genotype(name):
"genotype.html",
metadata=metadata,
)
+
+@app.route("/case-attribute//edit")
+def edit_case_attributes(inbredset_id: int) -> Response:
+ """
+ Edit the case-attributes for InbredSet group identified by `inbredset_id`.
+ """
+ from wqflask.oauth2 import client
+
+ def __fetch_strains__(inbredset_group):
+ return client.get(f"case-attribute/{inbredset_id}/strains").then(
+ lambda strains: {**inbredset_group, "strains": strains})
+
+ def __fetch_names__(strains):
+ return client.get(f"case-attribute/{inbredset_id}/names").then(
+ lambda canames: {**strains, "case_attribute_names": canames})
+
+ def __fetch_values__(canames):
+ return client.get(f"case-attribute/{inbredset_id}/values").then(
+ lambda cavalues: {**canames, "case_attribute_values": {
+ value["StrainName"]: value for value in cavalues}})
+
+ return client.get(f"case-attribute/{inbredset_id}").then(
+ lambda iset_group: {"inbredset_group": iset_group}).then(
+ __fetch_strains__).then(__fetch_names__).then(
+ __fetch_values__).either(
+ lambda err: err, ## TODO: Handle error better
+ lambda values: render_template("edit_case_attributes.html", **values))
--
cgit 1.4.1