]> git.openstreetmap.org Git - nominatim-ui.git/blobdiff - src/components/SearchSection.svelte
version 3.2.11
[nominatim-ui.git] / src / components / SearchSection.svelte
index 535f42b53102c9b380c0088e1a667832b177e1f1..e50bbdfff59247ef12591f2190efcdbe5601f983 100644 (file)
@@ -69,7 +69,7 @@
   }
 
   function set_dedupe(e) {
-    document.querySelector('input[name=dedupe]').value = e.target.checked ? 1 : '';
+    document.querySelector('input[name=dedupe]').value = e.target.checked ? 1 : 0;
   }
 
   function set_api_param(e) {
 
 <ul class="nav nav-tabs">
   <li class="nav-item">
-    <a class="nav-link" class:active={!bStructuredSearch} data-toggle="tab" href="#simple">Simple</a>
+    <a class="nav-link" class:active={!bStructuredSearch} data-bs-toggle="tab" href="#simple">Simple</a>
   </li>
   <li class="nav-item">
-    <a class="nav-link" class:active={bStructuredSearch} data-toggle="tab" href="#structured">Structured</a>
+    <a class="nav-link" class:active={bStructuredSearch} data-bs-toggle="tab" href="#structured">Structured</a>
   </li>
 </ul>
 
 <div class="tab-content py-2">
   <div class="tab-pane" class:active={!bStructuredSearch} id="simple" role="tabpanel">
     <UrlSubmitForm page="search">
-      <input id="q"
-             name="q"
-             type="text"
-             class="form-control form-control-sm"
-             placeholder="Search"
-             value="{api_request_params.q || ''}" />
-
-      <button type="submit" class="btn btn-primary btn-sm mx-1">Search</button>
-      <input type="hidden" name="viewbox" value="{sViewBox || ''}" />
-      <input type="hidden" name="dedupe" value="{!api_request_params.dedupe ? '' : 1}" />
-      <input type="hidden" name="bounded" value="{api_request_params.bounded ? 1 : ''}" />
-      <input type="hidden" name="accept-language" value="{api_request_params['accept-language'] || ''}" />
-      <input type="hidden" name="countrycodes" value="{api_request_params.countrycodes || ''}" />
-      <input type="hidden" name="limit" value="{api_request_params.limit || ''}" />
-      <input type="hidden" name="polygon_threshold" value="{api_request_params.polygon_threshold || ''}" />
+      <div class="col-auto">
+        <input id="q"
+               name="q"
+               type="text"
+               class="form-control form-control-sm"
+               placeholder="Search"
+               value="{api_request_params.q || ''}"
+               autofocus />
+      </div>
+      <div class="col-auto">
+        <button type="submit" class="btn btn-primary btn-sm mx-1">Search</button>
+        <input type="hidden" name="viewbox" value="{sViewBox || ''}" />
+        <input type="hidden" name="dedupe" value="{api_request_params.dedupe === 0 ? 0 : 1}" />
+        <input type="hidden" name="bounded" value="{api_request_params.bounded ? 1 : ''}" />
+        <input type="hidden" name="accept-language" value="{api_request_params['accept-language'] || ''}" />
+        <input type="hidden" name="countrycodes" value="{api_request_params.countrycodes || ''}"
+                                                      pattern="^[a-zA-Z]{'{2}'}(,[a-zA-Z]{'{2}'})*$" />
+        <input type="hidden" name="limit" value="{api_request_params.limit || ''}" />
+        <input type="hidden" name="polygon_threshold" value="{api_request_params.polygon_threshold || ''}" />
+      </div>
     </UrlSubmitForm>
   </div>
   <div class="tab-pane" class:active={bStructuredSearch} id="structured" role="tabpanel">
     <UrlSubmitForm page="search">
-      <input name="street" type="text" class="form-control form-control-sm mr-1"
-             placeholder="House number/Street"
-             value="{api_request_params.street || ''}" />
-      <input name="city" type="text" class="form-control form-control-sm mr-1"
-             placeholder="City"
-             value="{api_request_params.city || ''}" />
-      <input id="county" name="county" type="text" class="form-control form-control-sm mr-1"
-             placeholder="County"
-             value="{api_request_params.county || ''}" />
-      <input name="state" type="text" class="form-control form-control-sm mr-1"
-             placeholder="State"
-             value="{api_request_params.state || ''}" />
-      <input name="country" type="text" class="form-control form-control-sm mr-1"
-             placeholder="Country"
-             value="{api_request_params.country || ''}" />
-      <input name="postalcode" type="text" class="form-control form-control-sm mr-1"
-             placeholder="Postal Code"
-             value="{api_request_params.postalcode || ''}" />
-
-      <button type="submit" class="btn btn-primary btn-sm">Search</button>
-      <input type="hidden" name="viewbox" value="{sViewBox || ''}" />
-      <input type="hidden" name="dedupe" value="{!api_request_params.dedupe ? '' : 1}" />
-      <input type="hidden" name="bounded" value="{api_request_params.bounded ? 1 : ''}" />
-      <input type="hidden" name="accept-language" value="{api_request_params['accept-language'] || ''}" />
-      <input type="hidden" name="countrycodes" value="{api_request_params.countrycodes || ''}" />
-      <input type="hidden" name="limit" value="{api_request_params.limit || ''}" />
-      <input type="hidden" name="polygon_threshold" value="{api_request_params.polygon_threshold || ''}" />
+      <div class="col-auto">
+        <input name="street" type="text" class="form-control form-control-sm me-1"
+               placeholder="House number/Street"
+               value="{api_request_params.street || ''}" />
+      </div>
+      <div class="col-auto">
+        <input name="city" type="text" class="form-control form-control-sm me-1"
+               placeholder="City"
+               value="{api_request_params.city || ''}" />
+      </div>
+      <div class="col-auto">
+        <input id="county" name="county" type="text" class="form-control form-control-sm me-1"
+               placeholder="County"
+               value="{api_request_params.county || ''}" />
+      </div>
+      <div class="col-auto">
+        <input name="state" type="text" class="form-control form-control-sm me-1"
+               placeholder="State"
+               value="{api_request_params.state || ''}" />
+      </div>
+      <div class="col-auto">
+        <input name="country" type="text" class="form-control form-control-sm me-1"
+               placeholder="Country"
+               value="{api_request_params.country || ''}" />
+      </div>
+      <div class="col-auto">
+        <input name="postalcode" type="text" class="form-control form-control-sm me-1"
+               placeholder="Postal Code"
+               value="{api_request_params.postalcode || ''}" />
+      </div>
+      <div class="col-auto">
+        <button type="submit" class="btn btn-primary btn-sm">Search</button>
+        <input type="hidden" name="viewbox" value="{sViewBox || ''}" />
+        <input type="hidden" name="dedupe" value="{api_request_params.dedupe === 0 ? 0 : 1}" />
+        <input type="hidden" name="bounded" value="{api_request_params.bounded ? 1 : ''}" />
+        <input type="hidden" name="accept-language" value="{api_request_params['accept-language'] || ''}" />
+        <input type="hidden" name="countrycodes" value="{api_request_params.countrycodes || ''}"
+                                                pattern="^[a-zA-Z]{'{2}'}(,[a-zA-Z]{'{2}'})*$" />
+        <input type="hidden" name="limit" value="{api_request_params.limit || ''}" />
+        <input type="hidden" name="polygon_threshold" value="{api_request_params.polygon_threshold || ''}" />
+      </div>
     </UrlSubmitForm>
   </div>
 </div> <!-- /tab-content -->
       <div class="form-check form-check-inline">
         <label class="form-check-label" for="option_dedupe">deduplicate results</label>
         <input type="checkbox" class="form-check-input api-param-setting"
-               id="option_dedupe" checked={!!api_request_params.dedupe} on:change={set_dedupe}>
+               id="option_dedupe" checked={api_request_params.dedupe === 0 ? 0 : 1} on:change={set_dedupe}>
       </div>
     </li>
 
     <li>
       <label for="option_limit">Maximum number of results</label>
       <input type="number" class="form-control form-control-sm d-inline w-auto api-param-setting"
-             data-api-param="limit" id="option_limit" size="5" min="1" max="50"
+             data-api-param="limit" id="option_limit" min="1" max="50"
              value="{api_request_params.limit || ''}"
              on:change={set_api_param}>
     </li>
     <li>
       <label for="option_polygon_threshold">Polygon simplification</label>
       <input type="number" class="form-control form-control-sm d-inline w-auto api-param-setting"
-             data-api-param="polygon_threshold" id="option_polygon_threshold" size="5" min="0.0" step="0.01"
+             data-api-param="polygon_threshold" id="option_polygon_threshold" min="0.0"  max="1.0" step="0.001"
              value="{api_request_params.polygon_threshold || ''}"
              on:change={set_api_param}>
     </li>
     </li>
 
     <li>
-      <label for="option_ccode">Countries</label>
+      <label for="option_ccode">Country Codes</label>
       <input type="text" placeholder="e.g. de,gb" class="form-control form-control-sm d-inline w-auto api-param-setting"
              data-api-param="countrycodes" id="option_ccode" size="15"
              value="{api_request_params.countrycodes || ''}"
+             pattern="^[a-zA-Z]{'{2}'}(,[a-zA-Z]{'{2}'})*$"
              on:change={set_api_param}>
     </li>
   </ul>