Repository navigation
Conversation
|
@twinturbo What's the status of this? I know you wanted to add some more filtering functionality. Also, I'm thinking that it probably wouldn't hurt to add the following just so we don't get people complaining: Ember.SortableMixin = Ember.Mixin.create(Ember.ArrangeableMixin, {
init: function() {
Ember.deprecate("Ember.SortableMixin has been replaced by Ember.ArrangeableMixin.");
this._super();
}
}); |
|
I've added all the functionality I want. I just need to add docs and the
|
|
@twinturbo there is currently a failing test in the sortable mixin (see #1537), can you add this test to this PR? |
|
@crofty will do. |
There was a problem hiding this comment.
In order to support the following example:
filterProperties: [['isNew', false]]I think that it is as follows:
if (arguments.length === 3) {There was a problem hiding this comment.
@twinturbo I'm sorry for an ambiguous comment. It was fixed by ahawkins@ebe0337. Great works!
|
@wagenet this is approaching completeness. Can you confer with the core team? |
|
👍 works great for me |
|
@twinturbo Github is reporting that it can't be merged automatically. Can you look into this? |
Works in a similar way to the SortableMixin. Mix this into an ArrayProxy, define the filterProperties and the array will be filtered to only include the objects whose filterProperties are truthy. You can get more advanced filtering by defining a custom filterCondition. The filterCondition is used to determine if the object is to be included in the filtered list. Any item properties used in the filterCondition will need to be lised in filterProperties.
These verify that the FilterableMixin works with bound content and updates correctly when the content is swapped out.
filterFunction can be overridden to correctly process any object/key/value pair. This commit also removes some duplicate tests
|
@wagenet let me know what you think should be documented. I documented the main public parts. IDK what to do about the private stuff. |
|
Hey @twinturbo, thanks for all of your hard work on this. @igorT has a proposal for handling this problem that allows it to be composed quite nicely. We've asked him to post his thoughts here to discuss how we can unify the efforts. |
|
@tomdale thanks for the update. I'll hang tight until then. |
|
just ran into this, can't wait for a nicer solution than copy pasta 💩 |
There was a problem hiding this comment.
@twinturbo it would be nice to add support for passing the key into sortFunction. The sortFunction is somewhat useless if you have multiple sortProperties that are the same data type.
sortFunction(get(item1, propertyName), get(item2, propertyName),propertyName);|
I thought about this for a while, and while I need to write a detailed spec/code it up here are some of my thoughts. It seems bad that we need a special mixin just because Sortable and Filterable do not play nice together. This is actually a symptom of a deeper problem, that the ArrayProxy API is not designed to be used by multiple mixins. Even if we were to accept the Arrangeable mixin as a special case, we run into the same problem once somebody wants to extend it and modify it, either by changing the arrangedContent or just trying to mix in another ArrayProxy mixin. The way forward IMO would be to extend ArrayProxy API with several methods/properties and use those to desing a Sortable/Filterable, such that they both can be applied at the same time. The main problem right now are the contentArrayWillChange and contentArrayDidChange methods, as they assume they operate on a continuous selection of items, which breaks if you want to do a sort and then call _super() and pass it to you parent method which might be one from filterable. Making new methods that act on a element, index pair would work a lot better. You could then imagine having a filterable which simply decides whether or not to call _super() for a particular element and actually insert it, and a sortable that calls _super() with the new index. You would also need to extend arrangedContent and propagate initial setup there as well. With this approach you can then easily have something like ArrayProxy.extends(Sortable, Filterable, Reversable, SomethingElsable, myOwnProxy), instead of having special cases. I might have time to spike this during the holidays. |
|
Question from this morning... what is "Arrangable"? |
There was a problem hiding this comment.
@twinturbo discussed w/ @wycats @tomdale this AM. You're observing items in the array and needlessly recaulcuating while constructing the arrangableContent. It eventually finishes, but is highly inefficient.
We monkeypatched my running instance by copying off content to origContent and then moved this forEach below L#156
|
@igorT anything so far? |
|
@igorT 👍 would be interested in seeing what you come up with as well. We're using ArrangableMixin and functionally it's great, but architecturally there are some issues that could use some ❤️ (eg: observer problem mentioned above). |
|
@leepforg ill take care of that. Should be an easy fix.
|
|
@twinturbo The fix listed above breaks tests, so something else will need to be done. |
|
so... @igorT the API update/rewrite you mentioned in your comment above, is this something you are still planning on doing? |
|
We're going to close this in favor of making sortable and filterable composable. If there are bugs that make that hard today, let's fix them. |
|
@twinturbo I hope you will work with @igorT on a PR that implements the composition idea. |
|
@igorT I know you're super busy with ED these days, and it's been a while, but do you have your notes handy on how you wanted to handle ArrayProxy? I've been trying to hack away at a Filterable mixin lately, and bumped into the issues described here. I'm motivated to try and work on this issue. |
|
All the comments here were before array/reduce computeds were created, so I
|
[BUGFIX] properly surface deprecation message
This PR take commits from #1288 and combines that with the existing
SortableMixin. This makes it easier to use both at the same time. It also should be more performant in the combined use case because it does not have to loop over thecontentarray twice to add observers. The existing api fromEmber.SortableMixinis mirrored for filtering. You can specifyfilterPropertiesthe same assortProperties.There is one failing test ATM. The test is carried over from the
Ember.SortableMixinand the other PR. I've added more tests around filtering and sorting the same array.I've pushed this code to say that I'm serious about this feature. This is a major pain point of us. I can't see why there can't be one single mixin to do this.
The original implementation is from @crofty. I've simply pulled his commits and refactored them so they can be merged with
Ember.SortableMixin.Edit: I've realized that I completely suck at spelling and/or typing.