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

Commit fa3facc

Browse files
committed
Removed references to the "dtgePreview" querystring
1 parent ccc3ecc commit fa3facc

File tree

4 files changed

+17
-43
lines changed

4 files changed

+17
-43
lines changed

src/Our.Umbraco.DocTypeGridEditor/Bootstrap.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplica
6363
}
6464
}
6565
};
66-
67-
PublishedContentRequest.Prepared += (sender, e) =>
68-
{
69-
// Check if it's a dtgePreview request and is set to redirect.
70-
// If so reset the redirect url to an empty string to stop the redirect happening in preview mode.
71-
if (sender is PublishedContentRequest request && request.Uri.Query.InvariantContains("dtgePreview") && request.IsRedirect)
72-
{
73-
request.SetRedirect(string.Empty);
74-
}
75-
};
7666
}
7767
}
7868
}

src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorSurfaceController.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Web.Mvc;
1+
using System;
2+
using System.Web.Mvc;
23
using Our.Umbraco.DocTypeGridEditor.Extensions;
34
using Umbraco.Core;
45
using Umbraco.Core.Models;
@@ -29,7 +30,7 @@ public string PreviewViewPath
2930

3031
public bool IsPreview
3132
{
32-
get { return Request.QueryString["dtgePreview"] == "1"; }
33+
get { return ControllerContext.RouteData.Values.TryGetValue("dtgePreview", out object value) && Convert.ToBoolean(value); }
3334
}
3435

3536
protected PartialViewResult CurrentPartialView(object model = null)

src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/HtmlHelperExtensions.cs

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,24 @@ public static HtmlString RenderDocTypeGridEditorItem(
3131
if (string.IsNullOrWhiteSpace(previewViewPath) == false)
3232
previewViewPath = previewViewPath.EnsureEndsWith('/');
3333

34+
var routeValues = new
35+
{
36+
dtgeModel = content,
37+
dtgeViewPath = viewPath,
38+
dtgePreviewViewPath = previewViewPath,
39+
dtgePreview = isPreview
40+
};
41+
3442
// Try looking for surface controller with action named after the editor alias
3543
if (string.IsNullOrWhiteSpace(editorAlias) == false && SurfaceControllerHelper.SurfaceControllerExists(controllerName, editorAlias, true))
3644
{
37-
return helper.Action(editorAlias, controllerName, new
38-
{
39-
dtgeModel = content,
40-
dtgeViewPath = viewPath,
41-
dtgePreviewViewPath = previewViewPath
42-
});
45+
return helper.Action(editorAlias, controllerName, routeValues);
4346
}
4447

4548
// Try looking for surface controller with action named after the doc type alias alias
4649
if (SurfaceControllerHelper.SurfaceControllerExists(controllerName, content.DocumentTypeAlias, true))
4750
{
48-
return helper.Action(content.DocumentTypeAlias, controllerName, new
49-
{
50-
dtgeModel = content,
51-
dtgeViewPath = viewPath,
52-
dtgePreviewViewPath = previewViewPath
53-
});
51+
return helper.Action(content.DocumentTypeAlias, controllerName, routeValues);
5452
}
5553

5654
// See if a default surface controller has been registered
@@ -62,32 +60,17 @@ public static HtmlString RenderDocTypeGridEditorItem(
6260
// Try looking for an action named after the editor alias
6361
if (string.IsNullOrWhiteSpace(editorAlias) == false && SurfaceControllerHelper.SurfaceControllerExists(defaultControllerName, editorAlias, true))
6462
{
65-
return helper.Action(editorAlias, defaultControllerName, new
66-
{
67-
dtgeModel = content,
68-
dtgeViewPath = viewPath,
69-
dtgePreviewViewPath = previewViewPath
70-
});
63+
return helper.Action(editorAlias, defaultControllerName, routeValues);
7164
}
7265

7366
// Try looking for a doc type alias action
7467
if (SurfaceControllerHelper.SurfaceControllerExists(defaultControllerName, content.DocumentTypeAlias, true))
7568
{
76-
return helper.Action(content.DocumentTypeAlias, defaultControllerName, new
77-
{
78-
dtgeModel = content,
79-
dtgeViewPath = viewPath,
80-
dtgePreviewViewPath = previewViewPath
81-
});
69+
return helper.Action(content.DocumentTypeAlias, defaultControllerName, routeValues);
8270
}
8371

8472
// Just go with a default action name
85-
return helper.Action("Index", defaultControllerName, new
86-
{
87-
dtgeModel = content,
88-
dtgeViewPath = viewPath,
89-
dtgePreviewViewPath = previewViewPath
90-
});
73+
return helper.Action("Index", defaultControllerName, routeValues);
9174
}
9275

9376
// Check for preview view

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
);
3636
},
3737
getEditorMarkupForDocTypePartial: function (nodeId, id, editorAlias, contentTypeAlias, value, viewPath, previewViewPath, published) {
38-
var url = umbRequestHelper.convertVirtualToAbsolutePath("~/" + (published ? nodeId : "") + "?dtgePreview=1" + (published ? "" : "&nodeId=" + nodeId));
38+
var url = umbRequestHelper.convertVirtualToAbsolutePath("~/umbraco/backoffice/DocTypeGridEditorApi/DocTypeGridEditorApi/GetPreviewMarkup?pageId=" + pageId);
3939
return $http({
4040
method: 'POST',
4141
url: url,

0 commit comments

Comments
 (0)