FoxUSA/StoreDown

Suggestion -- Location autocomplete/suggestions

icsy7867 opened this issue · 3 comments

I am about to tackle a large and messy storage room. I was trying to plan out the best way to do this. The location field seems to work well, but the idea of repetitively typing in similar location strings seems repetitive and superfluous.

I think an autocomplete suggestion solution would work very well here. I have used this library in the past:
https://tarekraafat.github.io/autoComplete.js/#/

Basically pulling all of the existing locations through couch db, and adding that as an array of strings to the autocomplete library, it would make inputting a lot of items a lot easier. For example, if i have multiple initial locations, and I am reorganizing a storage closet (Lets call it Storage Closet 1), simply typing "Storage Closet 1" would give me all of the possible locations in that specific location, and one could simply click it.

I dont do a whole lot in javascript, and even I found this library stupidly easy to use, and I think it could add a lot of utility to StoreDown with very minimal modifications. For my use case, I am importing a moderately large list of users from LDAP (About 1000), and I have an email/username autocomplete. I load the entire list from an API I made and load it into the website and it is quite snappy.

Also thinking about all of these containers and Items I am about to create and go through, having a "use last location" button or maybe after making an asset having a "Add another" which defaults to the previous location could be helpful as well.

Looking at the couchdb a quick and dirty query will work:

curl -X POST https://couchdb.domain.com/storedown/_find \
  -H "Content-Type: application/json" -u 'couch:myP@ssw0rd' \
  --data-binary @- << EOF
{
    "selector": {},
    "fields": ["location"]
}
EOF

Was looking into doing the SQL equivalent of a "DISTINCT". It looks like couchdb supports a "group=true", but it looks like you would have to create a view for this, and the "find" method doesnt support that. This would need to be queried and cleaned up to only have unique. Looks like this isnt hard to do:
https://stackoverflow.com/questions/1960473/get-all-unique-values-in-a-javascript-array-remove-duplicates

However, if you have more than 10,000 locations or so, it might take some time. But any reasonable amount of "locations" should be pretty quick.

Have you seen the prefix feature? That is how I solved this for my use cases

I didn't! I will take a look at this, this weekend! Thanks