1. Making IsInternal a update to make sure everyone has it.
2. Changing the view model to be like the Terms one. Seems Record is null and that throws an exception

Work Item: 19793

--HG--
branch : 1.x
This commit is contained in:
Nicholas Mayne
2013-06-19 00:54:11 +01:00
parent e77dd8ad53
commit 13d9233c7e
4 changed files with 38 additions and 16 deletions

View File

@@ -55,7 +55,7 @@ namespace Orchard.Taxonomies.Controllers {
return new HttpUnauthorizedResult();
foreach (var entry in checkedEntries) {
_taxonomyService.DeleteTaxonomy(entry.Taxonomy);
_taxonomyService.DeleteTaxonomy(_taxonomyService.GetTaxonomy(entry.Id));
}
break;
@@ -187,7 +187,10 @@ namespace Orchard.Taxonomies.Controllers {
private static TaxonomyEntry CreateTaxonomyEntry(TaxonomyPart taxonomy) {
return new TaxonomyEntry {
Taxonomy = taxonomy,
Id = taxonomy.Id,
Name = taxonomy.Name,
IsInternal = taxonomy.IsInternal,
ContentItem = taxonomy.ContentItem,
IsChecked = false,
};
}

View File

@@ -59,7 +59,17 @@ namespace Orchard.Taxonomies {
.WithSetting("Stereotype", "Widget")
);
return 1;
ContentDefinitionManager.AlterTypeDefinition("TaxonomyNavigationMenuItem",
cfg => cfg
.WithPart("TaxonomyNavigationPart")
.WithPart("MenuPart")
.WithPart("CommonPart")
.DisplayedAs("Taxonomy Link")
.WithSetting("Description", "Injects menu items from a Taxonomy")
.WithSetting("Stereotype", "MenuItem")
);
return 3;
}
public int UpdateFrom1() {
@@ -75,5 +85,11 @@ namespace Orchard.Taxonomies {
return 2;
}
public int UpdateFrom2() {
SchemaBuilder.AlterTable("TaxonomyPartRecord", table => table.AddColumn<bool>("IsInternal"));
return 3;
}
}
}

View File

@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Orchard.Taxonomies.Models;
using Orchard.ContentManagement;
namespace Orchard.Taxonomies.ViewModels {
public class TaxonomyAdminIndexViewModel {
@@ -8,7 +8,10 @@ namespace Orchard.Taxonomies.ViewModels {
}
public class TaxonomyEntry {
public TaxonomyPart Taxonomy { get; set; }
public int Id { get; set; }
public bool IsInternal { get; set; }
public string Name { get; set; }
public ContentItem ContentItem { get; set; }
public bool IsChecked { get; set; }
}

View File

@@ -31,27 +31,27 @@
</thead>
@foreach (var taxonomyEntry in Model.Taxonomies) {
ti = taxonomyIndex;
<tr class="@(taxonomyEntry.Taxonomy.IsInternal ? "internal" : null)">
<tr class="@(taxonomyEntry.IsInternal ? "internal" : null)">
<td>
<input type="hidden" value="@Model.Taxonomies[taxonomyIndex].Taxonomy.Id" name="@Html.NameOf(m => m.Taxonomies[ti].Taxonomy.Id)"/>
@if (!taxonomyEntry.Taxonomy.IsInternal || Authorizer.Authorize(Orchard.Security.StandardPermissions.SiteOwner)) {
<input type="hidden" value="@Model.Taxonomies[taxonomyIndex].Id" name="@Html.NameOf(m => m.Taxonomies[ti].Id)"/>
@if (!taxonomyEntry.IsInternal || Authorizer.Authorize(Orchard.Security.StandardPermissions.SiteOwner)) {
<input type="checkbox" value="true" name="@Html.NameOf(m => m.Taxonomies[ti].IsChecked)"/>
}
</td>
<td>
@if (!taxonomyEntry.Taxonomy.IsInternal || Authorizer.Authorize(Orchard.Security.StandardPermissions.SiteOwner)) {
@Html.ActionLink(taxonomyEntry.Taxonomy.Name, "Index", "TermAdmin", new { taxonomyId = taxonomyEntry.Taxonomy.Id }, new object { })
@if (!taxonomyEntry.IsInternal || Authorizer.Authorize(Orchard.Security.StandardPermissions.SiteOwner)) {
@Html.ActionLink(taxonomyEntry.Name, "Index", "TermAdmin", new { taxonomyId = taxonomyEntry.Id }, new object { })
}
else {
@Html.ItemDisplayText(taxonomyEntry.Taxonomy)
@Html.ItemDisplayText(taxonomyEntry.ContentItem)
}
</td>
<td>
@if (!taxonomyEntry.Taxonomy.IsInternal || Authorizer.Authorize(Orchard.Security.StandardPermissions.SiteOwner)) {
@Html.ItemEditLink(T("Edit").Text, taxonomyEntry.Taxonomy) <text>|</text>
@Html.ActionLink(T("Terms").Text, "Index", "TermAdmin", new { taxonomyId = taxonomyEntry.Taxonomy.Id }, new object { }) <text>|</text>
@Html.ActionLink(T("Delete").Text, "Delete", new { id = taxonomyEntry.Taxonomy.Id }, new object { }) <text>|</text>
@Html.ActionLink(T("Import").Text, "Import", new { id = taxonomyEntry.Taxonomy.Id }, new object { })
@if (!taxonomyEntry.IsInternal || Authorizer.Authorize(Orchard.Security.StandardPermissions.SiteOwner)) {
@Html.ItemEditLink(T("Edit").Text, taxonomyEntry.ContentItem) <text>|</text>
@Html.ActionLink(T("Terms").Text, "Index", "TermAdmin", new { taxonomyId = taxonomyEntry.Id }, new object { }) <text>|</text>
@Html.ActionLink(T("Delete").Text, "Delete", new { id = taxonomyEntry.Id }, new object { }) <text>|</text>
@Html.ActionLink(T("Import").Text, "Import", new { id = taxonomyEntry.Id }, new object { })
}
</td>
</tr>