Fixes: U4-6428 Grid configuration does not support virtual paths - and therefore is not compatible with virtual directories
This commit is contained in:
@@ -6,6 +6,30 @@
|
||||
function umbRequestHelper($http, $q, umbDataFormatter, angularHelper, dialogService, notificationsService) {
|
||||
return {
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.services.umbRequestHelper#convertVirtualToAbsolutePath
|
||||
* @methodOf umbraco.services.umbRequestHelper
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* This will convert a virtual path (i.e. ~/App_Plugins/Blah/Test.html ) to an absolute path
|
||||
*
|
||||
* @param {string} a virtual path, if this is already an absolute path it will just be returned, if this is a relative path an exception will be thrown
|
||||
*/
|
||||
convertVirtualToAbsolutePath: function(virtualPath) {
|
||||
if (virtualPath.startsWith("/")) {
|
||||
return virtualPath;
|
||||
}
|
||||
if (!virtualPath.startsWith("~/")) {
|
||||
throw "The path " + virtualPath + " is not a virtual path";
|
||||
}
|
||||
if (!Umbraco.Sys.ServerVariables.application.applicationPath) {
|
||||
throw "No applicationPath defined in Umbraco.ServerVariables.application.applicationPath";
|
||||
}
|
||||
return Umbraco.Sys.ServerVariables.application.applicationPath + virtualPath.trimStart("~/");
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.services.umbRequestHelper#dictionaryToQueryString
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
angular.module("umbraco")
|
||||
.controller("Umbraco.PropertyEditors.GridController",
|
||||
function ($scope, $http, assetsService, $rootScope, dialogService, gridService, mediaResource, imageHelper, $timeout) {
|
||||
function ($scope, $http, assetsService, $rootScope, dialogService, gridService, mediaResource, imageHelper, $timeout, umbRequestHelper) {
|
||||
|
||||
// Grid status variables
|
||||
$scope.currentRow = null;
|
||||
@@ -576,10 +576,11 @@ angular.module("umbraco")
|
||||
var editorConfig = $scope.getEditor(control.editor.alias);
|
||||
control.editor = editorConfig;
|
||||
|
||||
//if its a path
|
||||
if(_.indexOf(control.editor.view, "/") >= 0){
|
||||
control.$editorPath = control.editor.view;
|
||||
}else{
|
||||
//if its an absolute path
|
||||
if (control.editor.view.startsWith("/") || control.editor.view.startsWith("~/")) {
|
||||
control.$editorPath = umbRequestHelper.convertVirtualToAbsolutePath(control.editor.view);
|
||||
}
|
||||
else {
|
||||
//use convention
|
||||
control.$editorPath = "views/propertyeditors/grid/editors/" + control.editor.view + ".html";
|
||||
}
|
||||
|
||||
@@ -58,6 +58,9 @@
|
||||
"umbracoUrls": {
|
||||
"authenticationApiBaseUrl": "@(Url.GetUmbracoApiServiceBaseUrl<AuthenticationController>(controller => controller.PostLogin(null)))",
|
||||
"serverVarsJs": '@Url.GetUrlWithCacheBust("ServerVariables", "BackOffice")'
|
||||
},
|
||||
"application": {
|
||||
"applicationPath" : "@Context.Request.ApplicationPath"
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -281,15 +281,17 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
},
|
||||
{"isDebuggingEnabled", HttpContext.IsDebuggingEnabled},
|
||||
{
|
||||
"application", GetApplicationState()
|
||||
}
|
||||
{"application", GetApplicationState()}
|
||||
};
|
||||
|
||||
|
||||
return JavaScript(ServerVariablesParser.Parse(d));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the server variables regarding the application state
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Dictionary<string, object> GetApplicationState()
|
||||
{
|
||||
if (ApplicationContext.IsConfigured == false)
|
||||
@@ -306,6 +308,8 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
app.Add("version", version);
|
||||
app.Add("cdf", ClientDependency.Core.Config.ClientDependencySettings.Instance.Version);
|
||||
//useful for dealing with virtual paths on the client side when hosted in virtual directories especially
|
||||
app.Add("applicationPath", HttpContext.Request.ApplicationPath.EnsureEndsWith('/'));
|
||||
return app;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user