mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-02 19:44:02 +08:00
#18472: Fixing sluggish technical names generation
Work Item: 18472 --HG-- branch : 1.x
This commit is contained in:
@@ -90,12 +90,18 @@ namespace Orchard.ContentTypes.Controllers {
|
||||
return RedirectToAction("AddPartsTo", new { id = typeViewModel.Name });
|
||||
}
|
||||
|
||||
public ActionResult ContentTypeName(string displayName) {
|
||||
return Json(_contentDefinitionService.GenerateContentTypeNameFromDisplayName(displayName));
|
||||
public ActionResult ContentTypeName(string displayName, int version) {
|
||||
return Json(new {
|
||||
result = _contentDefinitionService.GenerateContentTypeNameFromDisplayName(displayName),
|
||||
version = version
|
||||
});
|
||||
}
|
||||
|
||||
public ActionResult FieldName(string partName, string displayName) {
|
||||
return Json(_contentDefinitionService.GenerateFieldNameFromDisplayName(partName, displayName));
|
||||
public ActionResult FieldName(string partName, string displayName, int version) {
|
||||
return Json(new {
|
||||
result = _contentDefinitionService.GenerateFieldNameFromDisplayName(partName, displayName),
|
||||
version = version
|
||||
});
|
||||
}
|
||||
|
||||
public ActionResult Edit(string id) {
|
||||
|
||||
@@ -49,10 +49,13 @@
|
||||
$.post(jsonUrl, {
|
||||
partName: partName,
|
||||
displayName: $displayName.val(),
|
||||
version: ++version,
|
||||
__RequestVerificationToken: $("input[name=__RequestVerificationToken]").val()
|
||||
},
|
||||
function(data) {
|
||||
$name.val(data);
|
||||
if(version == data.version) {
|
||||
$name.val(data.result);
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
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() {
|
||||
@@ -37,10 +38,13 @@
|
||||
|
||||
$.post(jsonUrl, {
|
||||
displayName: $displayName.val(),
|
||||
version: ++version,
|
||||
__RequestVerificationToken: $("input[name=__RequestVerificationToken]").val()
|
||||
},
|
||||
function(data) {
|
||||
$name.val(data);
|
||||
if(version == data.version) {
|
||||
$name.val(data.result);
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user