ContentTypes: Code styling and page title standardization (with encoding fix) in Admin templates

This commit is contained in:
Lombiq
2019-08-27 19:42:02 +02:00
committed by Benedek Farkas
parent b018234e39
commit 142ef2b458
12 changed files with 186 additions and 163 deletions

View File

@@ -1,9 +1,11 @@
@using Orchard.Utility.Extensions
@model Orchard.ContentTypes.ViewModels.AddFieldViewModel
@{
Style.Require("ContentTypesAdmin");
Layout.Title = T("Add New Field To \"{0}\"", Model.Part.DisplayName).ToString();
Layout.Title = T("Add New Field To \"{0}\"", Html.Raw(Model.Part.DisplayName)).Text;
var returnUrl = Request.QueryString["returnUrl"];
}
@@ -31,48 +33,48 @@
}
@using(Script.Foot()){
<script type="text/javascript">
//<![CDATA[
$(function(){
var $name = $("#@Html.FieldIdFor(m=>m.Name)");
var $displayName = $("#@Html.FieldIdFor(m=>m.DisplayName)");
var partName = "@Model.Part.Name";
<script type="text/javascript">
//<![CDATA[
$(function(){
var $name = $("#@Html.FieldIdFor(m=>m.Name)");
var $displayName = $("#@Html.FieldIdFor(m=>m.DisplayName)");
var partName = "@Model.Part.Name";
var jsonUrl = "@Url.Action("FieldName", "Admin", new RouteValueDictionary { {"Area","Orchard.ContentTypes"} } )";
var version = 0;
var jsonUrl = "@Url.Action("FieldName", "Admin", new RouteValueDictionary { {"Area","Orchard.ContentTypes"} } )";
var version = 0;
var nameAltered;
$name.keypress(function() {
nameAltered = true;
});
var nameAltered;
$name.keypress(function() {
nameAltered = true;
});
var compute = function() {
// stop processing automatically if altered by the user
if(nameAltered) {
return true;
}
var compute = function() {
// stop processing automatically if altered by the user
if(nameAltered) {
return true;
}
$.post(jsonUrl, {
partName: partName,
displayName: $displayName.val(),
version: ++version,
__RequestVerificationToken: $("input[name=__RequestVerificationToken]").val()
},
function(data) {
if(version == data.version) {
$name.val(data.result);
}
},
"json"
);
};
$.post(jsonUrl, {
partName: partName,
displayName: $displayName.val(),
version: ++version,
__RequestVerificationToken: $("input[name=__RequestVerificationToken]").val()
},
function(data) {
if(version == data.version) {
$name.val(data.result);
}
},
"json"
);
};
//pull technical name input from tab order
$name.attr("tabindex", -1);
//pull technical name input from tab order
$name.attr("tabindex", -1);
$displayName.keyup(compute);
$displayName.blur(compute);
})
//]]>
</script>
$displayName.keyup(compute);
$displayName.blur(compute);
})
//]]>
</script>
}

View File

@@ -1,9 +1,12 @@
@model Orchard.ContentTypes.ViewModels.AddPartsViewModel
@{
Style.Require("ContentTypesAdmin");
Layout.Title = T("Add Parts To \"{0}\"", Model.Type.DisplayName).ToString();
Layout.Title = T("Add Parts To \"{0}\"", Html.Raw(Model.Type.DisplayName)).Text;
}
@T("Choose the Parts to add to this Content Type.")
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
<fieldset>

View File

