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

View File

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

View File

@@ -4,15 +4,17 @@
Style.Require("ContentTypesAdmin"); Style.Require("ContentTypesAdmin");
Layout.Title = T("Add New Field To \"{0}\"", Model.Part.DisplayName).ToString(); Layout.Title = T("Add New Field To \"{0}\"", Model.Part.DisplayName).ToString();
var returnUrl = Request.QueryString["returnUrl"];
} }
@using (Html.BeginFormAntiForgeryPost()) { @using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary() @Html.ValidationSummary()
<fieldset> <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"}) @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> <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"}) @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>
@@ -22,6 +24,9 @@
</fieldset> </fieldset>
<fieldset> <fieldset>
<button class="primaryAction" type="submit">@T("Save")</button> <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> </fieldset>
} }

View File

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

View File

@@ -4,12 +4,14 @@
Style.Require("ContentTypesAdmin"); Style.Require("ContentTypesAdmin");
Layout.Title = T("Edit Field \"{0}\"", Html.Raw(Model.DisplayName)).ToString(); Layout.Title = T("Edit Field \"{0}\"", Html.Raw(Model.DisplayName)).ToString();
var returnUrl = Request.QueryString["returnUrl"];
} }
@using (Html.BeginFormAntiForgeryPost()) { @using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary() @Html.ValidationSummary()
<fieldset> <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"}) @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> <span class="hint">@T("Name of the field as it will be displayed in screens.")</span>
@@ -17,5 +19,8 @@
</fieldset> </fieldset>
<fieldset> <fieldset>
<button class="primaryAction" type="submit" name="submit.Save" value="Save">@T("Save")</button> <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> </fieldset>
} }

View File

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