Repository navigation
Interactive custom model text box - #2239
Conversation
…the parsed value directly * this fixes issues with multi-line strings
…e annoying edge-cases)
…r typing `if: ` or `else if: `)
|
@karussell I found this code in It looks like it takes a custom model from the url parameters? Is this an actual working feature or can it be removed? So far I thought it would be nice to be able to store custom models inside the url, but it was not possible... |
|
Thanks for this incredible work. It will help us a lot to promote the customizable routing I think :)
For development it should work but we can also remove it. |
Yes, good idea, this works 👍 Its not ideal, because this way we have to run Apparently npm used to have a different behavior where instead of using the symlink it copied the local child module to node_modules, but this comes with other problems. Another solution could be yarn workspaces... But for now using require(../..) is good enough?
Yes an also this only really works for CI (or maybe not even). For local development uploading every change to npm (or even some private registry) seems way to cumbersome.
I do not think this is related to the problem I was having, but if anything I would copy the maps sources to src/main/js not the other way around. |
|
In the last commit I added a button that switches the editor to a read-only json view I'd like to disable it as long as the yaml input is invalid. WDYT is this useful? Can/should we change these three 'buttons' from anchors to buttons? Or how can we make it appear disabled? Maybe use Btw I also disable the search button as long as the input is invalid now, does this make sense? |
|
Over one thing I stumbled: before I was able to do the usual
Nice idea! And should I do a reimport of our customizable routing server in its current state? (and rewrite the examples&screenshots?) btw: I just picked a random route and thought something is really broken as it did not avoid MOTORWAY at all. No matter what I did. The problem was that although in the map it looked like a motorway it was a TRUNK (I have a strange luck ;) ) ... maybe we should additionally send And previously it worked when I included (also a bit ugly that the elevation widget currently only works if elevation is enabled :) )
text is fine IMO. Only a minor style adaption so that it matches the sidebar footer? (greenish text without underscore) |
Since we now include custom-model-editor via require(...) only instead of package.json we have to build it separately yes. You can also do
Sure! We cannot use areas yet though.
You mean we should show all encoded values when we hover edges in the mvt view? Yes!
What do you mean? What are details in yaml?
Yes, since it is also showing path details this feature should not depend on elevation...
Ok will try. |
Since we (currently) have the properties like
We would need to have this documented or include the editor JS files like we include other JS files?
I didn't mean this but it would be nice :) What I meant is that we collect all encoded values used in the script and include it in the query as path details. This way we can easily see the e.g. the road_class for the route and how it changes if we change e.g. the multiply-by number. (if the elevation widget is shown) |
Ah ok. Btw so far you can use ctrl+enter to send the request regardless of the validation. Not sure if this should be a 'feature' :) So far the validation check is just not implemented in this case...
Ok sure it should be documented. We cannot include editor files like other files because the editor uses an additional transpilation step.
Ok yes that makes sense. It should not be too hard to return the used encoded values from the expression parser. |
|
Its still not working with IE11, I get a Hmm, no it does not. IE11 support was officially dropped 25 days ago: eemeli/yaml@c1639b3 the yaml playground does not work in IE11 either: https://github.com/eemeli/yaml-playground I'd say let's not support IE11 and move on :) Windows users can use Edge (this branch works for Edge). |

This is work in progress to realize a text input box that allows entering a custom model with error highlighting and auto-completion. The goal here is to provide a very flat learning curve for the custom model language. The custom model is written in YAML that can contain boolean expression strings that refer to encoded values like
road_class == PRIMARYetc.Since the encoded values are unknown to most users they are provided as auto-completion suggestions. The auto-completion can be triggered by pressing Ctrl+Space. Note that the auto-completion suggestions depend on the cursor position. If the cursor is positioned within some word the conditions are filtered by the characters between the beginning of the word and the cursor.
|road_class+ Ctrl+Space yieldssurface, road_class, road_class_link, toll, ..., butro|ad_class+ Ctrl+Space only yieldsroad_class, road_class_link, ...(all values starting withro)! Is this what most people would expect?Usage: see the README.md file in the textbox folder
Currently the boolean expressions are colored in blue, errors in boolean expressions are red and errors in yaml format are indicated by red underlines.
todo:
true,falseadjust /info endpoint to return encoded value types (numeric/boolean/enum)not needed -> show ev from /infoError: Can't walk dependency graph: Cannot find module 'custom-model-editor'and also check IE/browser compatibility in generalIE won't be supportedminify codemirror css files(not worth it), add version information as well