]> git.openstreetmap.org Git - nominatim-ui.git/blobdiff - src/components/SearchSectionDetails.svelte
Details page: Allow searching for negative OSM ids
[nominatim-ui.git] / src / components / SearchSectionDetails.svelte
index 8029fb3705392c7a4f4cda9d0d3ae2456db19a30..5ca614a276da6f99b88f4b7dd8ef2522ecc5d50d 100644 (file)
@@ -6,8 +6,8 @@
   function handleFormSubmit(event) {
     let form_el = event.target;
     let val = form_el.querySelector('input[type=edit]').value.trim();
   function handleFormSubmit(event) {
     let form_el = event.target;
     let val = form_el.querySelector('input[type=edit]').value.trim();
-    let type_and_id_match = val.match(/^\s*([NWR])(\d+)\s*$/i)
-                            || val.match(/\/(relation|way|node)\/(\d+)\s*$/);
+    let type_and_id_match = val.match(/^\s*([NWR])(-?\d+)\s*$/i)
+                            || val.match(/\/(relation|way|node)\/(-?\d+)\s*$/);
 
     var params = new URLSearchParams();
     if (type_and_id_match) {
 
     var params = new URLSearchParams();
     if (type_and_id_match) {
 </script>
 
 <form on:submit|preventDefault={handleFormSubmit} class="form-inline" action="details.html">
 </script>
 
 <form on:submit|preventDefault={handleFormSubmit} class="form-inline" action="details.html">
-  <input type="edit"
-         class="form-control form-control-sm mr-1"
-         pattern="^[NWR]?[0-9]+$|.*openstreetmap.*"
-         value="{api_request_params.osmtype || ''}{api_request_params.osmid || ''}{api_request_params.place_id || ''}" />
-  <button type="submit" class="btn btn-primary btn-sm">Show</button>
+  <div class="row g-1">
+    <div class="col-auto">
+      <!-- eslint-disable-next-line max-len -->
+      <input type="edit"
+             class="form-control form-control-sm me-1"
+             pattern="^[1-9][0-9]*$|^[NWRnwr]-?[1-9][0-9]*$|.*openstreetmap.*"
+             value="{
+              (api_request_params.osmtype || '')
+              + (api_request_params.osmid || '')
+              + (api_request_params.place_id || '')
+            }" />
+      </div>
+    <div class="col-auto">
+      <button type="submit" class="btn btn-primary btn-sm">Show</button>
+    </div>
+  </div>
 </form>
 <small class="form-text text-muted">
 </form>
 <small class="form-text text-muted">
-  OSM type+id (<em>N123</em>, <em>W123</em>, <em>R123</em>),
+  OSM type+id (<em>N123</em>,
+               <em>n123</em>,
+               <em>W123</em>,
+               <em>w123</em>,
+               <em>R123</em>,
+               <em>r123</em>),
   Place id (<em>1234</em>) or
   URL (<em>https://openstreetmap.org/way/123</em>)
 </small>
   Place id (<em>1234</em>) or
   URL (<em>https://openstreetmap.org/way/123</em>)
 </small>