aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBonfaceKilz2022-05-12 11:27:08 +0300
committerBonfaceKilz2022-05-27 15:17:52 +0300
commitd998a402feca4d609953aa9dd5e58b70ee21a33a (patch)
treee11cd27851020d1cb1ece4ac4bde784cb1d30814
parentb02c7767367868b80101633eadbd806aa525c2af (diff)
downloadgenenetwork2-d998a402feca4d609953aa9dd5e58b70ee21a33a.tar.gz
Make a POST request on data edit
* wqflask/wqflask/metadata_edits.py: When editing a case-attribute, make a post request to the relevant end-point.
-rw-r--r--wqflask/wqflask/templates/case_attributes.html42
1 files changed, 39 insertions, 3 deletions
diff --git a/wqflask/wqflask/templates/case_attributes.html b/wqflask/wqflask/templates/case_attributes.html
index 48efd8c8..7b6af57d 100644
--- a/wqflask/wqflask/templates/case_attributes.html
+++ b/wqflask/wqflask/templates/case_attributes.html
@@ -102,9 +102,9 @@
</thead>
<tbody>
{% for id_, name, description in case_attributes %}
- <tr>
- <td>{{ name }}</td>
- <td>{{description}}</td>
+ <tr data-id="{{id_}}">
+ <td class="name" data-original-value="{{ name }}">{{ name }}</td>
+ <td class="description" data-original-value="{{ description }}">{{description}}</td>
<td>
<a class="add" title="Add" data-toggle="tooltip"><i><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></i></a>
<a class="edit" title="Edit" data-toggle="tooltip"><i><span class="glyphicon glyphicon-edit" aria-hidden="true"></span></i></a>
@@ -158,6 +158,42 @@
$(this).parents("tr").find(".add, .edit").toggle();
$(".add-new").removeAttr("disabled");
}
+
+ let nameNode = $(this).parents("tr").find(".name");
+ let descNode = $(this).parents("tr").find(".description");
+
+ let name = nameNode.html();
+ let desc = descNode.html();
+
+ let originalName = nameNode.data("original-value");
+ let originalDesc = descNode.data("original-value");
+ let diff = {};
+ if (name !== originalName) {
+ diff["Modifications"] = {
+ name: {
+ Original: originalName,
+ Current: name,
+ }};
+ }
+ if (desc !== originalDesc) {
+ let desc_ = {
+ Original: originalDesc,
+ Current: desc,
+ }
+ if (Object.keys(diff).length == 0) {
+ diff["Modifications"] = {
+ description: desc_
+ }
+ }
+ else {
+ diff["Modifications"].name = desc_;
+ }
+ }
+ if (!Object.keys(diff).length == 0) {
+ diff["id"] = $(this).parents("tr").data("id");
+ }
+ $.post('{{ url_for("metadata_edit.update_case_attributes") }}',
+ JSON.stringify(diff));
});
// Edit row on edit button click
$(document).on("click", ".edit", function(){