[Fixes #7131] Orchard.ContentTypes - Add / Edit Field Issues (#7150)

This commit is contained in:
Matthew Harris
2016-09-29 20:58:04 +01:00
committed by Sébastien Ros
parent ed94ba11e7
commit 37e8696fe0
6 changed files with 31 additions and 22 deletions

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Orchard.ContentManagement.MetaData;
namespace Orchard.ContentTypes.ViewModels {
@@ -11,19 +10,16 @@ namespace Orchard.ContentTypes.ViewModels {
/// <summary>
/// The technical name of the field
/// </summary>
[Required]
public string Name { get; set; }
/// <summary>
/// The display name of the field
/// </summary>
[Required]
public string DisplayName { get; set; }
/// <summary>
/// The selected field type
/// </summary>
[Required]
public string FieldTypeName { get; set; }
/// <summary>

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Orchard.ContentManagement.MetaData;
namespace Orchard.ContentTypes.ViewModels {
@@ -12,7 +11,6 @@ namespace Orchard.ContentTypes.ViewModels {
/// <summary>
/// The display name of the field
/// </summary>
[Required]
public string DisplayName { get; set; }
}
}

View File

@@ -4,17 +4,19 @@
Style.Require("ContentTypesAdmin");
Layout.Title = T("Add New Field To \"{0}\"", Model.Part.DisplayName).ToString();
var returnUrl = Request.QueryString["returnUrl"];
}
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
<fieldset>
<label for="DisplayName">@T("Display Name")</label>
<label for="DisplayName" class="required">@T("Display Name")</label>
@Html.TextBoxFor(m => m.DisplayName, new {@class = "text medium", autofocus = "autofocus"})
<span class="hint">@T("Name of the field as it will be displayed in screens.")</span>
<label for="Name">@T("Technical Name")</label>
<label for="Name" class="required">@T("Technical Name")</label>
@Html.TextBoxFor(m => m.Name, new {@class = "text"})
<span class="hint">@T("Technical name of the field.")</span>
<span class="hint">@T("Technical name of the field.")</span>
</fieldset>
<fieldset>
<label for="FieldTypeName">@T("Field Type")</label>
@@ -22,6 +24,9 @@
</fieldset>
<fieldset>
<button class="primaryAction" type="submit">@T("Save")</button>
@if (!String.IsNullOrWhiteSpace(returnUrl) && Request.IsLocalUrl(returnUrl)) {
<a id="button-cancel" href="@returnUrl" class="button">@T("Cancel")</a>
}
</fieldset>
}

View File

@@ -1,8 +1,10 @@
@using Orchard.Utility.Extensions;
@model Orchard.ContentTypes.ViewModels.EditTypeViewModel
@{
Style.Require("ContentTypesAdmin");
Script.Require("jQuery");
Layout.Title = T("Edit Content Type - {0}", Html.Raw(Model.DisplayName)).Text;
var returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
}
<div class="manage">
@@ -27,7 +29,7 @@
<div class="manage-type">
<h2>@T("Fields")</h2>
<div class="manage add-to-type">
@Html.ActionLink(T("Add Field").Text, "AddFieldTo", new { area = "Orchard.ContentTypes", id = Model.Name }, new { @class = "button" })
@Html.ActionLink(T("Add Field").Text, "AddFieldTo", new { area = "Orchard.ContentTypes", id = Model.Name, returnUrl }, new { @class = "button" })
</div>
@Html.EditorFor(m => m.Fields, "Fields", "")
<h2>@T("Parts")</h2>

View File

@@ -4,12 +4,14 @@
Style.Require("ContentTypesAdmin");
Layout.Title = T("Edit Field \"{0}\"", Html.Raw(Model.DisplayName)).ToString();
var returnUrl = Request.QueryString["returnUrl"];
}
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
<fieldset>
<label for="DisplayName">@T("Display Name")</label>
<label for="DisplayName" class="required">@T("Display Name")</label>
@Html.TextBoxFor(m => m.DisplayName, new {@class = "text medium", autofocus = "autofocus"})
<span class="hint">@T("Name of the field as it will be displayed in screens.")</span>
@@ -17,5 +19,8 @@
</fieldset>
<fieldset>
<button class="primaryAction" type="submit" name="submit.Save" value="Save">@T("Save")</button>
@if (!String.IsNullOrWhiteSpace(returnUrl) && Request.IsLocalUrl(returnUrl)) {
<a id="button-cancel" href="@returnUrl" class="button">@T("Cancel")</a>
}
</fieldset>
}

View File

@@ -1,13 +1,16 @@
@using Orchard.Utility.Extensions
@model Orchard.ContentTypes.ViewModels.EditPartFieldViewModel
<fieldset class="manage-field">
<h3>@Model.DisplayName <span>(@Model.FieldDefinition.Name.CamelFriendly())</span></h3>
<div class="manage">
@Html.ActionLink(T("Edit").Text, "EditField", new { area = "Orchard.ContentTypes", id = Model.Part.Name, Model.Name }) |
@Html.ActionLink(T("Remove").Text, "RemoveFieldFrom", new { area = "Orchard.ContentTypes", id = Model.Part.Name, Model.Name }, new { itemprop = "RemoveUrl UnsafeUrl" })
</div>
<div class="details">
@{Html.RenderTemplates(Model.Templates);}
@Html.HiddenFor(m => m.Name)@Html.HiddenFor(m => m.FieldDefinition.Name)@Html.HiddenFor(m => m.Index)
</div>
</fieldset>
@{
var returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
}
<fieldset class="manage-field">
<h3>@Model.DisplayName <span>(@Model.FieldDefinition.Name.CamelFriendly())</span></h3>
<div class="manage">
@Html.ActionLink(T("Edit").Text, "EditField", new { area = "Orchard.ContentTypes", id = Model.Part.Name, Model.Name, returnUrl }) |
@Html.ActionLink(T("Remove").Text, "RemoveFieldFrom", new { area = "Orchard.ContentTypes", id = Model.Part.Name, Model.Name }, new { itemprop = "RemoveUrl UnsafeUrl" })
</div>
<div class="details">
@{Html.RenderTemplates(Model.Templates);}
@Html.HiddenFor(m => m.Name)@Html.HiddenFor(m => m.FieldDefinition.Name)@Html.HiddenFor(m => m.Index)
</div>
</fieldset>