Git Product home page Git Product logo

Comments (12)

devads avatar devads commented on August 11, 2024

I tried with eui-or-filter and it works well !
But there are some problems with filters selected but hide when you choose others filters.
Is it possible to extract filters selected for deleting them ?
Thanks

from elasticui.

YousefED avatar YousefED commented on August 11, 2024

I think what you are looking for is eui-filter-self="false":

https://github.com/YousefED/ElasticUI/blob/master/docs/components.md

from elasticui.

devads avatar devads commented on August 11, 2024

Thanks for your response, like you can see in my first comment, I already use eui-filter-self="false" but it's not the problem.
Example :
I have two TermsAggregation with TermsFilter, one for brand and another for model.
If I choose two brands (Kia and Honda) and in models I choose (Picanto) if I unselected Kia from brand list, I always have Picanto in results from elastic but it's hidden in the select (because I unselected Kia).
So the results are wrong.

I hope this is more understanding.

Thanks,

from elasticui.

YousefED avatar YousefED commented on August 11, 2024

Ah. If I understand you correctly you're selecting a filter, which later gets removed from the interface after another selection changes.

When the filter is removed from the interface, you can't "unselected" it anymore, so it stays active in Elasticsearch


I think a good solution would be to make sure the filter is removed automatically when the interface element is removed.

We should be able to achieve this by watching "this.scope.$on('$destroy'" in FilterController, similar to what's already in AggregationController.

Please let me know whether my analysis seems ok

from elasticui.

devads avatar devads commented on August 11, 2024

Yes, it's exactly this.

I already tried to modify FilterController init by watching "this.scope.$on('$destroy'" but without success

this.scope.$on('$destroy', function() {
    if (_this.scope.filter.enabled)
        _this.scope.filters.remove(_this.scope.filter.filter);
});

It removes all filters even if they are yet in the interface.

If you can help me on this.
Thanks @YousefED

from elasticui.

YousefED avatar YousefED commented on August 11, 2024

Hmm your code looks fine to me. If you could provide a simple JSFiddle / online example I'd love to debug it (for example, change the demo)

from elasticui.

devads avatar devads commented on August 11, 2024

Of course no problem.

There is the fiddle http://jsfiddle.net/gonado/1hLr6kzd/20/

And maybe you need the index example for ES

PUT /cars_ex/

PUT cars_ex/transactions/_mapping/
{
  "transactions": {
   "properties": {
    "brand": {
      "type": "string",
      "fields": {
        "raw":   { "type": "string", "index": "not_analyzed" }
      }},
     "model": {
      "type": "string",
      "fields": {
        "raw":   { "type": "string", "index": "not_analyzed" }
      }}
    }
  }
}
}

POST /cars_ex/transactions/_bulk
{ "index": {}}
{ "price" : 12100, "title" : "Honda Civic 1.6 120ch i-DTEC Business", "brand" : "Honda", "model" : "Civic" }
{ "index": {}}
{ "price" : 15290, "title" : "Honda CR-V 1.6 i-DTEC 160 Exclusive Navi 4WD AT", "brand" : "Honda", "model" : "CR-V" }
{ "index": {}}
{ "price" : 18000, "title" : "BMW SERIE 1 114D 95CH LOUNGE START EDITION 5P", "brand" : "BMW", "model" : "Série 1" }
{ "index": {}}
{ "price" : 25000, "title" : "BMW SÉRIE 3 316DA 116CH LOUNGE START EDITION", "brand" : "BMW", "model" : "Série 3" }
{ "index": {}}
{ "price" : 7990, "title" : "OPEL KARL 1.0 75CH ESSENTIA", "brand" : "Opel", "model" : "Karl" }
{ "index": {}}
{ "price" : 8990, "title" : "OPEL CORSA 1.2 70CH ESSENTIA 3P", "brand" : "Opel", "model" : "Corsa" }
{ "index": {}}
{ "price" : 14990, "title" : "KIA CEED 1.4 CRDI 90CH MOTION", "brand" : "Kia", "model" : "Ceed" }
{ "index": {}}
{ "price" : 22490, "title" : "KIA CARENS 1.7 CRDI 115CH ACTIVE ISG 5 PLACES", "brand" : "Kia", "model" : "Carens" }
{ "index": {}}
{ "price" : 25900, "title" : "VOLKSWAGEN GOLF SPORTSVAN", "brand" : "Volkswagen", "model" : "Golf Sportsvan" }

Thanks !

from elasticui.

devads avatar devads commented on August 11, 2024

The modification is here

FilterController.prototype.init = function () {
                ...
                this.scope.$on('$destroy', function() {
                    if (_this.scope.filter.enabled)
                        _this.scope.filters.remove(_this.scope.filter.filter);
                });
            };

from elasticui.

YousefED avatar YousefED commented on August 11, 2024

Thanks a lot for this. The solution so far doesn't work because the filters always get destroyed and recreated. This makes sense, but unfortunately this means a quick-fix is not readily available (requires more architectural changes).

Another solution might be to create something similar to eui-filter-self="false", but then eui-never-filter="true". This would mean an aggregation (in this case "brands") would never be filtered (would need to update AggregationController.getAggregation()


A quick workaround for your scenario would be to just statically define the brands, instead of via an aggregation. for example something like this for every brand:

<label class="checkbox" eui-filter="ejs.TermsFilter('model.raw', 'BMW')">
            <input type="checkbox" ng-model="filter.enabled">
            BMW
        </label>

Hope this helps for now

from elasticui.

devads avatar devads commented on August 11, 2024

Thanks for your response !

I've already implemented the eui-never-filter, it works great if you want to keep all brands visible.
But you always have the problem with filters get destroyed and present in ES.

This is always a big problem for my scenario, maybe I have to use elastic.js only, but I like to use elasticui, it's so easy to use :-)

Do you think you will make theses changes in the future to adapt elasticui ?

Thanks.

from elasticui.

YousefED avatar YousefED commented on August 11, 2024

What is the problem you keep having after implementing this ("always have the problem with filters get destroyed)?

At this moment, I don't have any plans myself to implement this unfortunately.

from elasticui.

devads avatar devads commented on August 11, 2024

Ok no problem I understand !

Implementing the eui-never-filter keep well all brands even if you choose a model, but If you have a model checked and you unchecked a brand of this model it keeps this model in ES, so it's not working !

I have to find a way to do it.

Thanks for you time.

from elasticui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.