mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-18 19:51:45 +08:00
Updated the admin content item list ordering to not exclude any items
- having to make the orderby join free and roughly order by content version id to get created and modified order. this is also now doing an order and skip/take after running the query up to that point so it's also not ideal for perf --HG-- branch : dev
This commit is contained in:
@@ -52,19 +52,6 @@ namespace Orchard.Core.Contents.Controllers {
|
|||||||
|
|
||||||
var query = _contentManager.Query(VersionOptions.Latest, _contentDefinitionManager.ListTypeDefinitions().Select(ctd => ctd.Name).ToArray());
|
var query = _contentManager.Query(VersionOptions.Latest, _contentDefinitionManager.ListTypeDefinitions().Select(ctd => ctd.Name).ToArray());
|
||||||
|
|
||||||
// Ordering
|
|
||||||
switch (model.Options.OrderBy) {
|
|
||||||
case ContentsOrder.Modified:
|
|
||||||
query = query.OrderByDescending<CommonRecord, DateTime?>(cr => cr.ModifiedUtc);
|
|
||||||
break;
|
|
||||||
case ContentsOrder.Published:
|
|
||||||
query = query.OrderByDescending<CommonRecord, DateTime?>(cr => cr.PublishedUtc);
|
|
||||||
break;
|
|
||||||
case ContentsOrder.Created:
|
|
||||||
query = query.OrderByDescending<CommonRecord, DateTime?>(cr => cr.CreatedUtc);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(model.TypeName)) {
|
if (!string.IsNullOrEmpty(model.TypeName)) {
|
||||||
var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(model.TypeName);
|
var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(model.TypeName);
|
||||||
if (contentTypeDefinition == null)
|
if (contentTypeDefinition == null)
|
||||||
@@ -79,7 +66,44 @@ namespace Orchard.Core.Contents.Controllers {
|
|||||||
if (model.ContainerId != null)
|
if (model.ContainerId != null)
|
||||||
query = query.Join<CommonRecord>().Where(cr => cr.Container.Id == model.ContainerId);
|
query = query.Join<CommonRecord>().Where(cr => cr.Container.Id == model.ContainerId);
|
||||||
|
|
||||||
var contentItems = query.Slice(skip, pageSize);
|
// Ordering
|
||||||
|
//-- want something like
|
||||||
|
//switch (model.Options.OrderBy) {
|
||||||
|
// case ContentsOrder.Modified:
|
||||||
|
// query = query.OrderByDescending<CommonRecord, DateTime?>(cr => cr.ModifiedUtc);
|
||||||
|
// break;
|
||||||
|
// case ContentsOrder.Published:
|
||||||
|
// query = query.OrderByDescending<CommonRecord, DateTime?>(cr => cr.PublishedUtc);
|
||||||
|
// break;
|
||||||
|
// case ContentsOrder.Created:
|
||||||
|
// query = query.OrderByDescending<CommonRecord, DateTime?>(cr => cr.CreatedUtc);
|
||||||
|
// break;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//-- but resorting to
|
||||||
|
|
||||||
|
IEnumerable<ContentItem> contentItems = query.List();
|
||||||
|
switch (model.Options.OrderBy) {
|
||||||
|
case ContentsOrder.Modified:
|
||||||
|
contentItems = contentItems.OrderByDescending(ci => ci.VersionRecord.Id);
|
||||||
|
break;
|
||||||
|
//case ContentsOrder.Published:
|
||||||
|
// would be lying w/out a published date instead of a bool but that only comes with the common aspect
|
||||||
|
// contentItems = contentItems.OrderByDescending(ci => ci.VersionRecord.Published/*Date*/);
|
||||||
|
// break;
|
||||||
|
case ContentsOrder.Created:
|
||||||
|
contentItems = contentItems.OrderByDescending(ci => ci.Id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-- for the moment
|
||||||
|
//-- because I'd rather do this
|
||||||
|
|
||||||
|
//var contentItems = query.Slice(skip, pageSize);
|
||||||
|
|
||||||
|
//-- instead of this (having the ordering and skip/take after the query)
|
||||||
|
|
||||||
|
contentItems = contentItems.Skip(skip).Take(pageSize);
|
||||||
|
|
||||||
model.Entries = contentItems.Select(BuildEntry).ToList();
|
model.Entries = contentItems.Select(BuildEntry).ToList();
|
||||||
model.Options.SelectedFilter = model.TypeName;
|
model.Options.SelectedFilter = model.TypeName;
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ using (Html.BeginFormAntiForgeryPost()) { %>
|
|||||||
</select>
|
</select>
|
||||||
<label for="orderResults" class="bulk-order"><%:T("Ordered by")%></label>
|
<label for="orderResults" class="bulk-order"><%:T("Ordered by")%></label>
|
||||||
<select id="orderResults" name="<%:Html.NameOf(m => m.Options.OrderBy) %>">
|
<select id="orderResults" name="<%:Html.NameOf(m => m.Options.OrderBy) %>">
|
||||||
<%:Html.SelectOption(Model.Options.OrderBy, ContentsOrder.Created, T("Date Created").ToString())%>
|
<%:Html.SelectOption(Model.Options.OrderBy, ContentsOrder.Created, T("most recently created").ToString())%>
|
||||||
<%:Html.SelectOption(Model.Options.OrderBy, ContentsOrder.Modified, T("Date Modified").ToString())%>
|
<%:Html.SelectOption(Model.Options.OrderBy, ContentsOrder.Modified, T("most recently modified").ToString())%>
|
||||||
<%:Html.SelectOption(Model.Options.OrderBy, ContentsOrder.Published, T("Date Published").ToString())%>
|
<%--<%:Html.SelectOption(Model.Options.OrderBy, ContentsOrder.Published, T("Date Published").ToString())%>--%>
|
||||||
</select>
|
</select>
|
||||||
<button type="submit" name="submit.Filter" value="yes please"><%:T("Apply") %></button>
|
<button type="submit" name="submit.Filter" value="yes please"><%:T("Apply") %></button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
Reference in New Issue
Block a user