Updating the tag edit page to also contain the list of items with that tag

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-11-08 17:25:23 -08:00
parent f4d685c4eb
commit ecdb058802
5 changed files with 31 additions and 51 deletions

View File

@@ -90,7 +90,9 @@ namespace Orchard.Tags.Controllers {
Id = tag.Id,
TagName = tag.TagName,
};
ViewData["ContentItems"] = _tagService.GetTaggedContentItems(id).ToList();
return View(viewModel);
}
@@ -127,21 +129,6 @@ namespace Orchard.Tags.Controllers {
return RedirectToAction("Index");
}
public ActionResult Search(int id) {
Tag tag = _tagService.GetTag(id);
if (tag == null) {
return RedirectToAction("Index");
}
IEnumerable<IContent> contents = _tagService.GetTaggedContentItems(id).ToList();
var viewModel = new TagsAdminSearchViewModel {
TagName = tag.TagName,
Contents = contents,
};
return View(viewModel);
}
private static TagEntry CreateTagEntry(Tag tag) {
return new TagEntry {
Tag = tag,

View File

@@ -86,7 +86,6 @@
<Compile Include="ViewModels\TagsAdminCreateViewModel.cs" />
<Compile Include="ViewModels\TagsAdminEditViewModel.cs" />
<Compile Include="ViewModels\TagsAdminIndexViewModel.cs" />
<Compile Include="ViewModels\TagsAdminSearchViewModel.cs" />
<Compile Include="ViewModels\TagsSearchViewModel.cs" />
<Compile Include="ViewModels\TagsIndexViewModel.cs" />
</ItemGroup>
@@ -96,7 +95,6 @@
<Content Include="Views\Web.config" />
<Content Include="Views\Admin\Edit.cshtml" />
<Content Include="Views\Admin\Index.cshtml" />
<Content Include="Views\Admin\Search.cshtml" />
<Content Include="Views\Parts\Tags.ShowTags.cshtml" />
<Content Include="Views\EditorTemplates\Parts\Tags.cshtml" />
<Content Include="Views\Home\Index.cshtml" />

View File

@@ -1,9 +0,0 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
namespace Orchard.Tags.ViewModels {
public class TagsAdminSearchViewModel {
public string TagName { get; set; }
public IEnumerable<IContent> Contents { get; set; }
}
}

View File

@@ -1,6 +1,8 @@
@model Orchard.Tags.ViewModels.TagsAdminEditViewModel
@using Orchard.ContentManagement;
@using Orchard.Utility.Extensions;
<h1>@Html.TitleForPage(T("Edit a Tag").ToString()) </h1>
<h1>@Html.TitleForPage(T("Manage tag: {0}", Model.TagName).ToString()) </h1>
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
<fieldset>
@@ -12,4 +14,28 @@
<fieldset>
<button class="primaryAction" type="submit">@T("Save")</button>
</fieldset>
}
}
<h2>@T("Content items tagged with {0}", Model.TagName)</h2>
@if (View.ContentItems == null) {
<p>@T("There is nothing tagged with {0}", Model.TagName)</p>
}
else {
<table class="items">
<colgroup>
<col id="Col1" />
<col id="Col2" />
</colgroup>
<thead>
<tr>
<th scope="col">@T("Content Type")</th>
<th scope="co2">@T("Name")</th>
</tr>
</thead>
@foreach (IContent content in View.ContentItems) {
<tr>
<td>@content.ContentItem.ContentType.CamelFriendly()</td>
<td>@Html.ItemDisplayLink(content.ContentItem)</td>
</tr>
}
</table>
}

View File

@@ -1,22 +0,0 @@
@model Orchard.Tags.ViewModels.TagsAdminSearchViewModel
@using Orchard.ContentManagement;
<h1>@Html.TitleForPage(T("List of contents tagged with {0}", Model.TagName).ToString())</h1>
<table class="items">
<colgroup>
<col id="Col1" />
<col id="Col2" />
</colgroup>
<thead>
<tr>
<th scope="col">@T("Name")</th>
<th scope="col">@T("Link to the content item")</th>
</tr>
</thead>
@foreach (var contentItem in Model.Contents) {
<tr>
<td>@Html.ItemDisplayText(contentItem)</td>
<td>@Html.ItemDisplayLink(contentItem)</td>
</tr>
}
</table>