uasoft-indonesia / badaso

Laravel Vue headless CMS / admin panel / dashboard / builder / API CRUD generator, anything !
https://badaso.uatech.co.id
MIT License
1.21k stars 223 forks source link

Search with blank #571

Closed Dri372 closed 2 years ago

Dri372 commented 2 years ago

Description When you enter a search with a blank, ie : text1 text2 , search is done on "text1 text2" that's sound goog but it's not the "classical" way.

-a- Describe the solution you'd like Search enter : "text1 text2" -> search "text1 text2" as actual Search enter : text1 tex2 -> search text1 AND text2

-b-Even better solution Accept simple logic in the search enter, ie Search enter : text1 -OR- text2 -> search text1 OR text2

-a- Idea of solution in vendor/badaso/core/src/resources/js/components/BadasoTable.vue

    getItemsSearch(min, max) {
      const search = this.normalize(this.searchx);
      const searchs = search.split(" ");
      return this.sortItems(this.data)
        .filter((tr) => {
                let res=true;
                searchs.forEach ( search => {
                        res= res && ( this.normalize(this.getValues(tr).toString()).indexOf(search) != -1 );
                })
                return ( res );
        })
    queriedResults() {
      let queriedResults = this.data;
      if (this.searchx && this.search) {
        let searchs = this.searchx.split(" "); 
        let dataBase = this.data;
        queriedResults = dataBase.filter((tr) => {
          let values = this.getValues(tr)
            .toString()
            .toLowerCase();
          let res=true;                               
          searchs.forEach ( search => {
                res= res && ( values.indexOf(search.toLowerCase()) != -1 );
          });
          return ( res );
        });
      }
      return queriedResults;
    },

Note : Should be probably good to have the previous code in a common method (no duplicate code)

rizkiheryandi commented 2 years ago

I think you can create a PR for this, so we can try your solution, thank you

Dri372 commented 2 years ago

Should be possible.

But first can you remove your duplicate code (code the search in only one place), or explain why it's not your solution?

Then I propose, if your are ok, the following search :

rizkiheryandi commented 2 years ago

Hi @Dri372

Could you give a demonstrate with real case keywords ? maybe with smartphone or laptop things ? so i can understand it better

you can also provide a screenshot or some visualitation also if posibble

or some refference from another link too that we can test

thanks in advance

Dri372 commented 2 years ago

Let's imagine a table 'cars' with 3 fields model, power, color m1; 50 ; Black m1 ; 50 ; Red m2 ; 50 ; Black m2; 60 : Green

With the actual Seacrh, it's not possible to list all black cars of 50 kW With the proposed modif if you enter in the Search : 50 Black (or Black 50) you'll get the answer : m1; 50 ; Black m2 ; 50 ; Black

PS : I just found that we can do the search using comma : 50,Black get also the answer. Don't know if you code this, if it s documented, it's ok but not 'standard'

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.