@@ -1,6 +1,8 @@
@model Orchard.ContentTypes.ViewModels.CreateTypeViewModel
@{ Layout.Title = T("New Content Type").ToString(); }
@{
Layout.Title = T("New Content Type").Text;
}
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
@@ -14,48 +16,49 @@
</fieldset>
<fieldset>
<button class="primaryAction" type="submit">@T("Create")</button>
</fieldset>}
</fieldset>
}
@using(Script.Foot()){
<script type="text/javascript">
//<![CDATA[
$(function(){
var $name = $("#@Html.FieldIdFor(m=>m.Name)");
var $displayName = $("#@Html.FieldIdFor(m=>m.DisplayName)");
var jsonUrl = "@Url.Action("ContentTypeName", "Admin", new RouteValueDictionary { {"Area","Orchard.ContentTypes"} } )";
var version = 0;
<script type="text/javascript">
//<![CDATA[
$(function(){
var $name = $("#@Html.FieldIdFor(m=>m.Name)");
var $displayName = $("#@Html.FieldIdFor(m=>m.DisplayName)");
var jsonUrl = "@Url.Action("ContentTypeName", "Admin", new RouteValueDictionary { {"Area","Orchard.ContentTypes"} } )";
var version = 0;
var nameAltered;
$name.keypress(function() {
nameAltered = true;
});
var nameAltered;
$name.keypress(function() {
nameAltered = true;
});
var compute = function() {
// stop processing automatically if altered by the user
if(nameAltered) {
return true;
}
var compute = function() {
// stop processing automatically if altered by the user
if(nameAltered) {
return true;
}
$.post(jsonUrl, {
displayName: $displayName.val(),
version: ++version,
__RequestVerificationToken: $("input[name=__RequestVerificationToken]").val()
},
function(data) {
if(version == data.version) {
$name.val(data.result);
}
},
"json"
);
};
$.post(jsonUrl, {
displayName: $displayName.val(),
version: ++version,
__RequestVerificationToken: $("input[name=__RequestVerificationToken]").val()
},
function(data) {
if(version == data.version) {
$name.val(data.result);
}
},
"json"
);
};
//pull technical name input from tab order
$name.attr("tabindex", -1);
//pull technical name input from tab order
$name.attr("tabindex", -1);
$displayName.keyup(compute);
$displayName.blur(compute);
})
//]]>
</script>
$displayName.keyup(compute);
$displayName.blur(compute);
})
//]]>
</script>
}

View File

@@ -1,6 +1,8 @@
@model Orchard.ContentTypes.ViewModels.CreatePartViewModel
@{ Layout.Title = T("New Content Part").ToString(); }
@{
Layout.Title = T("New Content Part").Text;
}
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
@@ -11,4 +13,5 @@
</fieldset>
<fieldset>
<button class="primaryAction" type="submit">@T("Create")</button>
</fieldset>}
</fieldset>
}

View File

