g3w-suite / g3w-admin

Server module for G3W-SUITE
https://g3w-suite.readthedocs.io/en/latest/g3wsuite_administration.html
Mozilla Public License 2.0
40 stars 34 forks source link

Autocomplete request for formatted values (`suggest` + `fformatter`) #810

Closed Raruto closed 5 months ago

Raruto commented 5 months ago

Checklist

Motivation

Related to: https://github.com/g3w-suite/g3w-admin/pull/787, be able to perfom a request like the following:

https://v37.g3wsuite.it/vector/api/data/qdjango/97/buildings_rating_3d535fae_fd04_4df6_b6ff_8cbd13df078f/?suggest=id_buildings%7Cala&ordering=id_buildings&formatter=1&fformatter=id_buildings

image

// current behavior: "all values are returned"

"data": [
  [1, "Ice Palace"],
  [2, "G3WSUITE"],
  [3, "Garibaldi Palace"],
  [5, "Blue Palace"],
  [6, "Cavour Palace"],
  [7, "Casa Rosada"],
  [8, "Red Building"],
  [9, "G3WSUITE"],
  [10, "Green Palace"],
  [11, "Brown Palace"],
  [12, "White house"],
  [13, "Yellow Palace"],
  [41, "Bob Dylan House"],
  [45, "CasaMia"],
  [46, "fzdg"],
  [51, "Prov Trento"],
  [52, "\\u043a\\u0430\\u043f\\u043a\\u0430\\u043f"],
  [53, "Carnia"],
  [54, "Provincia Lucca"],
  [55, "hfh"],
  [56, "gddg"],
  [57, "Prova mail"],
  [58, "Test mail"],
  [60, "Comune Firenze"],
  [61, "jjjjj"],
  [62, "awrar"],
  [63, "Capannori"],
  [64, "jhgkjgk"],
  [65, "test-ro"],
  [66, "satan star"],
  [67, "Luca"]
]

Suggested solution

Honor the suggest request when combined with fformatter parameter:

// desired behavior: "filter values by 'ala' string"

"data": [
  [1, "Ice Palace"],
  [3, "Garibaldi Palace"],
  [5, "Blue Palace"],
  [6, "Cavour Palace"],
  [10, "Green Palace"],
  [11, "Brown Palace"],
  [13, "Yellow Palace"],
]

PS you should also take in consideration to always perform case insensitive searches for the suggest param (eg. Palace vs palace should not return different results)

Alternatives considered

No response