CASsim icon indicating copy to clipboard operation
CASsim copied to clipboard

Changed parameters should be included after the URL

Open jkomoros opened this issue 4 years ago • 2 comments

diff the original config with the currently modified one, and then stuff the diff into a hash encoding, so that someone sharing the URL would get the same exact config.

Kind of a poor man's #32

Also add a button to clear all userland modifications

jkomoros avatar Dec 11 '21 17:12 jkomoros

Could use a lot of the same diffing/overriding machinery from #29

jkomoros avatar Dec 11 '21 17:12 jkomoros

  • [x] In the state model, store the list of modifications (dotted paths, values). The state that feeds into the SimulationCollection is the rawData combined with those modifications
  • [x] Add a UI affordance to throw away all modifications (with a confirm prompt)
  • [x] Simulators get a version number that they can increment if they want
  • [x] Add a way to pass "the default value for this item" with a special sentinel for modifying at a path. Will need to have the logic in the applyModificationsToRawConfig create a throwaway Simulator in order to get the default value
  • [x] Make sure that the raw string values of modifications are URL-encoded ('&' and '=' are the most dangerous)
  • [x] unpackModificationsForURL
  • [x] Are there every any cases where we have to pack an object or array? Those must always be the default value, right, because there's no way in the UI to add an object right now other than default
  • [ ] Do testing for packing and unpacking URL
  • [x] Each config should have a sha of its json (3 digis?) in the version url, so it can alert if there's a difference from the one that the diff is for. This should be computed on demand (and memoized) in a getter on simulator. It should return a fingerprint (sha of a JSON stringify of config)), and the unpacking machinery should compare as many digits as the included fingerprint (wait, it should compare based on the RAW config, not the modified config, right?)
  • [x] Make it so if there is a diff applied from underlying, each value that is different shows up highlighted in the UI (related to the "diff based on a base simOptions" issue). Need an removeLastModificationForPath(simIndex, path) action creator. Also have a shadowedModificationsForSimIndex selector and util. Paths that have been deleted in modifications should show an undelete affordance. Have a modifications path => value that is passed to option-control and it highlights ones and had an 'undo modifications' affordance.
  • [x] Bug: if you have a modification to add northStar default, and then a later one to change one of its values, and then you remove the 'add northstar' one, then it leads to an invalid config because the northstar value is implied into existence. maybe the removeLastModificationForPath should walk backwards and also remove any ones after it (but only if it was a 'd' record)
  • [ ] Bug: switch the sim parameter of one of hte configs to dice-roll-demo and refresh. It fails to load. (verify it's also fixed when deployed; the polymer build machinery complains about the non-constant
  • [ ] Kind of weird behavior: start in a config with a northStar. Delete the northstar. Then go back and add it (don't undo the modificaiton, manually add it back). Now all of the northstar shows as new, even though only some of it is actually new.
  • [ ] Another kind of weird behavior: start in a config with no north star. Add one. Then DELETE it (don't undo modifications on it). It shows a deleted item, even though it never existed in the first place!
  • [x] Make it so deleted keys leave a 'undo' affordance on them
  • [x] Bug: if you delete a top-level key (advanced or non advanced, it might not matter), it doesn't render an affordance to add it back.
  • [ ] Make it so deleted array keys have an undo affordance on them (this is hard)
  • [x] It's kind of weird that if you hit undo it only ondoes ONE item, if you made multiple modifications. Probably best to just remove them all...
  • [x] Aren't there some weird situations with shadowing? e.g. northStar is set to default, then northStar.offset is set to 1.5, then northStar is deleted. So maybe shadowing later deletions have to remove all paths that are a descendant of the given path? e.g. (startsWith(deletepath + '.' (to make sure that keys that have hte same prefix but aren't the same don't get erronously said to be a sub path). It should be sufficient, when building up the shadowed final value map, if we run into a delete sentinel, delete any existing keys that have DELETE_KEY. as prefix
  • [x] Bug: if there's a modification, then it erroneously applies it to the first item if the index is omitted (but the bug goes away if we include the simIndex in every packed URL part)
  • [x] Remove the # if nothing in hash
  • [x] There's a bug: if you make modifications, then move to another simIndex, then move to ANOTHER simIndex, the hash erroneously disappears. This is because the replaceState is called, but then hash doesn't update, so hash is overwritten
  • [x] Switching simulation type live breaks (it broke in actual not loading renderer, but has been broken for longer with an uncaught error in console. The total break happened in b172932809007a118c6872a1875f2277830ade77 . (but the uncaught errors predate it)
  • [x] Also... does switching from dice roll TO schelling-org actually work?
  • [x] Add shortNames to schelling-org and the default dice game
  • [x] Also make it so shortNames aren't allowed to conflict with non-short-names in the peer
  • [x] A 'expandPathWithConfig' and 'shortenPathWithConfig' method (tested)
  • [x] Validate that there are no duplicate short names (if not short name, use the default name) at any config level
  • [x] Show an alert message in the UI if the simulator version or base config the diff was generated from is different
  • [x] Stash the modifications in the URL after the hash. encode them after d= with a URL enncoded blob that is: <VERSIONNUMBER>&<PROPNAME>=<VALUE>&<PROPNAME>=<VALUE>. So the first item in the dotted list is the version number of the simulator, and afterwards is pair of dotted path name = value. 'x' is the serialization of 'delete sentinel'. (Objects will also need an encoding that will parse properly, and handle = and & specially)
  • [x] The 'default value' is serialized into the URL as 'd'
  • [x] Remove overriding modifications (cull ones that shadow other ones)
  • [x] Make it so the diff is parsed back out of the URL at load
  • [x] Items in options config get a 'short' property. If set, then when packing the path, the short will be used for the property instead of the full name. short names should be unique within that object level and be consistent
  • [x] In the future, make it so short names are automatically created when not provided. They should be something like "first letter of the key, plus every upper case letter in the rest, combined with a two-digit hash of the overal lkey (to make collisions less common)". But this will get a bit hard to make sure they stay consistent. Ideally there'd be a way to "burn them in"

jkomoros avatar Dec 11 '21 23:12 jkomoros