@@ -1,5 +1,5 @@
@using Orchard.Utility.Extensions;
@model Orchard.ContentTypes.ViewModels.EditTypeViewModel
@{
Style.Require("ContentTypesAdmin");
Script.Require("jQuery");
@@ -45,13 +45,13 @@
</div>
}
@using(Script.Foot()){
<script type="text/javascript">
//<![CDATA[
(function ($) {
$(".manage-field h3,.manage-part h3").expandoControl(function (controller) { return controller.nextAll(".details"); }, { collapse: true, remember: false });
$(".manage-field h4").expandoControl(function (controller) { return controller.nextAll(".settings"); }, { collapse: true, remember: false });
})(jQuery);
//]]>
</script>
@using(Script.Foot()) {
<script type="text/javascript">
//<![CDATA[
(function ($) {
$(".manage-field h3,.manage-part h3").expandoControl(function (controller) { return controller.nextAll(".details"); }, { collapse: true, remember: false });
$(".manage-field h4").expandoControl(function (controller) { return controller.nextAll(".settings"); }, { collapse: true, remember: false });
})(jQuery);
//]]>
</script>
}

View File

@@ -1,9 +1,11 @@
@using Orchard.Utility.Extensions
@model Orchard.ContentTypes.ViewModels.EditFieldNameViewModel
@{
Style.Require("ContentTypesAdmin");
Layout.Title = T("Edit Field \"{0}\"", Html.Raw(Model.DisplayName)).ToString();
Layout.Title = T("Edit Content Field - {0}", Html.Raw(Model.DisplayName)).Text;
var returnUrl = Request.QueryString["returnUrl"];
}

View File

@@ -1,8 +1,9 @@
@model Orchard.ContentTypes.ViewModels.EditPartViewModel
@{
Style.Require("ContentTypesAdmin");
Script.Require("jQuery");
Layout.Title = T("Edit Part").ToString();
Layout.Title = T("Edit Content Part - {0}", Html.Raw(Model.DisplayName)).Text;
}
@using (Html.BeginFormAntiForgeryPost()) {
@@ -28,12 +29,12 @@
}
@using(Script.Foot()){
<script type="text/javascript">
//<![CDATA[
(function ($) {
$(".manage-field h3,.manage-part h3").expandoControl(function (controller) { return controller.nextAll(".details"); }, { collapse: true, remember: false });
$(".manage-field h4").expandoControl(function (controller) { return controller.nextAll(".settings"); }, { collapse: true, remember: false });
})(jQuery);
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
(function ($) {
$(".manage-field h3,.manage-part h3").expandoControl(function (controller) { return controller.nextAll(".details"); }, { collapse: true, remember: false });
$(".manage-field h4").expandoControl(function (controller) { return controller.nextAll(".settings"); }, { collapse: true, remember: false });
})(jQuery);
//]]>
</script>
}

View File

@@ -1,8 +1,9 @@
@model Orchard.ContentTypes.ViewModels.EditPlacementViewModel
@{
Style.Require("ContentTypesAdmin");
Script.Require("jQueryUI_Sortable");
Layout.Title = T("Edit Placement - {0}", Model.ContentTypeDefinition.DisplayName).ToString();
Layout.Title = T("Edit Placement - {0}", Html.Raw(Model.ContentTypeDefinition.DisplayName)).Text;
var hiddenShapes = Model.AllPlacements.Where(x => String.IsNullOrEmpty(x.PlacementSettings.Zone) && (String.IsNullOrWhiteSpace(x.PlacementSettings.Position) || x.PlacementSettings.Position == "-"));
}
@@ -12,7 +13,6 @@
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
<ul id="placement">
@for (int i = 0; i < Model.AllPlacements.Count; i++ ) {
@@ -24,13 +24,13 @@
<li data-shape-type="@placement.ShapeType" data-shape-differentiator="@placement.Differentiator" data-shape-zone="Content" data-shape-position="@placement.Position">
<div class="shape-type"><h3>@placement.ShapeType @placement.Differentiator</h3></div>
<div class="shape-editor">
@try {
@Display(Model.AllPlacements[i].Shape)
}
catch {
}
</div>
<div class="shape-editor">
@try {
@Display(Model.AllPlacements[i].Shape)
}
catch {
}
</div>
@* @shape.Position @(Model.PlacementSettings.Any(x => x.Equals(shape)))*@
@Html.HiddenFor(m => m.AllPlacements[i].PlacementSettings.ShapeType, new { @class = "type" })
@@ -45,63 +45,62 @@
<button class="primaryAction" type="submit" name="submit.Save" value="Save">@T("Save")</button>
<button class="primaryAction" type="submit" name="submit.Restore" value="Restore" itemprop="RemoveUrl" data-message="@T("Are you sure you want to restore these placements?")">@T("Restore")</button>
</fieldset>
}
@using (Script.Foot()) {
<script type="text/javascript">
//<![CDATA[
(function ($) {
<script type="text/javascript">
//<![CDATA[
(function ($) {
var assignPositions = function () {
var position = 0;
$('.type').each(function () {
var input = $(this);
reAssignIdName(input, position); // type
var assignPositions = function () {
var position = 0;
$('.type').each(function () {
var input = $(this);
reAssignIdName(input, position); // type
input = input.next();
reAssignIdName(input, position); // differentiator
input = input.next();
reAssignIdName(input, position); // differentiator
input = input.next();
reAssignIdName(input, position); // zone
input = input.next();
reAssignIdName(input, position); // zone
input = input.next();
reAssignIdName(input, position); // position
input = input.next();
reAssignIdName(input, position); // position
input.val(++position);
});
};
input.val(++position);
});
};
var reAssignIdName = function (input, pos) {
var name = input.attr('name');
input.attr('name', name.replace(new RegExp("\\[.*\\]", 'gi'), '[' + pos + ']'));
var reAssignIdName = function (input, pos) {
var name = input.attr('name');
input.attr('name', name.replace(new RegExp("\\[.*\\]", 'gi'), '[' + pos + ']'));
var id = input.attr('id');
input.attr('id', id.replace(new RegExp('_.*__', 'i'), '_' + pos + '__'));
};
var id = input.attr('id');
input.attr('id', id.replace(new RegExp('_.*__', 'i'), '_' + pos + '__'));
};
assignPositions();
assignPositions();
var startPos;
var startPos;
$('#placement').sortable({
placeholder: "placement-placeholder",
start: function (event, ui) {
var self = $(ui.item);
startPos = self.prevAll().size();
},
stop: function (event, ui) {
assignPositions();
$('#save-message').show();
$('#placement').sortable({
placeholder: "placement-placeholder",
start: function (event, ui) {
var self = $(ui.item);
startPos = self.prevAll().size();
},
stop: function (event, ui) {
assignPositions();
$('#save-message').show();
}
});
}
});
$('.shape-editor *').attr('disabled', 'disabled');
$('.shape-editor *').attr('disabled', 'disabled');
$("#placement").disableSelection();
$("#placement").disableSelection();
})(jQuery);
//]]>
</script>
})(jQuery);
//]]>
</script>
}

View File

@@ -1,22 +1,25 @@
@model Orchard.ContentTypes.ViewModels.ListContentTypesViewModel
@{
Style.Require("ContentTypesAdmin");
Script.Require("jQuery");
Script.Include("admin-contenttypes.js");
Layout.Title = T("Manage Content Types").ToString();
Layout.Title = T("Manage Content Types").Text;
}
<div class="manage">
@Html.ActionLink(T("Create new type").ToString(), "Create", new{Controller="Admin",Area="Orchard.ContentTypes"}, new { @class = "button primaryAction" })
@Html.ActionLink(T("Create new type").Text, "Create", new { Controller = "Admin", Area = "Orchard.ContentTypes" }, new { @class = "button primaryAction" })
</div>
<fieldset class="bulk-actions">
<label for="search-box">@T("Filter:")</label>
<input id="search-box" class="text" type="text" autofocus="autofocus" />
</fieldset>
<ul class="contentItems">
@foreach (var type in Model.Types) {
<li data-record-text="@type.DisplayName">
@Html.DisplayFor(m => type)
</li>
<li data-record-text="@type.DisplayName">
@Html.DisplayFor(m => type)
</li>
}
</ul>

View File

@@ -1,20 +1,25 @@
@model Orchard.ContentTypes.ViewModels.ListContentPartsViewModel
@{
Script.Require("jQuery");
Script.Include("admin-contenttypes.js");
Layout.Title = T("Content Parts").ToString();
Layout.Title = T("Content Parts").Text;
}
<div class="manage">
@Html.ActionLink(T("Create new part").ToString(), "CreatePart", new{Controller="Admin",Area="Orchard.ContentTypes"}, new { @class = "button primaryAction" })
@Html.ActionLink(T("Create new part").Text, "CreatePart", new { Controller = "Admin", Area = "Orchard.ContentTypes" }, new { @class = "button primaryAction" })
</div>
<fieldset class="bulk-actions">
<label for="search-box">@T("Filter:")</label>
<input id="search-box" class="text" type="text" autofocus="autofocus" />
</fieldset>
<ul class="contentItems">
@foreach (var type in Model.Parts) {
<li data-record-text="@type.DisplayName">
@Html.DisplayFor(m => type)
</li>
<li data-record-text="@type.DisplayName">
@Html.DisplayFor(m => type)
</li>
}
</ul>

View File

@@ -1,7 +1,8 @@
@model Orchard.ContentTypes.ViewModels.RemoveFieldViewModel
@{
Style.Require("ContentTypesAdmin");
Layout.Title = T("Remove the \"{0}\" part from \"{1}\"", Model.Name, Model.Part.DisplayName).ToString();
Layout.Title = T("Remove the \"{0}\" Content Field from \"{1}\"", Model.Name, Html.Raw(Model.Part.DisplayName)).Text;
}
@using (Html.BeginFormAntiForgeryPost()) {

View File

@@ -1,7 +1,8 @@
@model Orchard.ContentTypes.ViewModels.RemovePartViewModel
@{
Style.Require("ContentTypesAdmin");
Layout.Title = T("Remove the \"{0}\" part from \"{1}\"", Model.Name, Model.Type.DisplayName).ToString();
Layout.Title = T("Remove the \"{0}\" Content Part from \"{1}\"", Model.Name, Html.Raw(Model.Type.DisplayName)).Text;
}
@using (Html.BeginFormAntiForgeryPost()) {