Updating the content list admin to order order on the query (instead of post-query) and added back the published ordering option to the front end

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-11-01 08:59:13 -07:00
parent f2300394e9
commit 35f632f9db
2 changed files with 7 additions and 30 deletions

View File

@@ -65,44 +65,20 @@ namespace Orchard.Core.Contents.Controllers {
if (model.ContainerId != null)
query = query.Join<CommonPartRecord>().Where(cr => cr.Container.Id == model.ContainerId);
// Ordering
//-- want something like
//switch (model.Options.OrderBy) {
// case ContentsOrder.Modified:
// query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.ModifiedUtc);
// break;
// case ContentsOrder.Published:
// query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.PublishedUtc);
// break;
// case ContentsOrder.Created:
// query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.CreatedUtc);
// break;
//}
//-- but resorting to
var contentItems = query.List();
switch (model.Options.OrderBy) {
case ContentsOrder.Modified:
contentItems = contentItems.OrderByDescending(ci => ci.VersionRecord.Id);
query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.ModifiedUtc);
break;
case ContentsOrder.Published:
query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.PublishedUtc);
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);
query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.CreatedUtc);
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)
var pageOfContentItems = contentItems.Skip(pager.GetStartIndex()).Take(pager.PageSize).ToList();
var pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList();
model.Options.SelectedFilter = model.TypeName;
model.Options.FilterOptions = GetCreatableTypes()

View File

@@ -35,6 +35,7 @@
<select id="orderResults" name="Options.OrderBy">
@Html.SelectOption((ContentsOrder)Model.Options.OrderBy, ContentsOrder.Created, T("recently created").ToString())
@Html.SelectOption((ContentsOrder)Model.Options.OrderBy, ContentsOrder.Modified, T("recently modified").ToString())
@Html.SelectOption((ContentsOrder)Model.Options.OrderBy, ContentsOrder.Published, T("recently published").ToString())
</select>
<button type="submit" name="submit.Filter" value="yes please">@T("Apply")</button>
</fieldset>