mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-26 03:40:56 +08:00
[Fixes #7348] Changed the SummaryAdmin view to have the same "New Translation" link as the Editor view (#7513)
Fixes #7348
This commit is contained in:
committed by
Sébastien Ros
parent
3b7ec4cb89
commit
c795cdb871
@@ -51,10 +51,10 @@ namespace Orchard.Localization.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var contentItemTranslation = _contentManager.New<LocalizationPart>(masterContentItem.ContentType);
|
var contentItemTranslation = _contentManager.New<LocalizationPart>(masterContentItem.ContentType);
|
||||||
contentItemTranslation.MasterContentItem = masterContentItem;
|
contentItemTranslation.MasterContentItem = masterLocalizationPart.MasterContentItem == null ? masterContentItem : masterLocalizationPart.MasterContentItem;
|
||||||
|
|
||||||
var content = _contentManager.BuildEditor(contentItemTranslation);
|
var content = _contentManager.BuildEditor(contentItemTranslation);
|
||||||
|
|
||||||
return View(content);
|
return View(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,14 +89,14 @@ namespace Orchard.Localization.Controllers {
|
|||||||
if (existingTranslation != null) {
|
if (existingTranslation != null) {
|
||||||
var existingTranslationMetadata = _contentManager.GetItemMetadata(existingTranslation);
|
var existingTranslationMetadata = _contentManager.GetItemMetadata(existingTranslation);
|
||||||
return RedirectToAction(
|
return RedirectToAction(
|
||||||
Convert.ToString(existingTranslationMetadata.EditorRouteValues["action"]),
|
Convert.ToString(existingTranslationMetadata.EditorRouteValues["action"]),
|
||||||
existingTranslationMetadata.EditorRouteValues);
|
existingTranslationMetadata.EditorRouteValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
var contentItemTranslation = _contentManager
|
var contentItemTranslation = _contentManager
|
||||||
.Create<LocalizationPart>(masterContentItem.ContentType, VersionOptions.Draft, part => {
|
.Create<LocalizationPart>(masterContentItem.ContentType, VersionOptions.Draft, part => {
|
||||||
part.MasterContentItem = masterContentItem;
|
part.MasterContentItem = masterLocalizationPart.MasterContentItem == null ? masterContentItem : masterLocalizationPart.MasterContentItem;
|
||||||
});
|
});
|
||||||
|
|
||||||
var content = _contentManager.UpdateEditor(contentItemTranslation, this);
|
var content = _contentManager.UpdateEditor(contentItemTranslation, this);
|
||||||
|
|
||||||
|
|||||||
@@ -20,35 +20,45 @@ namespace Orchard.Localization.Drivers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Display(LocalizationPart part, string displayType, dynamic shapeHelper) {
|
protected override DriverResult Display(LocalizationPart part, string displayType, dynamic shapeHelper) {
|
||||||
var masterId = part.HasTranslationGroup
|
|
||||||
? part.Record.MasterContentItemId
|
|
||||||
: part.Id;
|
|
||||||
|
|
||||||
return Combined(
|
return Combined(
|
||||||
ContentShape("Parts_Localization_ContentTranslations",
|
ContentShape("Parts_Localization_ContentTranslations",
|
||||||
() => shapeHelper.Parts_Localization_ContentTranslations(Id: part.ContentItem.Id, MasterId: masterId, Culture: GetCulture(part), Localizations: GetDisplayLocalizations(part, VersionOptions.Published))),
|
() => shapeHelper.Parts_Localization_ContentTranslations(Id: part.ContentItem.Id, MasterId: ActualMasterId(part), Culture: GetCulture(part), Localizations: GetDisplayLocalizations(part, VersionOptions.Published))),
|
||||||
ContentShape("Parts_Localization_ContentTranslations_Summary",
|
ContentShape("Parts_Localization_ContentTranslations_Summary",
|
||||||
() => shapeHelper.Parts_Localization_ContentTranslations_Summary(Id: part.ContentItem.Id, MasterId: masterId, Culture: GetCulture(part), Localizations: GetDisplayLocalizations(part, VersionOptions.Published))),
|
() => shapeHelper.Parts_Localization_ContentTranslations_Summary(Id: part.ContentItem.Id, MasterId: ActualMasterId(part), Culture: GetCulture(part), Localizations: GetDisplayLocalizations(part, VersionOptions.Published))),
|
||||||
ContentShape("Parts_Localization_ContentTranslations_SummaryAdmin", () => {
|
ContentShape("Parts_Localization_ContentTranslations_SummaryAdmin", () => {
|
||||||
var siteCultures = _cultureManager.ListCultures();
|
var siteCultures = _cultureManager.ListCultures();
|
||||||
|
|
||||||
return shapeHelper.Parts_Localization_ContentTranslations_SummaryAdmin(Id: part.ContentItem.Id, MasterId: masterId, Culture: GetCulture(part), Localizations: GetDisplayLocalizations(part, VersionOptions.Latest), SiteCultures: siteCultures);
|
return shapeHelper.Parts_Localization_ContentTranslations_SummaryAdmin(Id: part.ContentItem.Id, MasterId: ActualMasterId(part), Culture: GetCulture(part), Localizations: GetDisplayLocalizations(part, VersionOptions.Latest), SiteCultures: siteCultures);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int ActualMasterId(LocalizationPart part) {
|
||||||
|
var masterId = part.HasTranslationGroup
|
||||||
|
? part.Record.MasterContentItemId
|
||||||
|
: part.Id;
|
||||||
|
if (_contentManager.Get(masterId, VersionOptions.Latest) == null) {
|
||||||
|
//the original MasterContentItem has been deleted
|
||||||
|
masterId = part.Id;
|
||||||
|
}
|
||||||
|
return masterId;
|
||||||
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(LocalizationPart part, dynamic shapeHelper) {
|
protected override DriverResult Editor(LocalizationPart part, dynamic shapeHelper) {
|
||||||
var localizations = GetEditorLocalizations(part).ToList();
|
var localizations = GetEditorLocalizations(part).ToList();
|
||||||
|
|
||||||
var missingCultures = part.HasTranslationGroup ?
|
var masterContentItem = _contentManager.Get(part.Record.MasterContentItemId, VersionOptions.Latest);
|
||||||
RetrieveMissingCultures(part.MasterContentItem.As<LocalizationPart>(), true) :
|
|
||||||
|
var missingCultures = part.HasTranslationGroup && masterContentItem != null ?
|
||||||
|
RetrieveMissingCultures(masterContentItem.As<LocalizationPart>(), true) :
|
||||||
RetrieveMissingCultures(part, part.Culture != null);
|
RetrieveMissingCultures(part, part.Culture != null);
|
||||||
|
|
||||||
var model = new EditLocalizationViewModel {
|
var model = new EditLocalizationViewModel {
|
||||||
SelectedCulture = GetCulture(part),
|
SelectedCulture = GetCulture(part),
|
||||||
MissingCultures = missingCultures,
|
MissingCultures = missingCultures,
|
||||||
ContentItem = part,
|
ContentItem = part,
|
||||||
MasterContentItem = part.HasTranslationGroup ? part.MasterContentItem : null,
|
MasterContentItem = masterContentItem,
|
||||||
ContentLocalizations = new ContentLocalizationsViewModel(part) { Localizations = localizations }
|
ContentLocalizations = new ContentLocalizationsViewModel(part) { Localizations = localizations }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -69,7 +79,7 @@ namespace Orchard.Localization.Drivers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<string> RetrieveMissingCultures(LocalizationPart part, bool excludePartCulture) {
|
private List<string> RetrieveMissingCultures(LocalizationPart part, bool excludePartCulture) {
|
||||||
var editorLocalizations = GetEditorLocalizations(part);
|
var editorLocalizations = GetEditorLocalizations(part.MasterContentItem != null ? part.MasterContentItem.As<LocalizationPart>() : part);
|
||||||
|
|
||||||
var cultures = _cultureManager
|
var cultures = _cultureManager
|
||||||
.ListCultures()
|
.ListCultures()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ var localizationLinks = Html.UnorderedList(localizations, (c, i) => Html.ItemEdi
|
|||||||
}
|
}
|
||||||
@if (Model.Culture != null && !((IEnumerable<string>)Model.SiteCultures).All(c => c == Model.Culture || localizations.Any(l => c == l.Culture.Culture)))
|
@if (Model.Culture != null && !((IEnumerable<string>)Model.SiteCultures).All(c => c == Model.Culture || localizations.Any(l => c == l.Culture.Culture)))
|
||||||
{
|
{
|
||||||
<div class="add-localization">@Html.ActionLink(T("+ New translation").Text, "Translate", "Admin", new { area = "Orchard.Localization", id = Model.Id }, null)</div>
|
<div class="add-localization">@Html.ActionLink(T("+ New translation").Text, "Translate", "Admin", new { area = "Orchard.Localization", id = Model.MasterId }, null)</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -22,8 +22,8 @@
|
|||||||
</ToolsOptionsCategory>
|
</ToolsOptionsCategory>
|
||||||
<ToolsOptionsCategory name="TextEditor">
|
<ToolsOptionsCategory name="TextEditor">
|
||||||
<ToolsOptionsSubCategory name="CSharp-Specific">
|
<ToolsOptionsSubCategory name="CSharp-Specific">
|
||||||
<PropertyValue name="AddImport_SuggestForTypesInNuGetPackages">0</PropertyValue>
|
<PropertyValue name="AddImport_SuggestForTypesInNuGetPackages">1</PropertyValue>
|
||||||
<PropertyValue name="AddImport_SuggestForTypesInReferenceAssemblies">0</PropertyValue>
|
<PropertyValue name="AddImport_SuggestForTypesInReferenceAssemblies">1</PropertyValue>
|
||||||
<PropertyValue name="AutoComment">1</PropertyValue>
|
<PropertyValue name="AutoComment">1</PropertyValue>
|
||||||
<PropertyValue name="AutoInsertAsteriskForNewLinesOfBlockComments">1</PropertyValue>
|
<PropertyValue name="AutoInsertAsteriskForNewLinesOfBlockComments">1</PropertyValue>
|
||||||
<PropertyValue name="CSharpClosedFileDiagnostics">-1</PropertyValue>
|
<PropertyValue name="CSharpClosedFileDiagnostics">-1</PropertyValue>
|
||||||
@@ -141,10 +141,10 @@
|
|||||||
<PropertyValue name="EnableExpandPrecedence">false</PropertyValue>
|
<PropertyValue name="EnableExpandPrecedence">false</PropertyValue>
|
||||||
<PropertyValue name="EnableExpandScopes">false</PropertyValue>
|
<PropertyValue name="EnableExpandScopes">false</PropertyValue>
|
||||||
<PropertyValue name="EnableExtractFunction">false</PropertyValue>
|
<PropertyValue name="EnableExtractFunction">false</PropertyValue>
|
||||||
<PropertyValue name="EnableSQLiteStoreEngine">false</PropertyValue>
|
<PropertyValue name="EnableSQLiteStoreEngine">true</PropertyValue>
|
||||||
<PropertyValue name="EnableSingleFileISense">true</PropertyValue>
|
<PropertyValue name="EnableSingleFileISense">true</PropertyValue>
|
||||||
<PropertyValue name="EnableSingleFileISenseSquiggles">false</PropertyValue>
|
<PropertyValue name="EnableSingleFileISenseSquiggles">false</PropertyValue>
|
||||||
<PropertyValue name="EnumerateCommentTasks">false</PropertyValue>
|
<PropertyValue name="EnumerateCommentTasks">true</PropertyValue>
|
||||||
<PropertyValue name="GroupBrackets">true</PropertyValue>
|
<PropertyValue name="GroupBrackets">true</PropertyValue>
|
||||||
<PropertyValue name="HideExperimentalAd">true</PropertyValue>
|
<PropertyValue name="HideExperimentalAd">true</PropertyValue>
|
||||||
<PropertyValue name="HighlightMatchingTokens">true</PropertyValue>
|
<PropertyValue name="HighlightMatchingTokens">true</PropertyValue>
|
||||||
|
|||||||
Reference in New Issue
Block a user