Skip to content
This repository was archived by the owner on Feb 10, 2024. It is now read-only.

Commit 387ef87

Browse files
Added a fix for issue #18 If the current node isn't published, the preview is run in the context of the homepage, but the nodeId is appended onto the querystring, so if you did need some contextual information from the node, you should be able to work it out
1 parent f6955b0 commit 387ef87

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@
5454

5555
$scope.setPreview = function (model) {
5656
if ("enablePreview" in $scope.control.editor.config && $scope.control.editor.config.enablePreview) {
57-
var nodeId = $routeParams.id;
58-
dtgeResources.getEditorMarkupForDocTypePartial(nodeId, model.id, $scope.control.editor.alias, model.dtgeContentTypeAlias, model.value, $scope.control.editor.config.viewPath, $scope.control.editor.config.previewViewPath)
57+
dtgeResources.getEditorMarkupForDocTypePartial(editorState.current.id, model.id,
58+
$scope.control.editor.alias, model.dtgeContentTypeAlias, model.value,
59+
$scope.control.editor.config.viewPath,
60+
$scope.control.editor.config.previewViewPath,
61+
editorState.current.published)
5962
.success(function(htmlResult) {
6063
if (htmlResult.trim().length > 0) {
6164
$scope.preview = htmlResult;

src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.resources.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
'Failed to retrieve datatypes'
3535
);
3636
},
37-
getEditorMarkupForDocTypePartial: function (nodeId, id, editorAlias, contentTypeAlias, value, viewPath, previewViewPath) {
38-
var url = "/" + nodeId +"?dtgePreview=1";
37+
getEditorMarkupForDocTypePartial: function (nodeId, id, editorAlias, contentTypeAlias, value, viewPath, previewViewPath, published) {
38+
var url = "/" + (published ? nodeId : "") + "?dtgePreview=1" + (published ? "" : "&nodeId=" + nodeId);
3939
return $http({
4040
method: 'POST',
4141
url: url,

0 commit comments

Comments
 (0)