summaryrefslogtreecommitdiff
path: root/issues/editing-bug-brittle-fix-for-editing-metadata.gmi
blob: 4855c8c9e0d68f09285f819292780746c577e242 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Brittle Fix for Editing Metadata

## Tags

* type: bug
* priority: high
* assigned: fredm, zachs, bonz
* keywords: metadata, editing
* status: open

## Description

=> https://github.com/genenetwork/genenetwork2/commit/47c74f8ad6e76c4227ba1ff980d3a49f9ef79a81 The initial fix
for the bug where values that were not changed were being deleted/removed works, but feels a tad brittle.

### Current Process

There is some javascript code that
=> https://github.com/genenetwork/genenetwork2/blob/47c74f8ad6e76c4227ba1ff980d3a49f9ef79a81/wqflask/wqflask/templates/edit_phenotype.html#L264-L267 marks fields as changed
when they are focussed and then blurred, whether or not there was an actual change.

On submitting, there is more javascript code that
=> https://github.com/genenetwork/genenetwork2/blob/47c74f8ad6e76c4227ba1ff980d3a49f9ef79a81/wqflask/wqflask/templates/edit_phenotype.html#L269-L271 disables all fields not marked as changed
before submitting the values.

There is still more javascript code that, in the paraphrased words of the original author,
=> https://github.com/genenetwork/genenetwork2/blob/47c74f8ad6e76c4227ba1ff980d3a49f9ef79a81/wqflask/wqflask/templates/edit_phenotype.html#L273-L276 awkwardly detects changes to sample data

----

The problem with the javascript code above is that it is hacky and the solutions are brittle. For example

* marking the field as changed on blur rather than actually comparing the values
* not submitting original values making it impossible to compare values on backend
* detecting changes by setting a flag: the user can very easily restore the value to original before submitting, making the set flag indicate the wrong thing

### Possible Fix

I think, in general, we need to instead set the values based on comparisons:

* Submit both the old values and new values
* Compare old value and new value
* If different, add field/key to "update list"
* If not, don't add the field/key at all
* Use final "update list" to build the dictionary or data object to use for the update