mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-26 20:16:15 +08:00
filterTaxonomyCulture function is now named with a proper unique name, based on part and field (#8702)
* Checked back previously selected terms after replacing the TaxonomyField markup. * Checkbox reset before checking back selected items. * Javascript functions to refresh localized terms are now named to be unique. For this purpose, added PartName property to LocalizedTaxonomiesViewModel. * Code refactoring: added variables for part-field differentiator and function name.
This commit is contained in:
committed by
GitHub
parent
2ef2ad8e99
commit
0485e44378
@@ -35,7 +35,8 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
ContentType = part.ContentItem.ContentType,
|
||||
FieldName = field.Name,
|
||||
Id = part.ContentItem.Id,
|
||||
Setting = taxonomySettings
|
||||
Setting = taxonomySettings,
|
||||
PartName = part.PartDefinition.Name
|
||||
};
|
||||
return shapeHelper.EditorTemplate(TemplateName: templateName, Model: viewModel, Prefix: GetPrefix(field, part));
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Orchard.Taxonomies.ViewModels {
|
||||
public string ContentType { get; set; }
|
||||
public string FieldName { get; set; }
|
||||
public int Id { get; set; }
|
||||
public string PartName { get; set; }
|
||||
public TaxonomyFieldSettings Setting { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,17 +4,24 @@
|
||||
@{
|
||||
Script.Require("jQuery");
|
||||
var Taxonomyprefix = ((ViewData)).TemplateInfo.HtmlFieldPrefix.Replace('.', '_');
|
||||
|
||||
var partField = Model.PartName + "_" + Model.FieldName;
|
||||
var functionName = "filterTaxonomyCulture_" + partField;
|
||||
|
||||
using (Script.Foot()) {
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
$(document).ready(function () {
|
||||
var pageurl = '@Url.Action("GetTaxonomy", "LocalizedTaxonomy", new { area = "Orchard.Taxonomies" })';
|
||||
function filterTaxonomyCulture(culture) {
|
||||
function @(functionName)(culture) {
|
||||
$.ajax({
|
||||
url: pageurl,
|
||||
data: { contentTypeName: '@Model.ContentType', taxonomyFieldName: '@Model.FieldName', contentId: @Model.Id, culture: culture },
|
||||
success: function (html) {
|
||||
var container = $(".taxonomy-wrapper[data-id-prefix='@Taxonomyprefix']");
|
||||
|
||||
$(".taxonomy-wrapper[data-id-prefix='@Taxonomyprefix']").replaceWith(html);
|
||||
|
||||
$(".taxonomy-wrapper[data-id-prefix='@Taxonomyprefix'] legend").expandoControl(function (controller) { return controller.nextAll(".expando"); }, { collapse: true, remember: false });
|
||||
@if (Model.Setting.Autocomplete) {
|
||||
<text>
|
||||
@@ -136,11 +143,19 @@
|
||||
alert("@T("Loading taxonomy fail, Retry")");
|
||||
});
|
||||
}
|
||||
$("#Localization_SelectedCulture").on('change', function () {
|
||||
$("#Localization_SelectedCulture").on('change', function (p) {
|
||||
var optionSelected = $("option:selected", this);
|
||||
filterTaxonomyCulture($("#Localization_SelectedCulture").val());
|
||||
var refreshTerms = false;
|
||||
if (p != undefined) {
|
||||
if (p == "@(partField)") {
|
||||
refreshTerms = true;
|
||||
}
|
||||
}
|
||||
if (refreshTerms) {
|
||||
@(functionName)($("#Localization_SelectedCulture").val());
|
||||
}
|
||||
});
|
||||
$("#Localization_SelectedCulture").trigger("change");
|
||||
$("#Localization_SelectedCulture").trigger("change", "@(partField)");
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user