From 95f154cc59b4c042dbea88d33c8be196295244ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Wed, 13 Feb 2019 14:58:48 +0100 Subject: [PATCH 01/11] open item in list view as infinity editors --- .../components/content/edit.controller.js | 42 ++++++++----------- .../content/umbvariantcontent.directive.js | 8 +++- .../umbvariantcontenteditors.directive.js | 3 +- .../umbeditorcontentheader.directive.js | 7 +++- .../src/views/components/content/edit.html | 5 ++- .../content/umb-variant-content-editors.html | 3 +- .../content/umb-variant-content.html | 3 +- .../grid/grid.listviewlayout.controller.js | 28 +++++++++++-- .../list/list.listviewlayout.controller.js | 28 +++++++++++-- 9 files changed, 87 insertions(+), 40 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js index b1ce4a266c..704808bc30 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js @@ -4,7 +4,7 @@ function ContentEditController($rootScope, $scope, $routeParams, $q, $window, appState, contentResource, entityResource, navigationService, notificationsService, serverValidationManager, contentEditingHelper, treeService, formHelper, umbRequestHelper, - editorState, $http, eventsService, relationResource, overlayService) { + editorState, $http, eventsService, relationResource, overlayService, $location) { var evts = []; var infiniteMode = $scope.infiniteModel && $scope.infiniteModel.infiniteMode; @@ -22,7 +22,7 @@ $scope.page.isNew = $scope.isNew ? true : false; $scope.page.buttonGroupState = "init"; $scope.page.hideActionsMenu = infiniteMode ? true : false; - $scope.page.hideChangeVariant = infiniteMode ? true : false; + $scope.page.hideChangeVariant = false; $scope.allowOpen = true; $scope.app = null; @@ -213,24 +213,7 @@ $scope.page.showPreviewButton = true; } - - // create infinite editing buttons - function createInfiniteModeButtons(content) { - - $scope.page.allowInfinitePublishAndClose = false; - $scope.page.allowInfiniteSaveAndClose = false; - - // check for publish rights - if (_.contains(content.allowedActions, "U")) { - $scope.page.allowInfinitePublishAndClose = true; - - // check for save rights - } else if (_.contains(content.allowedActions, "A")) { - $scope.page.allowInfiniteSaveAndClose = true; - } - - } - + /** Syncs the content item to it's tree node - this occurs on first load and after saving */ function syncTreeNode(content, path, initialLoad) { @@ -873,11 +856,8 @@ $scope.$broadcast("editors.apps.appChanged", { app: app }); - if (infiniteMode) { - createInfiniteModeButtons($scope.content); - } else { - createButtons($scope.content); - } + createButtons($scope.content); + }; /** @@ -895,6 +875,18 @@ $scope.infiniteModel.close($scope.infiniteModel); } }; + + /** + * Call back when user click the back-icon + */ + $scope.onBack = function() { + if ($scope.infiniteModel && $scope.infiniteModel.close) { + $scope.infiniteModel.close($scope.infiniteModel); + } else { + // navigate backwards if content has a parent. + $location.path('/' + $routeParams.section + '/' + $routeParams.tree + '/' + $routeParams.method + '/' + $scope.content.parentId); + } + }; //ensure to unregister from all events! $scope.$on('$destroy', function () { diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontent.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontent.directive.js index 5556308e06..2021de53f8 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontent.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontent.directive.js @@ -17,7 +17,8 @@ onSelectVariant: "&", onOpenSplitView: "&", onSelectApp: "&", - onSelectAppAnchor: "&" + onSelectAppAnchor: "&", + onBack: "&?" }, controllerAs: 'vm', controller: umbVariantContentController @@ -37,6 +38,7 @@ vm.openSplitView = openSplitView; vm.selectApp = selectApp; vm.selectAppAnchor = selectAppAnchor; + vm.showBackButton = showBackButton; function onInit() { // disable the name field if the active content app is not "Content" @@ -48,6 +50,10 @@ }); } + function showBackButton() { + return vm.page.listViewPath !== null + } + /** Called when the component has linked all elements, this is when the form controller is available */ function postLink() { //set the content to dirty if the header changes diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js index bd21cca541..9f149e5283 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js @@ -11,7 +11,8 @@ content: "<", // TODO: Not sure if this should be = since we are changing the 'active' property of a variant culture: "<", onSelectApp: "&?", - onSelectAppAnchor: "&?" + onSelectAppAnchor: "&?", + onBack: "&?" }, controllerAs: 'vm', controller: umbVariantContentEditorsController diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js index ad20c6bbae..3cc7792518 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js @@ -1,7 +1,7 @@ (function () { 'use strict'; - function EditorContentHeader($location, $routeParams) { + function EditorContentHeader() { function link(scope, el, attr, ctrl) { @@ -38,7 +38,9 @@ } scope.goBack = function () { - $location.path('/' + $routeParams.section + '/' + $routeParams.tree + '/' + $routeParams.method + '/' + scope.menu.currentNode.parentId); + if (scope.onBack) { + scope.onBack(); + } }; scope.selectVariant = function (event, variant) { @@ -121,6 +123,7 @@ onSelectNavigationItem: "&?", onSelectAnchorItem: "&?", showBackButton: " + on-select-app-anchor="appAnchorChanged(app, anchor)" + on-back="onBack()"> @@ -59,7 +60,7 @@ + on-select-app-anchor="vm.selectAppAnchor(app, anchor)" + on-back="vm.onBack()"> diff --git a/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content.html b/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content.html index 34c7792055..94fb7edae8 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content.html @@ -16,7 +16,8 @@ on-select-anchor-item="vm.selectAppAnchor(item, anchor)" open-variants="vm.openVariants" hide-change-variant="vm.page.hideChangeVariant" - show-back-button="vm.page.listViewPath !== null" + show-back-button="vm.showBackButton()" + on-back="vm.onBack()" split-view-open="vm.editorCount > 1" on-open-in-split-view="vm.openSplitView(variant)" on-close-split-view="vm.onCloseSplitView()" diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/layouts/grid/grid.listviewlayout.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/layouts/grid/grid.listviewlayout.controller.js index 9a28627aa1..5c0c90d2e0 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/layouts/grid/grid.listviewlayout.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/layouts/grid/grid.listviewlayout.controller.js @@ -9,7 +9,8 @@ (function () { "use strict"; - function ListViewGridLayoutController($scope, $routeParams, mediaHelper, mediaResource, $location, listViewHelper, mediaTypeHelper) { + function ListViewGridLayoutController($scope, $routeParams, mediaHelper, mediaResource, + listViewHelper, mediaTypeHelper, editorService) { var vm = this; var umbracoSettings = Umbraco.Sys.ServerVariables.umbracoSettings; @@ -116,8 +117,29 @@ listViewHelper.selectHandler(folder, $index, $scope.folders, $scope.selection, $event); } - function goToItem(item, $event, $index) { - $location.path($scope.entityType + '/' + $scope.entityType + '/edit/' + item.id); + function goToItem(node, $event, $index) { + $event.stopPropagation(); + + var contentEditor = { + id: node.id, + submit: function (model) { + // update the node + node.name = model.contentNode.name; + // TODO: node.description = model.contentNode.description; + node.published = model.contentNode.hasPublishedVersion; + if (entityType !== "Member") { + entityResource.getUrl(model.contentNode.id, entityType).then(function (data) { + node.url = data; + }); + } + editorService.close(); + }, + close: function () { + editorService.close(); + } + }; + editorService.contentEditor(contentEditor); + } activate(); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/layouts/list/list.listviewlayout.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/layouts/list/list.listviewlayout.controller.js index 00e6c6edb4..64015b6917 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/layouts/list/list.listviewlayout.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/layouts/list/list.listviewlayout.controller.js @@ -1,7 +1,7 @@ (function () { "use strict"; - function ListViewListLayoutController($scope, listViewHelper, $location, mediaHelper, mediaTypeHelper) { + function ListViewListLayoutController($scope, listViewHelper, mediaHelper, mediaTypeHelper, editorService) { var vm = this; var umbracoSettings = Umbraco.Sys.ServerVariables.umbracoSettings; @@ -52,11 +52,31 @@ listViewHelper.selectHandler(selectedItem, $index, $scope.items, $scope.selection, $event); } - function clickItem(item) { - // if item.id is 2147483647 (int.MaxValue) use item.key - $location.path($scope.entityType + '/' + $scope.entityType + '/edit/' + (item.id === 2147483647 ? item.key : item.id)); + function clickItem(node) { + + var contentEditor = { + id: node.id, + submit: function (model) { + // update the node + node.name = model.contentNode.name; + // TODO: node.description = model.contentNode.description; + node.published = model.contentNode.hasPublishedVersion; + if (entityType !== "Member") { + entityResource.getUrl(model.contentNode.id, entityType).then(function (data) { + node.url = data; + }); + } + editorService.close(); + }, + close: function () { + editorService.close(); + } + }; + editorService.contentEditor(contentEditor); + } + function isSortDirection(col, direction) { return listViewHelper.setSortingDirection(col, direction, $scope.options); } From 2001487c1e84e867c1fe31c9d96c55d62fe270ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Wed, 13 Feb 2019 16:16:41 +0100 Subject: [PATCH 02/11] Dont show back button in infinity mode --- .../components/content/umbvariantcontent.directive.js | 5 +++-- .../components/content/umbvariantcontenteditors.directive.js | 3 ++- .../components/editor/umbeditorcontentheader.directive.js | 2 +- .../components/editor/umbeditorheader.directive.js | 2 +- .../src/views/components/content/edit.html | 4 +++- .../components/content/umb-variant-content-editors.html | 3 ++- .../views/components/editor/umb-editor-content-header.html | 2 +- .../src/views/components/editor/umb-editor-header.html | 2 +- 8 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontent.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontent.directive.js index 2021de53f8..effa21e581 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontent.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontent.directive.js @@ -18,7 +18,8 @@ onOpenSplitView: "&", onSelectApp: "&", onSelectAppAnchor: "&", - onBack: "&?" + onBack: "&?", + showBack: " + on-back="onBack()" + show-back="!(infiniteModel && infiniteModel.infiniteMode)" + > diff --git a/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content-editors.html b/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content-editors.html index 75ce2a09b5..0e9e7d8eab 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content-editors.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content-editors.html @@ -15,7 +15,8 @@ on-select-variant="vm.selectVariant(variant, $index)" on-select-app="vm.selectApp(app)" on-select-app-anchor="vm.selectAppAnchor(app, anchor)" - on-back="vm.onBack()"> + on-back="vm.onBack()" + show-back="vm.showBack"> diff --git a/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-content-header.html b/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-content-header.html index 98ecfd4d28..315704318e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-content-header.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-content-header.html @@ -69,7 +69,7 @@ -
+
-
+
Date: Thu, 14 Feb 2019 15:48:39 +0100 Subject: [PATCH 03/11] Removed console.log --- .../components/editor/umbeditorcontentheader.directive.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js index 290b6601e2..4999f7007a 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js @@ -22,7 +22,6 @@ angular.forEach(scope.content.apps, (app) => { if (app.alias === "umbContent") { - console.log("app: ", app) app.anchors = scope.content.tabs; } }); From 9292254aa873e58eabd209109ed585d8f95a1a59 Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 15 Feb 2019 14:20:42 +1100 Subject: [PATCH 04/11] Fixes umbeditornavigation.directive which doesn't listen for any changes to the navigation collection which means it can't dynamically resize or show/hide the items --- .../editor/umbeditornavigation.directive.js | 21 ++++++++----------- src/Umbraco.Web.UI.Client/src/routes.js | 2 ++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditornavigation.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditornavigation.directive.js index 31976118fd..eec8455969 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditornavigation.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditornavigation.directive.js @@ -46,18 +46,15 @@ }; function onInit() { - - // hide navigation if there is only 1 item - if (scope.navigation.length <= 1) { - scope.showNavigation = false; - } - - $timeout(function(){ - if($window && $window.innerWidth) { - calculateVisibleItems($window.innerWidth); - } - }); - + var firstRun = true; + scope.$watch("navigation.length", + (newVal, oldVal) => { + if (firstRun || newVal !== undefined && newVal !== oldVal) { + firstRun = false; + scope.showNavigation = newVal > 1; + calculateVisibleItems($window.innerWidth); + } + }); } function calculateVisibleItems(windowWidth) { diff --git a/src/Umbraco.Web.UI.Client/src/routes.js b/src/Umbraco.Web.UI.Client/src/routes.js index ecb011e3f0..001888f3ca 100644 --- a/src/Umbraco.Web.UI.Client/src/routes.js +++ b/src/Umbraco.Web.UI.Client/src/routes.js @@ -157,6 +157,7 @@ app.config(function ($routeProvider) { return; } + //TODO: Fix this special case by using components, the packager should be a component and then we just have a view for each route like normal rendering the component with the correct parameters //special case for the package section var packagePages = ["edit", "options"]; if ($routeParams.section.toLowerCase() === "packages" && $routeParams.tree.toLowerCase() === "packages" && packagePages.indexOf($routeParams.method.toLowerCase()) === -1) { @@ -164,6 +165,7 @@ app.config(function ($routeProvider) { return; } + //TODO: Fix this special case by using components, the users section should be a component and then we just have a view for each route like normal rendering the component with the correct parameters //special case for the users section var usersPages = ["user", "group"]; if ($routeParams.section.toLowerCase() === "users" && $routeParams.tree.toLowerCase() === "users" && usersPages.indexOf($routeParams.method.toLowerCase()) === -1) { From a46d40e9ef3c782ddd5a339a7b32bf34f9b8b54b Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 15 Feb 2019 10:31:45 +0100 Subject: [PATCH 05/11] Fix UmbracoContext issue (with a TODO) --- .../PublishedCache/DefaultCultureAccessor.cs | 12 ++++++++---- src/Umbraco.Web/UmbracoInjectedModule.cs | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web/PublishedCache/DefaultCultureAccessor.cs b/src/Umbraco.Web/PublishedCache/DefaultCultureAccessor.cs index 80d2d9f3a5..ef6a6dd8da 100644 --- a/src/Umbraco.Web/PublishedCache/DefaultCultureAccessor.cs +++ b/src/Umbraco.Web/PublishedCache/DefaultCultureAccessor.cs @@ -1,4 +1,5 @@ -using Umbraco.Core.Services; +using Umbraco.Core; +using Umbraco.Core.Services; namespace Umbraco.Web.PublishedCache { @@ -8,17 +9,20 @@ namespace Umbraco.Web.PublishedCache public class DefaultCultureAccessor : IDefaultCultureAccessor { private readonly ILocalizationService _localizationService; + private readonly RuntimeLevel _runtimeLevel; /// /// Initializes a new instance of the class. /// - /// - public DefaultCultureAccessor(ILocalizationService localizationService) + public DefaultCultureAccessor(ILocalizationService localizationService, IRuntimeState runtimeState) { _localizationService = localizationService; + _runtimeLevel = runtimeState.Level; } /// - public string DefaultCulture => _localizationService.GetDefaultLanguageIsoCode() ?? ""; // fast + public string DefaultCulture => _runtimeLevel == RuntimeLevel.Run + ? _localizationService.GetDefaultLanguageIsoCode() ?? "" // fast + : "en-US"; // default for install and upgrade, when the service is n/a } } diff --git a/src/Umbraco.Web/UmbracoInjectedModule.cs b/src/Umbraco.Web/UmbracoInjectedModule.cs index 14ae45fe40..6a786ed6bf 100644 --- a/src/Umbraco.Web/UmbracoInjectedModule.cs +++ b/src/Umbraco.Web/UmbracoInjectedModule.cs @@ -95,6 +95,7 @@ namespace Umbraco.Web // ok, process + // TODO: should we move this to after we've ensured we are processing a routable page? // ensure there's an UmbracoContext registered for the current request // registers the context reference so its disposed at end of request var umbracoContextReference = _umbracoContextFactory.EnsureUmbracoContext(httpContext); From 6f0ba2236ff642308ba9b9d1db22b71d1b44f2bd Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 15 Feb 2019 10:32:00 +0100 Subject: [PATCH 06/11] Fix IGlobalSettings.LocalTempPath in tests --- src/Umbraco.Core/Configuration/GlobalSettings.cs | 1 - src/Umbraco.Tests/TestHelpers/SettingsForTests.cs | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Configuration/GlobalSettings.cs b/src/Umbraco.Core/Configuration/GlobalSettings.cs index 1fd770607c..09962fab5a 100644 --- a/src/Umbraco.Core/Configuration/GlobalSettings.cs +++ b/src/Umbraco.Core/Configuration/GlobalSettings.cs @@ -293,7 +293,6 @@ namespace Umbraco.Core.Configuration case LocalTempStorage.AspNetTemp: return System.IO.Path.Combine(HttpRuntime.CodegenDir, "UmbracoData"); case LocalTempStorage.EnvironmentTemp: - // TODO: why has this to be repeated everywhere?! // include the appdomain hash is just a safety check, for example if a website is moved from worker A to worker B and then back // to worker A again, in theory the %temp% folder should already be empty but we really want to make sure that its not // utilizing an old path - assuming we cannot have SHA1 collisions on AppDomainAppId diff --git a/src/Umbraco.Tests/TestHelpers/SettingsForTests.cs b/src/Umbraco.Tests/TestHelpers/SettingsForTests.cs index 97fffe11dd..572d572ab7 100644 --- a/src/Umbraco.Tests/TestHelpers/SettingsForTests.cs +++ b/src/Umbraco.Tests/TestHelpers/SettingsForTests.cs @@ -21,6 +21,7 @@ namespace Umbraco.Tests.TestHelpers settings.TimeOutInMinutes == 20 && settings.DefaultUILanguage == "en" && settings.LocalTempStorageLocation == LocalTempStorage.Default && + settings.LocalTempPath == IOHelper.MapPath("~/App_Data/TEMP") && settings.ReservedPaths == (GlobalSettings.StaticReservedPaths + "~/umbraco") && settings.ReservedUrls == GlobalSettings.StaticReservedUrls); return config; From e29b47069c3b8b96e5935d14ee8b6e07090ad10b Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 15 Feb 2019 10:54:00 +0100 Subject: [PATCH 07/11] Show save and publish in infinite mode --- .../src/views/components/content/edit.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/components/content/edit.html b/src/Umbraco.Web.UI.Client/src/views/components/content/edit.html index e9db56ec1f..cd2c94c458 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/content/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/content/edit.html @@ -62,7 +62,7 @@ Date: Fri, 15 Feb 2019 11:03:38 +0100 Subject: [PATCH 08/11] Bugfix for checkboxlist --- .../propertyeditors/checkboxlist/checkboxlist.controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/checkboxlist/checkboxlist.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/checkboxlist/checkboxlist.controller.js index 1e679eb5ae..5e7eff0d1e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/checkboxlist/checkboxlist.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/checkboxlist/checkboxlist.controller.js @@ -66,13 +66,13 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.CheckboxListContro function changed(item) { var index = _.findIndex($scope.model.value, function (v) { - return v === item.value; + return v === item.val; }); if (item.checked) { //if it doesn't exist in the model, then add it if (index < 0) { - $scope.model.value.push(item.value); + $scope.model.value.push(item.val); } } else { From 8e29dbd49493c9791b18fb818b60939832e370a6 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Fri, 15 Feb 2019 11:42:29 +0100 Subject: [PATCH 09/11] #4569 - Rename TinyMCE property editor alias (From TinyMCEv3) #379 - Rename Label property editor alias (From NoEdit) --- src/Umbraco.Core/Constants-Conventions.cs | 12 +++--- src/Umbraco.Core/Constants-PropertyEditors.cs | 12 +++--- .../Migrations/Install/DatabaseDataCreator.cs | 12 +++--- .../Migrations/Upgrade/UmbracoPlan.cs | 2 + .../Upgrade/V_8_0_0/AddTypedLabels.cs | 2 +- ...meLabelAndRichTextPropertyEditorAliases.cs | 41 +++++++++++++++++++ .../Packaging/PackageDataInstallation.cs | 2 +- .../PropertyEditors/LabelPropertyEditor.cs | 2 +- .../ValueConverters/LabelValueConverter.cs | 2 +- .../Services/Implement/MemberService.cs | 6 +-- src/Umbraco.Core/Umbraco.Core.csproj | 1 + .../DataTypeDefinitionRepositoryTest.cs | 2 +- .../CompositionsTestPackage-Random.xml | 4 +- .../Importing/CompositionsTestPackage.xml | 38 ++++++++--------- .../Entities/MockedContentTypes.cs | 10 ++--- src/Umbraco.Web/Editors/DataTypeController.cs | 2 +- .../Mapping/ContentPropertyBasicConverter.cs | 2 +- .../MemberTabsAndPropertiesResolver.cs | 2 +- .../Mapping/PropertyTypeGroupResolver.cs | 2 +- 19 files changed, 100 insertions(+), 56 deletions(-) create mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RenameLabelAndRichTextPropertyEditorAliases.cs diff --git a/src/Umbraco.Core/Constants-Conventions.cs b/src/Umbraco.Core/Constants-Conventions.cs index b3281e8967..d49244d9f9 100644 --- a/src/Umbraco.Core/Constants-Conventions.cs +++ b/src/Umbraco.Core/Constants-Conventions.cs @@ -219,7 +219,7 @@ namespace Umbraco.Core }, { FailedPasswordAttempts, - new PropertyType(PropertyEditors.Aliases.NoEdit, ValueStorageType.Integer, true, FailedPasswordAttempts) + new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Integer, true, FailedPasswordAttempts) { Name = FailedPasswordAttemptsLabel } @@ -240,35 +240,35 @@ namespace Umbraco.Core }, { LastLockoutDate, - new PropertyType(PropertyEditors.Aliases.NoEdit, ValueStorageType.Date, true, LastLockoutDate) + new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Date, true, LastLockoutDate) { Name = LastLockoutDateLabel } }, { LastLoginDate, - new PropertyType(PropertyEditors.Aliases.NoEdit, ValueStorageType.Date, true, LastLoginDate) + new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Date, true, LastLoginDate) { Name = LastLoginDateLabel } }, { LastPasswordChangeDate, - new PropertyType(PropertyEditors.Aliases.NoEdit, ValueStorageType.Date, true, LastPasswordChangeDate) + new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Date, true, LastPasswordChangeDate) { Name = LastPasswordChangeDateLabel } }, { PasswordAnswer, - new PropertyType(PropertyEditors.Aliases.NoEdit, ValueStorageType.Nvarchar, true, PasswordAnswer) + new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Nvarchar, true, PasswordAnswer) { Name = PasswordAnswerLabel } }, { PasswordQuestion, - new PropertyType(PropertyEditors.Aliases.NoEdit, ValueStorageType.Nvarchar, true, PasswordQuestion) + new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Nvarchar, true, PasswordQuestion) { Name = PasswordQuestionLabel } diff --git a/src/Umbraco.Core/Constants-PropertyEditors.cs b/src/Umbraco.Core/Constants-PropertyEditors.cs index 8b637fe90e..5c1f4e2c83 100644 --- a/src/Umbraco.Core/Constants-PropertyEditors.cs +++ b/src/Umbraco.Core/Constants-PropertyEditors.cs @@ -48,7 +48,7 @@ namespace Umbraco.Core /// DropDown List. /// public const string DropDownListFlexible = "Umbraco.DropDown.Flexible"; - + /// /// Grid. /// @@ -105,9 +105,9 @@ namespace Umbraco.Core public const string MultipleTextstring = "Umbraco.MultipleTextstring"; /// - /// NoEdit. + /// Label. /// - public const string NoEdit = "Umbraco.NoEdit"; + public const string Label = "Umbraco.Label"; /// /// Picker Relations. @@ -118,7 +118,7 @@ namespace Umbraco.Core /// RadioButton list. /// public const string RadioButtonList = "Umbraco.RadioButtonList"; - + /// /// Slider. /// @@ -142,7 +142,7 @@ namespace Umbraco.Core /// /// TinyMCE /// - public const string TinyMce = "Umbraco.TinyMCEv3"; + public const string TinyMce = "Umbraco.TinyMCE"; /// /// Boolean. @@ -163,7 +163,7 @@ namespace Umbraco.Core /// Upload Field. /// public const string UploadField = "Umbraco.UploadField"; - + /// /// Email Address. /// diff --git a/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs b/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs index 1fefcf85d9..d67680d98a 100644 --- a/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs +++ b/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs @@ -271,12 +271,12 @@ namespace Umbraco.Core.Migrations.Install _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -88, EditorAlias = Constants.PropertyEditors.Aliases.TextBox, DbType = "Nvarchar" }); _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -89, EditorAlias = Constants.PropertyEditors.Aliases.TextArea, DbType = "Ntext" }); _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -90, EditorAlias = Constants.PropertyEditors.Aliases.UploadField, DbType = "Nvarchar" }); - InsertDataTypeDto(Constants.DataTypes.LabelString, Constants.PropertyEditors.Aliases.NoEdit, "Nvarchar", "{\"umbracoDataValueType\":\"STRING\"}"); - InsertDataTypeDto(Constants.DataTypes.LabelInt, Constants.PropertyEditors.Aliases.NoEdit, "Integer", "{\"umbracoDataValueType\":\"INT\"}"); - InsertDataTypeDto(Constants.DataTypes.LabelBigint, Constants.PropertyEditors.Aliases.NoEdit, "Nvarchar", "{\"umbracoDataValueType\":\"BIGINT\"}"); - InsertDataTypeDto(Constants.DataTypes.LabelDateTime, Constants.PropertyEditors.Aliases.NoEdit, "Date", "{\"umbracoDataValueType\":\"DATETIME\"}"); - InsertDataTypeDto(Constants.DataTypes.LabelDecimal, Constants.PropertyEditors.Aliases.NoEdit, "Decimal", "{\"umbracoDataValueType\":\"DECIMAL\"}"); - InsertDataTypeDto(Constants.DataTypes.LabelTime, Constants.PropertyEditors.Aliases.NoEdit, "Date", "{\"umbracoDataValueType\":\"TIME\"}"); + InsertDataTypeDto(Constants.DataTypes.LabelString, Constants.PropertyEditors.Aliases.Label, "Nvarchar", "{\"umbracoDataValueType\":\"STRING\"}"); + InsertDataTypeDto(Constants.DataTypes.LabelInt, Constants.PropertyEditors.Aliases.Label, "Integer", "{\"umbracoDataValueType\":\"INT\"}"); + InsertDataTypeDto(Constants.DataTypes.LabelBigint, Constants.PropertyEditors.Aliases.Label, "Nvarchar", "{\"umbracoDataValueType\":\"BIGINT\"}"); + InsertDataTypeDto(Constants.DataTypes.LabelDateTime, Constants.PropertyEditors.Aliases.Label, "Date", "{\"umbracoDataValueType\":\"DATETIME\"}"); + InsertDataTypeDto(Constants.DataTypes.LabelDecimal, Constants.PropertyEditors.Aliases.Label, "Decimal", "{\"umbracoDataValueType\":\"DECIMAL\"}"); + InsertDataTypeDto(Constants.DataTypes.LabelTime, Constants.PropertyEditors.Aliases.Label, "Date", "{\"umbracoDataValueType\":\"TIME\"}"); _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -36, EditorAlias = Constants.PropertyEditors.Aliases.DateTime, DbType = "Date" }); _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -37, EditorAlias = Constants.PropertyEditors.Aliases.ColorPicker, DbType = "Nvarchar" }); InsertDataTypeDto(Constants.DataTypes.DropDownSingle, Constants.PropertyEditors.Aliases.DropDownListFlexible, "Nvarchar", "{\"multiple\":false}"); diff --git a/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs b/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs index 4fa687fa5d..a27db08881 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs @@ -135,6 +135,8 @@ namespace Umbraco.Core.Migrations.Upgrade .To("{940FD19A-00A8-4D5C-B8FF-939143585726}") .As("{0576E786-5C30-4000-B969-302B61E90CA3}"); + To("{E0CBE54D-A84F-4A8F-9B13-900945FD7ED9}"); + //FINAL diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddTypedLabels.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddTypedLabels.cs index cb8a58f3e3..2f20f01728 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddTypedLabels.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddTypedLabels.cs @@ -53,7 +53,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0 var dataTypeDto = new DataTypeDto { NodeId = id, - EditorAlias = Constants.PropertyEditors.Aliases.NoEdit, + EditorAlias = Constants.PropertyEditors.Aliases.Label, DbType = dbType }; diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RenameLabelAndRichTextPropertyEditorAliases.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RenameLabelAndRichTextPropertyEditorAliases.cs new file mode 100644 index 0000000000..1252a26e68 --- /dev/null +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RenameLabelAndRichTextPropertyEditorAliases.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using Umbraco.Core.Persistence; +using Umbraco.Core.Persistence.Dtos; + +namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0 +{ + public class RenameLabelAndRichTextPropertyEditorAliases : MigrationBase + { + public RenameLabelAndRichTextPropertyEditorAliases(IMigrationContext context) + : base(context) + { + } + + public override void Migrate() + { + MigratePropertyEditorAlias("Umbraco.TinyMCEv3", Constants.PropertyEditors.Aliases.TinyMce); + MigratePropertyEditorAlias("Umbraco.NoEdit", Constants.PropertyEditors.Aliases.Label); + } + + private void MigratePropertyEditorAlias(string oldAlias, string newAlias) + { + var dataTypes = GetDataTypes(oldAlias); + + foreach (var dataType in dataTypes) + { + dataType.EditorAlias = newAlias; + Database.Update(dataType); + } + } + + private List GetDataTypes(string editorAlias) + { + var dataTypes = Database.Fetch(Sql() + .Select() + .From() + .Where(x => x.EditorAlias == editorAlias)); + return dataTypes; + } + + } +} diff --git a/src/Umbraco.Core/Packaging/PackageDataInstallation.cs b/src/Umbraco.Core/Packaging/PackageDataInstallation.cs index 963ab7050f..c811f484bc 100644 --- a/src/Umbraco.Core/Packaging/PackageDataInstallation.cs +++ b/src/Umbraco.Core/Packaging/PackageDataInstallation.cs @@ -735,7 +735,7 @@ namespace Umbraco.Core.Packaging property.Element("Name").Value, dataTypeDefinitionId, property.Element("Type").Value.Trim()); //convert to a label! - dataTypeDefinition = _dataTypeService.GetByEditorAlias(Constants.PropertyEditors.Aliases.NoEdit).FirstOrDefault(); + dataTypeDefinition = _dataTypeService.GetByEditorAlias(Constants.PropertyEditors.Aliases.Label).FirstOrDefault(); //if for some odd reason this isn't there then ignore if (dataTypeDefinition == null) continue; } diff --git a/src/Umbraco.Core/PropertyEditors/LabelPropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/LabelPropertyEditor.cs index 2b8a207491..d0c40b1e63 100644 --- a/src/Umbraco.Core/PropertyEditors/LabelPropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/LabelPropertyEditor.cs @@ -5,7 +5,7 @@ namespace Umbraco.Core.PropertyEditors /// /// Represents a property editor for label properties. /// - [DataEditor(Constants.PropertyEditors.Aliases.NoEdit, "Label", "readonlyvalue", Icon = "icon-readonly")] + [DataEditor(Constants.PropertyEditors.Aliases.Label, "Label", "readonlyvalue", Icon = "icon-readonly")] public class LabelPropertyEditor : DataEditor { /// diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs index 1be37e9c94..05a5f15aaf 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs @@ -17,7 +17,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class LabelValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => Constants.PropertyEditors.Aliases.NoEdit.Equals(propertyType.EditorAlias); + => Constants.PropertyEditors.Aliases.Label.Equals(propertyType.EditorAlias); public override Type GetPropertyValueType(PublishedPropertyType propertyType) { diff --git a/src/Umbraco.Core/Services/Implement/MemberService.cs b/src/Umbraco.Core/Services/Implement/MemberService.cs index 3b35896769..5ce824de16 100644 --- a/src/Umbraco.Core/Services/Implement/MemberService.cs +++ b/src/Umbraco.Core/Services/Implement/MemberService.cs @@ -1212,21 +1212,21 @@ namespace Umbraco.Core.Services.Implement Id = --identity, Key = identity.ToGuid() }); - propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, ValueStorageType.Date, Constants.Conventions.Member.LastLockoutDate) + propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.Aliases.Label, ValueStorageType.Date, Constants.Conventions.Member.LastLockoutDate) { Name = Constants.Conventions.Member.LastLockoutDateLabel, SortOrder = 5, Id = --identity, Key = identity.ToGuid() }); - propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, ValueStorageType.Date, Constants.Conventions.Member.LastLoginDate) + propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.Aliases.Label, ValueStorageType.Date, Constants.Conventions.Member.LastLoginDate) { Name = Constants.Conventions.Member.LastLoginDateLabel, SortOrder = 6, Id = --identity, Key = identity.ToGuid() }); - propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, ValueStorageType.Date, Constants.Conventions.Member.LastPasswordChangeDate) + propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.Aliases.Label, ValueStorageType.Date, Constants.Conventions.Member.LastPasswordChangeDate) { Name = Constants.Conventions.Member.LastPasswordChangeDateLabel, SortOrder = 7, diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 29bc0ef62d..247fed0a5e 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -205,6 +205,7 @@ + diff --git a/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs index 2d999f00cd..b558ce6c87 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs @@ -344,7 +344,7 @@ namespace Umbraco.Tests.Persistence.Repositories // Assert Assert.That(definitionUpdated, Is.Not.Null); Assert.That(definitionUpdated.Name, Is.EqualTo("AgeDataType Updated")); - Assert.That(definitionUpdated.EditorAlias, Is.EqualTo(Constants.PropertyEditors.Aliases.NoEdit)); + Assert.That(definitionUpdated.EditorAlias, Is.EqualTo(Constants.PropertyEditors.Aliases.Label)); } } diff --git a/src/Umbraco.Tests/Services/Importing/CompositionsTestPackage-Random.xml b/src/Umbraco.Tests/Services/Importing/CompositionsTestPackage-Random.xml index 517db639a0..2ec534334f 100644 --- a/src/Umbraco.Tests/Services/Importing/CompositionsTestPackage-Random.xml +++ b/src/Umbraco.Tests/Services/Importing/CompositionsTestPackage-Random.xml @@ -71,7 +71,7 @@ Content content - Umbraco.TinyMCEv3 + Umbraco.TinyMCE ca90c950-0aff-4e72-b976-a30b1ac57dad Content False @@ -172,4 +172,4 @@ - \ No newline at end of file + diff --git a/src/Umbraco.Tests/Services/Importing/CompositionsTestPackage.xml b/src/Umbraco.Tests/Services/Importing/CompositionsTestPackage.xml index f6b4e2c160..39a7f102a5 100644 --- a/src/Umbraco.Tests/Services/Importing/CompositionsTestPackage.xml +++ b/src/Umbraco.Tests/Services/Importing/CompositionsTestPackage.xml @@ -324,7 +324,7 @@ AboutText aboutText - Umbraco.TinyMCEv3 + Umbraco.TinyMCE ca90c950-0aff-4e72-b976-a30b1ac57dad About False @@ -472,7 +472,7 @@ Content bodyText - Umbraco.TinyMCEv3 + Umbraco.TinyMCE ca90c950-0aff-4e72-b976-a30b1ac57dad Content False @@ -593,7 +593,7 @@ Content bodyText - Umbraco.TinyMCEv3 + Umbraco.TinyMCE ca90c950-0aff-4e72-b976-a30b1ac57dad Content False @@ -721,8 +721,8 @@ +
@@ -777,7 +777,7 @@ @{ Layout = "umbLayout.cshtml"; - // If the editor has not explicitly provided the "Page title" property page + // If the editor has not explicitly provided the "Page title" property page // then just show the name of the page otherwise show the provided title var pageTitle = string.IsNullOrWhiteSpace(CurrentPage.Title) ? CurrentPage.Name @@ -787,8 +787,8 @@ // AncestorsOrSelf is all of the ancestors this page has in the tree // (1) means: go up to level 1 and stop looking for more ancestors when you get there // First() gets the first ancestor found (the home page, on level 1) - var homePage = CurrentPage.AncestorsOrSelf(1).First(); - + var homePage = CurrentPage.AncestorsOrSelf(1).First(); + // Find all pages with document type alias umbNewsOverview // We do that using the plural, umbNewsOverviews (note the extra "s" in the end) // Then take the first one, as we know there will only be on news overview page @@ -815,18 +815,18 @@ @foreach (var item in newsItems) { - // If the editor has not explicitly provided the "Page title" property page + // If the editor has not explicitly provided the "Page title" property page // then just show the name of the page otherwise show the provided title - var title = string.IsNullOrWhiteSpace(item.Title) - ? item.Name + var title = string.IsNullOrWhiteSpace(item.Title) + ? item.Name : item.Title; // If the editor has not explicitly set the publishDate property then show the create date - var dateTime = item.PublishDate == default(DateTime) - ? item.CreateDate + var dateTime = item.PublishDate == default(DateTime) + ? item.CreateDate : item.PublishDate; - +

@title

@@ -869,11 +869,11 @@ @{ Layout = "umbLayout.cshtml"; - // If the editor has not explicitly provided the "Page title" property page + // If the editor has not explicitly provided the "Page title" property page // then just show the name of the page otherwise show the provided title var pageTitle = string.IsNullOrWhiteSpace(CurrentPage.Title) ? CurrentPage.Name - : CurrentPage.Title; + : CurrentPage.Title; }
@@ -892,7 +892,7 @@ } @CurrentPage.BodyText -
+
@@ -921,4 +921,4 @@ - \ No newline at end of file + diff --git a/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs b/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs index d7dcf8e79a..6de467f32f 100644 --- a/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs +++ b/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs @@ -359,7 +359,7 @@ namespace Umbraco.Tests.TestHelpers.Entities contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.TextBox, ValueStorageType.Nvarchar) { Alias = "singleLineText", Name = "Text String", Mandatory = false, SortOrder = 4, DataTypeId = -88 }); contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.TextArea, ValueStorageType.Ntext) { Alias = "multilineText", Name = "Multiple Text Strings", Mandatory = false, SortOrder = 5, DataTypeId = -89 }); contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.UploadField, ValueStorageType.Nvarchar) { Alias = "upload", Name = "Upload Field", Mandatory = false, SortOrder = 6, DataTypeId = -90 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, ValueStorageType.Nvarchar) { Alias = "label", Name = "Label", Mandatory = false, SortOrder = 7, DataTypeId = -92 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Label, ValueStorageType.Nvarchar) { Alias = "label", Name = "Label", Mandatory = false, SortOrder = 7, DataTypeId = -92 }); contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.DateTime, ValueStorageType.Date) { Alias = "dateTime", Name = "Date Time", Mandatory = false, SortOrder = 8, DataTypeId = -36 }); contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.ColorPicker, ValueStorageType.Nvarchar) { Alias = "colorPicker", Name = "Color Picker", Mandatory = false, SortOrder = 9, DataTypeId = -37 }); contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.DropDownListFlexible, ValueStorageType.Nvarchar) { Alias = "ddlMultiple", Name = "Dropdown List Multiple", Mandatory = false, SortOrder = 11, DataTypeId = -39 }); @@ -420,10 +420,10 @@ namespace Umbraco.Tests.TestHelpers.Entities var contentCollection = new PropertyTypeCollection(false); contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.UploadField, ValueStorageType.Nvarchar) { Alias = Constants.Conventions.Media.File, Name = "File", Description = "", Mandatory = false, SortOrder = 1, DataTypeId = -90 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, ValueStorageType.Integer) { Alias = Constants.Conventions.Media.Width, Name = "Width", Description = "", Mandatory = false, SortOrder = 2, DataTypeId = -90 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, ValueStorageType.Integer) { Alias = Constants.Conventions.Media.Height, Name = "Height", Description = "", Mandatory = false, SortOrder = 2, DataTypeId = -90 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, ValueStorageType.Integer) { Alias = Constants.Conventions.Media.Bytes, Name = "Bytes", Description = "", Mandatory = false, SortOrder = 2, DataTypeId = -90 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, ValueStorageType.Nvarchar) { Alias = Constants.Conventions.Media.Extension, Name = "File Extension", Description = "", Mandatory = false, SortOrder = 2, DataTypeId = -90 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Label, ValueStorageType.Integer) { Alias = Constants.Conventions.Media.Width, Name = "Width", Description = "", Mandatory = false, SortOrder = 2, DataTypeId = -90 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Label, ValueStorageType.Integer) { Alias = Constants.Conventions.Media.Height, Name = "Height", Description = "", Mandatory = false, SortOrder = 2, DataTypeId = -90 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Label, ValueStorageType.Integer) { Alias = Constants.Conventions.Media.Bytes, Name = "Bytes", Description = "", Mandatory = false, SortOrder = 2, DataTypeId = -90 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Label, ValueStorageType.Nvarchar) { Alias = Constants.Conventions.Media.Extension, Name = "File Extension", Description = "", Mandatory = false, SortOrder = 2, DataTypeId = -90 }); mediaType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = "Media", SortOrder = 1 }); diff --git a/src/Umbraco.Web/Editors/DataTypeController.cs b/src/Umbraco.Web/Editors/DataTypeController.cs index 117bc33cc4..e1fa167778 100644 --- a/src/Umbraco.Web/Editors/DataTypeController.cs +++ b/src/Umbraco.Web/Editors/DataTypeController.cs @@ -93,7 +93,7 @@ namespace Umbraco.Web.Editors public DataTypeDisplay GetEmpty(int parentId) { // cannot create an "empty" data type, so use something by default. - var editor = _propertyEditors[Constants.PropertyEditors.Aliases.NoEdit]; + var editor = _propertyEditors[Constants.PropertyEditors.Aliases.Label]; var dt = new DataType(editor, parentId); return Mapper.Map(dt); } diff --git a/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs b/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs index 006954fcb2..effa59fd63 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs @@ -44,7 +44,7 @@ namespace Umbraco.Web.Models.Mapping "No property editor '{PropertyEditorAlias}' found, converting to a Label", property.PropertyType.PropertyEditorAlias); - editor = _propertyEditors[Constants.PropertyEditors.Aliases.NoEdit]; + editor = _propertyEditors[Constants.PropertyEditors.Aliases.Label]; } var result = new TDestination diff --git a/src/Umbraco.Web/Models/Mapping/MemberTabsAndPropertiesResolver.cs b/src/Umbraco.Web/Models/Mapping/MemberTabsAndPropertiesResolver.cs index 517889277c..1e93618547 100644 --- a/src/Umbraco.Web/Models/Mapping/MemberTabsAndPropertiesResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/MemberTabsAndPropertiesResolver.cs @@ -124,7 +124,7 @@ namespace Umbraco.Web.Models.Mapping Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}doctype", Label = _localizedTextService.Localize("content/membertype"), Value = _localizedTextService.UmbracoDictionaryTranslate(member.ContentType.Name), - View = Current.PropertyEditors[Constants.PropertyEditors.Aliases.NoEdit].GetValueEditor().View + View = Current.PropertyEditors[Constants.PropertyEditors.Aliases.Label].GetValueEditor().View }, GetLoginProperty(_memberService, member, _localizedTextService), new ContentPropertyDisplay diff --git a/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupResolver.cs b/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupResolver.cs index bbbf5e2746..ea0411eb15 100644 --- a/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupResolver.cs @@ -210,7 +210,7 @@ namespace Umbraco.Web.Models.Mapping { _logger.Error(GetType(), "No property editor could be resolved with the alias: {PropertyEditorAlias}, defaulting to label", p.PropertyEditorAlias); - propertyEditorAlias = Constants.PropertyEditors.Aliases.NoEdit; + propertyEditorAlias = Constants.PropertyEditors.Aliases.Label; propertyEditor = _propertyEditors[propertyEditorAlias]; } From 6a5f8c0ab8b1a0e00a5faa1449031069a0afd3bb Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 15 Feb 2019 19:32:13 +0100 Subject: [PATCH 10/11] Fix #4578 --- .../Models/PublishedContentBase.cs | 86 ++++++++++--------- .../NuCache/PublishedContent.cs | 23 ++--- 2 files changed, 56 insertions(+), 53 deletions(-) diff --git a/src/Umbraco.Web/Models/PublishedContentBase.cs b/src/Umbraco.Web/Models/PublishedContentBase.cs index 8a7565265f..39933b49be 100644 --- a/src/Umbraco.Web/Models/PublishedContentBase.cs +++ b/src/Umbraco.Web/Models/PublishedContentBase.cs @@ -15,13 +15,13 @@ namespace Umbraco.Web.Models [DebuggerDisplay("Content Id: {Id}, Name: {Name}")] public abstract class PublishedContentBase : IPublishedContent { - private readonly IUmbracoContextAccessor _umbracoContextAccessor; - protected PublishedContentBase(IUmbracoContextAccessor umbracoContextAccessor) { - _umbracoContextAccessor = umbracoContextAccessor; + UmbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor)); } + protected IUmbracoContextAccessor UmbracoContextAccessor { get; } + #region ContentType public abstract PublishedContentType ContentType { get; } @@ -86,50 +86,52 @@ namespace Umbraco.Web.Models /// public virtual string GetUrl(string culture = null) // TODO: consider .GetCulture("fr-FR").Url { - var umbracoContext = _umbracoContextAccessor.UmbracoContext; - switch (ItemType) - { - case PublishedItemType.Content: - if (umbracoContext == null) - throw new InvalidOperationException("Cannot compute Url for a content item when UmbracoContext is null."); - if (umbracoContext.UrlProvider == null) - throw new InvalidOperationException("Cannot compute Url for a content item when UmbracoContext.UrlProvider is null."); - return umbracoContext.UrlProvider.GetUrl(this, culture); + switch (ItemType) + { + case PublishedItemType.Content: + var umbracoContext = UmbracoContextAccessor.UmbracoContext; - case PublishedItemType.Media: - var prop = GetProperty(Constants.Conventions.Media.File); - if (prop?.GetValue() == null) - { - return string.Empty; - } + if (umbracoContext == null) + throw new InvalidOperationException("Cannot compute Url for a content item when UmbracoContext is null."); + if (umbracoContext.UrlProvider == null) + throw new InvalidOperationException("Cannot compute Url for a content item when UmbracoContext.UrlProvider is null."); - var propType = ContentType.GetPropertyType(Constants.Conventions.Media.File); - - // TODO: consider implementing media url providers - // note: that one does not support variations - //This is a hack - since we now have 2 properties that support a URL: upload and cropper, we need to detect this since we always - // want to return the normal URL and the cropper stores data as json - switch (propType.EditorAlias) - { - case Constants.PropertyEditors.Aliases.UploadField: - return prop.GetValue().ToString(); - break; - case Constants.PropertyEditors.Aliases.ImageCropper: - //get the url from the json format - - var stronglyTyped = prop.GetValue() as ImageCropperValue; - if (stronglyTyped != null) - { - return stronglyTyped.Src; - } - return prop.GetValue()?.ToString(); - } + return umbracoContext.UrlProvider.GetUrl(this, culture); + case PublishedItemType.Media: + var prop = GetProperty(Constants.Conventions.Media.File); + if (prop?.GetValue() == null) + { return string.Empty; + } - default: - throw new NotSupportedException(); - } + var propType = ContentType.GetPropertyType(Constants.Conventions.Media.File); + + // TODO: consider implementing media url providers + // note: that one does not support variations + //This is a hack - since we now have 2 properties that support a URL: upload and cropper, we need to detect this since we always + // want to return the normal URL and the cropper stores data as json + switch (propType.EditorAlias) + { + case Constants.PropertyEditors.Aliases.UploadField: + + return prop.GetValue().ToString(); + case Constants.PropertyEditors.Aliases.ImageCropper: + //get the url from the json format + + var stronglyTyped = prop.GetValue() as ImageCropperValue; + if (stronglyTyped != null) + { + return stronglyTyped.Src; + } + return prop.GetValue()?.ToString(); + } + + return string.Empty; + + default: + throw new NotSupportedException(); + } } /// diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs index aa19918ca9..3526a6daeb 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs @@ -13,7 +13,6 @@ namespace Umbraco.Web.PublishedCache.NuCache internal class PublishedContent : PublishedContentBase { private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; - private readonly IUmbracoContextAccessor _umbracoContextAccessor; private readonly ContentNode _contentNode; private readonly string _urlSegment; @@ -24,13 +23,13 @@ namespace Umbraco.Web.PublishedCache.NuCache ContentData contentData, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, - IUmbracoContextAccessor umbracoContextAccessor) :base(umbracoContextAccessor) + IUmbracoContextAccessor umbracoContextAccessor) + : base(umbracoContextAccessor) { - _contentNode = contentNode; - ContentData = contentData; - _publishedSnapshotAccessor = publishedSnapshotAccessor; - _umbracoContextAccessor = umbracoContextAccessor; - VariationContextAccessor = variationContextAccessor; + _contentNode = contentNode ?? throw new ArgumentNullException(nameof(contentNode)); + ContentData = contentData ?? throw new ArgumentNullException(nameof(contentData)); + _publishedSnapshotAccessor = publishedSnapshotAccessor ?? throw new ArgumentNullException(nameof(publishedSnapshotAccessor)); + VariationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor)); _urlSegment = ContentData.Name.ToUrlSegment(); IsPreviewing = ContentData.Published == false; @@ -72,7 +71,8 @@ namespace Umbraco.Web.PublishedCache.NuCache public PublishedContent( ContentNode contentNode, PublishedContent origin, - IUmbracoContextAccessor umbracoContextAccessor) :base(umbracoContextAccessor) + IUmbracoContextAccessor umbracoContextAccessor) + : base(umbracoContextAccessor) { _contentNode = contentNode; _publishedSnapshotAccessor = origin._publishedSnapshotAccessor; @@ -91,7 +91,8 @@ namespace Umbraco.Web.PublishedCache.NuCache // clone for previewing as draft a published content that is published and has no draft private PublishedContent( PublishedContent origin, - IUmbracoContextAccessor umbracoContextAccessor) :base(umbracoContextAccessor) + IUmbracoContextAccessor umbracoContextAccessor) + : base(umbracoContextAccessor) { _publishedSnapshotAccessor = origin._publishedSnapshotAccessor; VariationContextAccessor = origin.VariationContextAccessor; @@ -468,8 +469,8 @@ namespace Umbraco.Web.PublishedCache.NuCache return this; var cache = GetAppropriateCache(); - if (cache == null) return new PublishedContent(this, _umbracoContextAccessor).CreateModel(); - return (IPublishedContent)cache.Get(AsPreviewingCacheKey, () => new PublishedContent(this, _umbracoContextAccessor).CreateModel()); + if (cache == null) return new PublishedContent(this, UmbracoContextAccessor).CreateModel(); + return (IPublishedContent)cache.Get(AsPreviewingCacheKey, () => new PublishedContent(this, UmbracoContextAccessor).CreateModel()); } // used by Navigable.Source,... From 834a30b5c7e172f1d4bbdfe0c1335d9c7a780af7 Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 15 Feb 2019 22:45:30 +0100 Subject: [PATCH 11/11] Fix tests --- .../PublishedMediaCache.cs | 3 ++- .../PublishedContent/PublishedMediaTests.cs | 17 ++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs index eeab265df8..71490465d0 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs @@ -70,7 +70,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache /// /// /// - internal PublishedMediaCache(IMediaService mediaService, IUserService userService, ISearcher searchProvider, IAppCache appCache, PublishedContentTypeCache contentTypeCache, IEntityXmlSerializer entitySerializer) + internal PublishedMediaCache(IMediaService mediaService, IUserService userService, ISearcher searchProvider, IAppCache appCache, PublishedContentTypeCache contentTypeCache, IEntityXmlSerializer entitySerializer, IUmbracoContextAccessor umbracoContextAccessor) : base(false) { _mediaService = mediaService ?? throw new ArgumentNullException(nameof(mediaService)); @@ -79,6 +79,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache _appCache = appCache; _contentTypeCache = contentTypeCache; _entitySerializer = entitySerializer; + _umbracoContextAccessor = umbracoContextAccessor; } static PublishedMediaCache() diff --git a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs index a9022554c9..f801d02c5b 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs @@ -23,6 +23,7 @@ using Umbraco.Core.Models.Membership; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Services; using Umbraco.Tests.LegacyXmlPublishedCache; +using Umbraco.Tests.Testing.Objects.Accessors; namespace Umbraco.Tests.PublishedContent { @@ -44,6 +45,8 @@ namespace Umbraco.Tests.PublishedContent Composition.WithCollectionBuilder() .Clear() .Append(); + + Composition.RegisterUnique(); } private IMediaType MakeNewMediaType(IUser user, string text, int parentId = -1) @@ -126,7 +129,7 @@ namespace Umbraco.Tests.PublishedContent var searcher = indexer.GetSearcher(); var ctx = GetUmbracoContext("/test"); - var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance()); + var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance()); //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace var publishedMedia = cache.GetById(1111); @@ -156,7 +159,7 @@ namespace Umbraco.Tests.PublishedContent var searcher = indexer.GetSearcher(); var ctx = GetUmbracoContext("/test"); - var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance()); + var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance()); //ensure it is found var publishedMedia = cache.GetById(3113); @@ -203,7 +206,7 @@ namespace Umbraco.Tests.PublishedContent var searcher = indexer.GetSearcher(); var ctx = GetUmbracoContext("/test"); - var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance()); + var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance()); //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace var publishedMedia = cache.GetById(1111); @@ -231,7 +234,7 @@ namespace Umbraco.Tests.PublishedContent var searcher = indexer.GetSearcher(); var ctx = GetUmbracoContext("/test"); - var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance()); + var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance()); //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace var publishedMedia = cache.GetById(1111); @@ -259,7 +262,7 @@ namespace Umbraco.Tests.PublishedContent var searcher = indexer.GetSearcher(); var ctx = GetUmbracoContext("/test"); - var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance()); + var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance()); //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace var publishedMedia = cache.GetById(1111); @@ -288,7 +291,7 @@ namespace Umbraco.Tests.PublishedContent var ctx = GetUmbracoContext("/test"); var searcher = indexer.GetSearcher(); - var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance()); + var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance()); //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace var publishedMedia = cache.GetById(3113); @@ -314,7 +317,7 @@ namespace Umbraco.Tests.PublishedContent var ctx = GetUmbracoContext("/test"); var searcher = indexer.GetSearcher(); - var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance()); + var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance()); //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace var publishedMedia = cache.GetById(3113);