Adding filter for own content

This commit is contained in:
Sebastien Ros
2015-09-16 16:05:21 -07:00
parent 9e9e19c439
commit 921b2472f1
3 changed files with 9 additions and 5 deletions

View File

@@ -65,8 +65,7 @@ namespace Orchard.Core.Contents.Controllers {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var versionOptions = VersionOptions.Latest; var versionOptions = VersionOptions.Latest;
switch (model.Options.ContentsStatus) switch (model.Options.ContentsStatus) {
{
case ContentsStatus.Published: case ContentsStatus.Published:
versionOptions = VersionOptions.Published; versionOptions = VersionOptions.Published;
break; break;
@@ -112,6 +111,10 @@ namespace Orchard.Core.Contents.Controllers {
query = _cultureFilter.FilterCulture(query, model.Options.SelectedCulture); query = _cultureFilter.FilterCulture(query, model.Options.SelectedCulture);
} }
if(model.Options.ContentsStatus == ContentsStatus.Owner) {
query = query.Where<CommonPartRecord>(cr => cr.OwnerId == Services.WorkContext.CurrentUser.Id);
}
model.Options.SelectedFilter = model.TypeName; model.Options.SelectedFilter = model.TypeName;
model.Options.FilterOptions = GetListableTypes(false) model.Options.FilterOptions = GetListableTypes(false)
.Select(ctd => new KeyValuePair<string, string>(ctd.Name, ctd.DisplayName)) .Select(ctd => new KeyValuePair<string, string>(ctd.Name, ctd.DisplayName))

View File

@@ -49,12 +49,12 @@ namespace Orchard.Core.Contents.ViewModels {
Created Created
} }
public enum ContentsStatus public enum ContentsStatus {
{
Draft, Draft,
Published, Published,
AllVersions, AllVersions,
Latest Latest,
Owner
} }
public enum ContentsBulkAction { public enum ContentsBulkAction {

View File

@@ -54,6 +54,7 @@
</select> </select>
<label for="contentResults" class="bulk-order">@T("Filter by")</label> <label for="contentResults" class="bulk-order">@T("Filter by")</label>
<select id="contentResults" name="Options.ContentsStatus"> <select id="contentResults" name="Options.ContentsStatus">
@Html.SelectOption((ContentsStatus)Model.Options.ContentsStatus, ContentsStatus.Owner, T("owned by me").ToString())
@Html.SelectOption((ContentsStatus)Model.Options.ContentsStatus, ContentsStatus.Latest, T("latest").ToString()) @Html.SelectOption((ContentsStatus)Model.Options.ContentsStatus, ContentsStatus.Latest, T("latest").ToString())
@Html.SelectOption((ContentsStatus)Model.Options.ContentsStatus, ContentsStatus.Published, T("published").ToString()) @Html.SelectOption((ContentsStatus)Model.Options.ContentsStatus, ContentsStatus.Published, T("published").ToString())
@Html.SelectOption((ContentsStatus)Model.Options.ContentsStatus, ContentsStatus.Draft, T("unpublished").ToString()) @Html.SelectOption((ContentsStatus)Model.Options.ContentsStatus, ContentsStatus.Draft, T("unpublished").ToString())