We have moved to GitHub Issues
Created by Asbjørn Riis-Knudsen 20 Jul 2016, 07:33:45 Updated by Mads Rasmussen 08 Aug 2016, 12:02:53Tags: PR
Now that 7.5 can sort by custom properties in the list view (finally!), I would expect to be able to set the default sort order for my list view to a custom property as well.
Let's say that I have a list view for a news section. Each item has a date property, which I add as a column in the list view. Since sorting by date is what I want by default, I would go to the Order by dropdown and expect to see my newly added date column here. Instead, this dropdown only contains the system columns. (see screenshot)
This is a major defect of the feature, as it would be much more user friendly for the editors to see items sorted by date automatically instead of manually having to sort by date in the list view.
I was taking a look at making a PR for this. However, one question: Currently, the dropdown for choosing the default sort order is simply a hardcoded list which includes a lot of columns that aren't even in the list view.
In my opinion, the dropdown should only include the columns displayed in the list view (i.e. the list below it). Is there any use case for the default sorting being by a column that is not included in the list view?
Agreed this is a bit of an oversight from my original PR for this feature. If you are taking a look at sorting it, thanks - and if I can help please let me know. From my point of view I can't really see a use case for that scenario, it would likely be confusing for the editors in that they couldn't see how it was sorted nor get back to the original sort without reloading the node. So making the selection for the default order from the list of columns displayed makes sense to me.
I have an in-progress PR here: https://github.com/umbraco/Umbraco-CMS/pull/1406
@abutland If you want to have a look, that would be great. It is working, but there are some questions about dealing with upgrades, as we will potentially be changing values, since some choices have been removed from the menu.
Another option I considered was keeping the old hardcoded list and then just adding custom fields, that would certainly be better for compatibility.
I had a look @arknu thanks. Seemed to me a bit more was necessary to get the actual search working, so I copied what you had into my own repo and extended it a bit. You can view the changes here: https://github.com/AndyButland/Umbraco-CMS/commit/660bc344cfc11d1c4de40c420bff982aea6205d3
I think with this it is now working, so if you'd like to review what I've done, confirm looks good to you and if so pull into your existing PR, please go ahead. Otherwise if you are happy for me to submit a PR myself I'll do that. As you prefer (realise you've started this one and might like to finish it off).
The only thing remaining I can see that would be nice is that as you add and remove columns, they immediately appear in the drop-down list to select the default sort order. Currently you have to save the data type first, which is OK, but not quite so nice. Bit beyond my angular skills to get that working in the right way though.
Wow, thanks for the major improvements, @abutland :) I have incorporated them in my PR and am working on getting the auto-refresh to work. I'll push to the existing PR then.
You should really be able to make a joint pull request, though ;)
I have pushed @abutland's fixes as well as some more of my own to the PR. It is now ready for review: https://github.com/umbraco/Umbraco-CMS/pull/1406
Regrettably, this is currently broken in the inline List View editor in the doctype editor. I'll have a look at solving this tomorrow, though I have a feeling it's going to be tricky.
Any suggestions on how to access the other prevalues in this situation would be welcome. It is possible to walk up the scope via the $parent property, but that seems like a rather nasty hack.
Haven't tried this, just from looking at the code... but have a look in for example
datatype.edit-controller.js, there's a call to
editorState.set($scope.content); after the response from the call to
dataTypeResource.getById() returns. This isn't in place in
umblistviewsettings.directive.js in response from the the similar call to
dataTypeResource.getByName. So looks to me you could add similar there. Then it should be able to be read in
sortby.prevalues.controller.js as we are doing.
@abutland Thanks, will have a look at that :)
@sebastiaan Not sure if you're the one handling this, so please pass it on if not.
I was thinking of handling the problem of the inline listview editor by creating a service to make the prevalues available. It seems somewhat strange to do a service to make one property available in one specific case, but it seems the best solution, I can think of. I just wanted to hear if that would be acceptable before implementing it completely and pushing it to the PR.
Updated the PR. This inline list view editor now works.
Backwards Compatible: True
Fix Submitted: Pull request
Affected versions: 7.5.0
Due in version: 7.5.0
Sprint: Sprint 39