aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorBonfaceKilz2022-05-19 12:58:31 +0300
committerBonfaceKilz2022-05-27 15:17:52 +0300
commitb5494aadd60250fc7bdb4e474bc06cc5f6cd29e0 (patch)
treecbe75ab0aad8ca613680c580c89a2e56b1c9eef5 /wqflask
parent764c0299ad87831d0bfebb040b30c9ad8033d8eb (diff)
downloadgenenetwork2-b5494aadd60250fc7bdb4e474bc06cc5f6cd29e0.tar.gz
POST new inserts
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/templates/case_attributes.html75
1 files changed, 47 insertions, 28 deletions
diff --git a/wqflask/wqflask/templates/case_attributes.html b/wqflask/wqflask/templates/case_attributes.html
index e5d5512c..c2db7ef8 100644
--- a/wqflask/wqflask/templates/case_attributes.html
+++ b/wqflask/wqflask/templates/case_attributes.html
@@ -210,43 +210,62 @@
let name = nameNode.html();
let desc = descNode.html();
-
+ let nodeId = $(this).parents("tr").data("id");
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 (nodeId) {
+ if (name !== originalName) {
+ diff["Modification"] = {
+ name: {
+ Original: originalName,
+ Current: name,
+ }};
}
- if (Object.keys(diff).length == 0) {
- diff["Modifications"] = {
- description: desc_
+ if (desc !== originalDesc) {
+ let desc_ = {
+ Original: originalDesc,
+ Current: desc,
+ }
+ if (Object.keys(diff).length == 0) {
+ diff["Modification"] = {
+ description: desc_
+ }
}
+ else {
+ diff["Modification"].name = desc_;
+ }
+ }
+ if (!Object.keys(diff).length == 0) {
+ diff["id"] = nodeId;
}
- else {
- diff["Modifications"].name = desc_;
+ } else {
+ if (name) {
+ diff["Insert"] = {
+ name: name,
+ }
+ }
+ if (desc) {
+ if (Object.keys(diff).length == 0) {
+ diff["Insert"] = {
+ description: desc,
+ }
+ }
+ else {
+ diff["Insert"].description = desc;
+ }
}
}
- if (!Object.keys(diff).length == 0) {
- diff["id"] = $(this).parents("tr").data("id");
+ if(diff) {
+ $.ajax({
+ type: "POST",
+ data: {"data": JSON.stringify(diff)},
+ url: '{{ url_for("metadata_edit.update_case_attributes") }}',
+ /* contentType: "application/json", */
+ success: function(data, status, xhr) { location.reload() }
+ }
+ )
}
- $.ajax({
- type: "POST",
- data: {"data": JSON.stringify(diff)},
- url: '{{ url_for("metadata_edit.update_case_attributes") }}',
- /* contentType: "application/json", */
- success: function(data, status, xhr) {
- location.reload();
- }
- });
});
// Edit row on edit button click
$(document).on("click", ".edit", function(){