diff --git a/appveyor.yml b/appveyor.yml index ba1d391..93b1af4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ image: Visual Studio 2017 # version format -version: 1.2.1.{build} +version: 1.2.2.{build} # UMBRACO_PACKAGE_PRERELEASE_SUFFIX if a rtm release build this should be blank, otherwise if empty will default to alpha # example UMBRACO_PACKAGE_PRERELEASE_SUFFIX=beta diff --git a/src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorApiController.cs b/src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorApiController.cs index 1668a6a..bfa1dc1 100644 --- a/src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorApiController.cs +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorApiController.cs @@ -159,10 +159,10 @@ public HttpResponseMessage GetPreviewMarkup([FromBody] PreviewData data, [FromUr } // Set the culture for the preview - if (page != null) + if (page != null && page.Cultures != null) { - var currentCulture = page.GetCultureFromDomains(); - if (page.Cultures != null && page.Cultures.ContainsKey(currentCulture)) + var currentCulture = string.IsNullOrWhiteSpace(data.Culture) ? page.GetCultureFromDomains() : data.Culture; + if (currentCulture != null && page.Cultures.ContainsKey(currentCulture)) { var culture = new CultureInfo(page.Cultures[currentCulture].Culture); UmbracoContext.PublishedRequest.Culture = culture; diff --git a/src/Our.Umbraco.DocTypeGridEditor/Web/Models/PreviewData.cs b/src/Our.Umbraco.DocTypeGridEditor/Web/Models/PreviewData.cs index 39ad8db..a20101c 100644 --- a/src/Our.Umbraco.DocTypeGridEditor/Web/Models/PreviewData.cs +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/Models/PreviewData.cs @@ -22,5 +22,8 @@ public class PreviewData [DataMember(Name = "viewPath")] public string ViewPath { get; set; } + + [DataMember(Name = "culture")] + public string Culture { get; set; } } } \ No newline at end of file diff --git a/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js index 5133fbb..9cc00da 100644 --- a/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js @@ -151,11 +151,13 @@ $scope.setPreview = function (model) { if ($scope.control.editor.config && "enablePreview" in $scope.control.editor.config && $scope.control.editor.config.enablePreview) { + var activeVariant = editorState.current.variants.find(v => v.active); + var culture = activeVariant ? activeVariant.language.culture : null; dtgeResources.getEditorMarkupForDocTypePartial(editorState.current.id, model.id, $scope.control.editor.alias, model.dtgeContentTypeAlias, model.value, $scope.control.editor.config.viewPath, $scope.control.editor.config.previewViewPath, - !!editorState.current.publishDate) + !!editorState.current.publishDate, culture) .then(function (response) { var htmlResult = response.data; if (htmlResult.trim().length > 0) { @@ -316,6 +318,7 @@ angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.Dialogs.DocT createFromBlueprint(blueprintIds[0]); } else { $scope.dialogMode = "selectBlueprint"; + vm.loading = false; } } else { createBlank(); diff --git a/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.resources.js b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.resources.js index 3f267c6..8277c95 100644 --- a/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.resources.js +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.resources.js @@ -34,7 +34,7 @@ 'Failed to retrieve datatypes' ); }, - getEditorMarkupForDocTypePartial: function (pageId, id, editorAlias, contentTypeAlias, value, viewPath, previewViewPath, published) { + getEditorMarkupForDocTypePartial: function (pageId, id, editorAlias, contentTypeAlias, value, viewPath, previewViewPath, published, culture) { var url = Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + "/backoffice/DocTypeGridEditorApi/DocTypeGridEditorApi/GetPreviewMarkup?dtgePreview=1&pageId=" + pageId; return $http({ method: 'POST', @@ -45,7 +45,8 @@ contentTypeAlias: contentTypeAlias, value: JSON.stringify(value), viewPath: viewPath, - previewViewPath: previewViewPath + previewViewPath: previewViewPath, + culture: culture }), headers: { 'Content-Type': 'application/x-www-form-urlencoded'