From c494ad0adc94926cfbfb3bf37fe68f3dc69e214d Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Mon, 20 May 2019 15:36:57 +0200 Subject: [PATCH 1/7] Fake settings + ability to swap editor and block views --- .../umbblockeditorblock.directive.js | 2 +- .../umbblockeditorblocks.directive.js | 1 - .../blockeditor/blockeditor.block.html | 26 ++++++++++--------- .../blockeditor/blockeditor.blocks.html | 13 ++++++---- .../blockeditor/blockeditor.controller.js | 18 ++++++++++++- 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblock.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblock.directive.js index 0db2873782..12cd2a868c 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblock.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblock.directive.js @@ -1,11 +1,11 @@ angular.module("umbraco.directives").directive('umbBlockEditorBlock', [ function () { var link = function (scope, el, attr, ctrl) { + scope.view = attr.view; }; return { restrict: "E", - replace: true, templateUrl: "views/propertyeditors/blockeditor/blockeditor.block.html", link: link }; diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblocks.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblocks.directive.js index 9c67e134ea..bf1f8148e2 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblocks.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblocks.directive.js @@ -5,7 +5,6 @@ return { restrict: "E", - replace: true, templateUrl: "views/propertyeditors/blockeditor/blockeditor.blocks.html", link: link }; diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.html index 85a5e578a4..6aeeef7823 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.html @@ -1,14 +1,16 @@ -
-
- Block identifier goes here (e.g. icon) -
-
- -
-
- -
-
- +
+
+
+
+
+ +
+
+ +
+
+
+ Eventually a block identifier will go here (e.g. element type icon) +
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.blocks.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.blocks.html index 2763af5039..54817aa676 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.blocks.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.blocks.html @@ -1,5 +1,8 @@ -
    -
  • - -
  • -
+
+
+
    +
  • + +
  • +
+
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.controller.js index 28bb91583c..2bd846eb71 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.controller.js @@ -14,6 +14,8 @@ vm.editContent = editContent; vm.editSettings = editSettings; vm.remove = remove; + // TODO: this needs to be configurable on data type level + vm.blocksView = null; // "/App_Plugins/MyBlockEditor/myblockeditor.html"; // it would be awesome if we could load all scaffolds in one go... however we need to have an eye out for performance, // oddly enough it's been shown to actually be slower to load them all at once instead of one at a time @@ -44,6 +46,12 @@ return blockConfig.elementType === scaffold.udi; }); }); + + _.each($scope.model.value, function (block) { + applyFakeSettings(block); + }); + + vm.loading = false; } } @@ -85,6 +93,7 @@ }); if ($scope.model.value.indexOf(block) < 0) { $scope.model.value.push(block); + applyFakeSettings(block); } editorService.close(); @@ -103,7 +112,7 @@ view: "views/propertyeditors/blockeditor/blockeditor.editsettings.html", size: "medium", submit: function(model) { - console.log("TODO: something with block settings", model) + applyFakeSettings(block); editorService.close(); }, close: function() { @@ -114,11 +123,18 @@ } function remove(block) { + // this should be replaced by a custom dialog (pending some PRs) if (confirm("TODO: Are you sure?")) { $scope.model.value.splice($scope.model.value.indexOf(block), 1); } } init(); + + // TODO: remove this (only for testing) + function applyFakeSettings(block) { + block.settings["cols"] = 1 + Math.floor(Math.random() * 3); + block.settings["rows"] = 1 + Math.floor(Math.random() * 2); + } } angular.module("umbraco").controller("Umbraco.PropertyEditors.BlockEditor.PropertyEditorController", BlockEditorPropertyEditorController); From 7ce4fbe44c03c1c58cd6e467d670f3e583a2fdc6 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Mon, 20 May 2019 17:40:38 +0200 Subject: [PATCH 2/7] Refactor to make it reusable across implementations --- .../components/umbblockeditor.directive.js | 15 +++++++ .../umbblockeditorblocks.directive.js | 12 ------ .../blockeditor/blockeditor.blocks.html | 8 ---- .../blockeditor.default.controller.js | 11 ++++++ .../blockeditor/blockeditor.default.html | 14 +++++++ ...js => blockeditor.directive.controller.js} | 39 +++++++++---------- .../blockeditor/blockeditor.directive.html | 7 ++++ .../blockeditor/blockeditor.html | 17 +------- 8 files changed, 66 insertions(+), 57 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditor.directive.js delete mode 100644 src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblocks.directive.js delete mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.blocks.html create mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.controller.js create mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.html rename src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/{blockeditor.controller.js => blockeditor.directive.controller.js} (77%) create mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.directive.html diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditor.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditor.directive.js new file mode 100644 index 0000000000..1fddf4dcc6 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditor.directive.js @@ -0,0 +1,15 @@ +angular.module("umbraco.directives").directive('umbBlockEditor', [ + function () { + return { + restrict: "E", + templateUrl: "views/propertyeditors/blockeditor/blockeditor.directive.html", + scope: { + config: "=", + view: "=?", + blocks: "=" + }, + controller: "Umbraco.PropertyEditors.BlockEditor.DirectiveController", + controllerAs: "vm" + }; + } +]); diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblocks.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblocks.directive.js deleted file mode 100644 index bf1f8148e2..0000000000 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblocks.directive.js +++ /dev/null @@ -1,12 +0,0 @@ -angular.module("umbraco.directives").directive('umbBlockEditorBlocks', [ - function () { - var link = function (scope, el, attr, ctrl) { - }; - - return { - restrict: "E", - templateUrl: "views/propertyeditors/blockeditor/blockeditor.blocks.html", - link: link - }; - } -]); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.blocks.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.blocks.html deleted file mode 100644 index 54817aa676..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.blocks.html +++ /dev/null @@ -1,8 +0,0 @@ -
-
-
    -
  • - -
  • -
-
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.controller.js new file mode 100644 index 0000000000..3ed36060fe --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.controller.js @@ -0,0 +1,11 @@ +function BlockEditorDefaultController($scope, contentResource, editorService) { + console.log("Block editor default controller", $scope.model) + // TODO: move this to a controller supporting the default blockeditor view + $scope.sortableOptions = { + axis: "y", + cursor: "move", + handle: ".handle", + tolerance: 'pointer' + }; +} +angular.module("umbraco").controller("Umbraco.PropertyEditors.BlockEditor.DefaultController", BlockEditorDefaultController); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.html new file mode 100644 index 0000000000..97613b0193 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.html @@ -0,0 +1,14 @@ +
+
    +
  • + +
  • +
+ +
+ Add: +
+ +
+
+
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.directive.controller.js similarity index 77% rename from src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.controller.js rename to src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.directive.controller.js index 2bd846eb71..681617871e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.directive.controller.js @@ -1,32 +1,29 @@ -function BlockEditorPropertyEditorController($scope, contentResource, editorService) { +function BlockEditorDirectiveController($scope, contentResource, editorService) { var vm = this; vm.scaffolds = []; vm.loading = true; - vm.sortableOptions = { - axis: "y", - cursor: "move", - handle: ".handle", - tolerance: 'pointer' - }; - vm.add = add; vm.editContent = editContent; vm.editSettings = editSettings; vm.remove = remove; - // TODO: this needs to be configurable on data type level - vm.blocksView = null; // "/App_Plugins/MyBlockEditor/myblockeditor.html"; // it would be awesome if we could load all scaffolds in one go... however we need to have an eye out for performance, // oddly enough it's been shown to actually be slower to load them all at once instead of one at a time var scaffoldsLoaded = 0; function init() { - $scope.model.value = $scope.model.value || []; - _.each($scope.model.config.blocks, function (blockConfig) { - contentResource.getScaffoldByUdi(-20, blockConfig.elementType).then(function (scaffold) { + if (!$scope.blocks) { + $scope.blocks = []; + } + if (!$scope.view) { + $scope.view = "views/propertyeditors/blockeditor/blockeditor.default.html"; + } + + _.each($scope.config, function (config) { + contentResource.getScaffoldByUdi(-20, config.elementType).then(function (scaffold) { if (scaffold.isElement) { // the scaffold udi is not the same as the element type udi, but we need it to be for comparison - scaffold.udi = blockConfig.elementType; + scaffold.udi = config.elementType; vm.scaffolds.push(scaffold); } scaffoldsLoaded++; @@ -40,14 +37,14 @@ function initIfAllScaffoldsHaveLoaded() { // Initialize when all scaffolds have loaded - if ($scope.model.config.blocks.length === scaffoldsLoaded) { + if ($scope.config.length === scaffoldsLoaded) { vm.scaffolds = _.sortBy(vm.scaffolds, function (scaffold) { - return _.findIndex($scope.model.config.blocks, function (blockConfig) { + return _.findIndex($scope.config, function (blockConfig) { return blockConfig.elementType === scaffold.udi; }); }); - _.each($scope.model.value, function (block) { + _.each($scope.blocks, function (block) { applyFakeSettings(block); }); @@ -91,8 +88,8 @@ block.content[property.alias] = property.value; }); }); - if ($scope.model.value.indexOf(block) < 0) { - $scope.model.value.push(block); + if ($scope.blocks.indexOf(block) < 0) { + $scope.blocks.push(block); applyFakeSettings(block); } @@ -125,7 +122,7 @@ function remove(block) { // this should be replaced by a custom dialog (pending some PRs) if (confirm("TODO: Are you sure?")) { - $scope.model.value.splice($scope.model.value.indexOf(block), 1); + $scope.blocks.splice($scope.blocks.indexOf(block), 1); } } @@ -137,4 +134,4 @@ block.settings["rows"] = 1 + Math.floor(Math.random() * 2); } } -angular.module("umbraco").controller("Umbraco.PropertyEditors.BlockEditor.PropertyEditorController", BlockEditorPropertyEditorController); +angular.module("umbraco").controller("Umbraco.PropertyEditors.BlockEditor.DirectiveController", BlockEditorDirectiveController); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.directive.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.directive.html new file mode 100644 index 0000000000..98ae7a79fd --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.directive.html @@ -0,0 +1,7 @@ +
+
+ +
+ +
+
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.html index 3329a895c3..3c95c536f3 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.html @@ -1,16 +1 @@ -
-
- -
- -
- - -
- Add: -
- -
-
-
-
+ From d71b2a07c4f0515af49c333990ea494aeec2467a Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Mon, 20 May 2019 18:03:21 +0200 Subject: [PATCH 3/7] Refactor block view specification in the block directive --- .../components/umbblockeditorblock.directive.js | 4 ++-- .../blockeditor/blockeditor.block.default.html | 13 +++++++++++++ .../blockeditor/blockeditor.block.html | 16 ---------------- .../blockeditor/blockeditor.default.html | 4 +++- 4 files changed, 18 insertions(+), 19 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.default.html delete mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.html diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblock.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblock.directive.js index 12cd2a868c..9b471f025f 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblock.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblock.directive.js @@ -1,12 +1,12 @@ angular.module("umbraco.directives").directive('umbBlockEditorBlock', [ function () { var link = function (scope, el, attr, ctrl) { - scope.view = attr.view; + scope.view = attr.view || "views/propertyeditors/blockeditor/blockeditor.block.default.html"; }; return { restrict: "E", - templateUrl: "views/propertyeditors/blockeditor/blockeditor.block.html", + template: "
", link: link }; } diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.default.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.default.html new file mode 100644 index 0000000000..b27f08e060 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.default.html @@ -0,0 +1,13 @@ +
+
+
+ +
+
+ +
+
+
+ Eventually a block identifier will go here (e.g. element type icon) +
+
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.html deleted file mode 100644 index 6aeeef7823..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.html +++ /dev/null @@ -1,16 +0,0 @@ -
-
-
-
-
- -
-
- -
-
-
- Eventually a block identifier will go here (e.g. element type icon) -
-
-
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.html index 97613b0193..84cf55fe7d 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.html @@ -1,7 +1,9 @@ 
  • - +
    + +
From 36616fb9d16547a97b4cbbd3b26c037d2bb4beac Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Mon, 20 May 2019 18:17:57 +0200 Subject: [PATCH 4/7] Split into SimpleGrid --- src/Umbraco.Core/Constants-PropertyEditors.cs | 5 ----- .../umbblockeditorblock.directive.js | 2 +- ...ock.default.html => blockeditor.block.html} | 0 .../blockeditor.default.controller.js | 2 -- .../simplegrid.html} | 0 .../BlockEditorConfiguration.cs | 2 +- .../BlockEditorConfigurationEditor.cs | 9 --------- .../BlockEditorPropertyEditor.cs | 18 ------------------ .../PropertyEditors/SimpleGridConfiguration.cs | 6 ++++++ .../SimpleGridConfigurationEditor.cs | 9 +++++++++ .../SimpleGridPropertyEditor.cs | 17 +++++++++++++++++ src/Umbraco.Web/Umbraco.Web.csproj | 5 +++-- 12 files changed, 37 insertions(+), 38 deletions(-) rename src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/{blockeditor.block.default.html => blockeditor.block.html} (100%) rename src/Umbraco.Web.UI.Client/src/views/propertyeditors/{blockeditor/blockeditor.html => simplegrid/simplegrid.html} (100%) delete mode 100644 src/Umbraco.Web/PropertyEditors/BlockEditorConfigurationEditor.cs delete mode 100644 src/Umbraco.Web/PropertyEditors/BlockEditorPropertyEditor.cs create mode 100644 src/Umbraco.Web/PropertyEditors/SimpleGridConfiguration.cs create mode 100644 src/Umbraco.Web/PropertyEditors/SimpleGridConfigurationEditor.cs create mode 100644 src/Umbraco.Web/PropertyEditors/SimpleGridPropertyEditor.cs diff --git a/src/Umbraco.Core/Constants-PropertyEditors.cs b/src/Umbraco.Core/Constants-PropertyEditors.cs index f9b298e586..0c2e246721 100644 --- a/src/Umbraco.Core/Constants-PropertyEditors.cs +++ b/src/Umbraco.Core/Constants-PropertyEditors.cs @@ -19,11 +19,6 @@ namespace Umbraco.Core /// public static class Aliases { - /// - /// Block Editor. - /// - public const string BlockEditor = "Umbraco.BlockEditor"; - /// /// CheckBox List. /// diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblock.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblock.directive.js index 9b471f025f..09964f3d43 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblock.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditorblock.directive.js @@ -1,7 +1,7 @@ angular.module("umbraco.directives").directive('umbBlockEditorBlock', [ function () { var link = function (scope, el, attr, ctrl) { - scope.view = attr.view || "views/propertyeditors/blockeditor/blockeditor.block.default.html"; + scope.view = attr.view || "views/propertyeditors/blockeditor/blockeditor.block.html"; }; return { diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.default.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.html similarity index 100% rename from src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.default.html rename to src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.block.html diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.controller.js index 3ed36060fe..c3287170a7 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.controller.js @@ -1,6 +1,4 @@ function BlockEditorDefaultController($scope, contentResource, editorService) { - console.log("Block editor default controller", $scope.model) - // TODO: move this to a controller supporting the default blockeditor view $scope.sortableOptions = { axis: "y", cursor: "move", diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/simplegrid/simplegrid.html similarity index 100% rename from src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.html rename to src/Umbraco.Web.UI.Client/src/views/propertyeditors/simplegrid/simplegrid.html diff --git a/src/Umbraco.Web/PropertyEditors/BlockEditorConfiguration.cs b/src/Umbraco.Web/PropertyEditors/BlockEditorConfiguration.cs index b91c6b37bf..c96c901861 100644 --- a/src/Umbraco.Web/PropertyEditors/BlockEditorConfiguration.cs +++ b/src/Umbraco.Web/PropertyEditors/BlockEditorConfiguration.cs @@ -4,7 +4,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - public class BlockEditorConfiguration + public abstract class BlockEditorConfiguration { [ConfigurationField("blocks", "Blocks", "views/propertyeditors/blockeditor/blockeditor.settings.html")] public Block[] Blocks { get; set; } diff --git a/src/Umbraco.Web/PropertyEditors/BlockEditorConfigurationEditor.cs b/src/Umbraco.Web/PropertyEditors/BlockEditorConfigurationEditor.cs deleted file mode 100644 index cd68108f16..0000000000 --- a/src/Umbraco.Web/PropertyEditors/BlockEditorConfigurationEditor.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Umbraco.Core.PropertyEditors; - -namespace Umbraco.Web.PropertyEditors -{ - internal class BlockEditorConfigurationEditor : ConfigurationEditor - { - - } -} diff --git a/src/Umbraco.Web/PropertyEditors/BlockEditorPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/BlockEditorPropertyEditor.cs deleted file mode 100644 index f486af4c3d..0000000000 --- a/src/Umbraco.Web/PropertyEditors/BlockEditorPropertyEditor.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Umbraco.Core; -using Umbraco.Core.Logging; -using Umbraco.Core.PropertyEditors; - -namespace Umbraco.Web.PropertyEditors -{ - [DataEditor(Constants.PropertyEditors.Aliases.BlockEditor, EditorType.PropertyValue , "Block Editor", "blockeditor", ValueType = ValueTypes.Json, Group="rich content", Icon="icon-application-window-alt")] - public class BlockEditorPropertyEditor : DataEditor - { - public BlockEditorPropertyEditor(ILogger logger) - : base(logger) - { } - - protected override IConfigurationEditor CreateConfigurationEditor() => new BlockEditorConfigurationEditor(); - - protected override IDataValueEditor CreateValueEditor() => base.CreateValueEditor(); - } -} diff --git a/src/Umbraco.Web/PropertyEditors/SimpleGridConfiguration.cs b/src/Umbraco.Web/PropertyEditors/SimpleGridConfiguration.cs new file mode 100644 index 0000000000..8664c3b40c --- /dev/null +++ b/src/Umbraco.Web/PropertyEditors/SimpleGridConfiguration.cs @@ -0,0 +1,6 @@ +namespace Umbraco.Web.PropertyEditors +{ + public class SimpleGridConfiguration : BlockEditorConfiguration + { + } +} diff --git a/src/Umbraco.Web/PropertyEditors/SimpleGridConfigurationEditor.cs b/src/Umbraco.Web/PropertyEditors/SimpleGridConfigurationEditor.cs new file mode 100644 index 0000000000..eaa054ff7e --- /dev/null +++ b/src/Umbraco.Web/PropertyEditors/SimpleGridConfigurationEditor.cs @@ -0,0 +1,9 @@ +using Umbraco.Core.PropertyEditors; + +namespace Umbraco.Web.PropertyEditors +{ + internal class SimpleGridConfigurationEditor : ConfigurationEditor + { + + } +} diff --git a/src/Umbraco.Web/PropertyEditors/SimpleGridPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/SimpleGridPropertyEditor.cs new file mode 100644 index 0000000000..eb20a177ea --- /dev/null +++ b/src/Umbraco.Web/PropertyEditors/SimpleGridPropertyEditor.cs @@ -0,0 +1,17 @@ +using Umbraco.Core.Logging; +using Umbraco.Core.PropertyEditors; + +namespace Umbraco.Web.PropertyEditors +{ + [DataEditor("Umbraco.SimpleGrid", EditorType.PropertyValue , "Simple Grid", "simplegrid", ValueType = ValueTypes.Json, Group="rich content", Icon="icon-application-window-alt")] + public class SimpleGridPropertyEditor : DataEditor + { + public SimpleGridPropertyEditor(ILogger logger) + : base(logger) + { } + + protected override IConfigurationEditor CreateConfigurationEditor() => new SimpleGridConfigurationEditor(); + + protected override IDataValueEditor CreateValueEditor() => base.CreateValueEditor(); + } +} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 4860559e00..57e2c722a5 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -212,8 +212,9 @@ - - + + + From 663228c33bccb2a51e067c5752717cb17220a6a1 Mon Sep 17 00:00:00 2001 From: Callum Whyte Date: Mon, 20 May 2019 17:18:51 +0100 Subject: [PATCH 5/7] Updating block settings editor --- .../blockeditor/blockeditor.settings.html | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.settings.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.settings.html index b658421791..29e2978724 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.settings.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.settings.html @@ -1,23 +1,20 @@ 
-
{{model.value | json}}
- -
- - {{block.elementType}} - - - - Settings - - - - Remove - -
+ + Add +
+
{{model.value | json}}
+
From 6c2401fa27603eb179a729549d3acf5424d55b01 Mon Sep 17 00:00:00 2001 From: Callum Whyte Date: Mon, 20 May 2019 17:24:37 +0100 Subject: [PATCH 6/7] Ensuring blocks are persisted when settings are saved --- .../blockeditor/blockeditor.settings.controller.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.settings.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.settings.controller.js index 0d7eedbcf0..3f1ef17d43 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.settings.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.settings.controller.js @@ -30,6 +30,10 @@ openSettingsPicker(block); }; + $scope.$on("formSubmitting", function () { + $scope.model.value = $scope.blocks; + }); + function openElementPicker(block) { var pickerOptions = { From e2b0053d318f2596101a0a9484cc873140f80e33 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Mon, 20 May 2019 18:37:12 +0200 Subject: [PATCH 7/7] Rename default view to simple list --- .../directives/components/umbblockeditor.directive.js | 7 ++++++- .../blockeditor/blockeditor.directive.controller.js | 3 --- ....controller.js => blockeditor.simplelist.controller.js} | 4 ++-- ...lockeditor.default.html => blockeditor.simplelist.html} | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) rename src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/{blockeditor.default.controller.js => blockeditor.simplelist.controller.js} (57%) rename src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/{blockeditor.default.html => blockeditor.simplelist.html} (87%) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditor.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditor.directive.js index 1fddf4dcc6..79463d1d24 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditor.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbblockeditor.directive.js @@ -1,5 +1,9 @@ angular.module("umbraco.directives").directive('umbBlockEditor', [ function () { + var link = function (scope, el, attr, ctrl) { + scope.view = attr.view || "views/propertyeditors/blockeditor/blockeditor.simplelist.html"; + }; + return { restrict: "E", templateUrl: "views/propertyeditors/blockeditor/blockeditor.directive.html", @@ -9,7 +13,8 @@ blocks: "=" }, controller: "Umbraco.PropertyEditors.BlockEditor.DirectiveController", - controllerAs: "vm" + controllerAs: "vm", + link: link }; } ]); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.directive.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.directive.controller.js index 681617871e..e4c16d4c28 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.directive.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.directive.controller.js @@ -15,9 +15,6 @@ if (!$scope.blocks) { $scope.blocks = []; } - if (!$scope.view) { - $scope.view = "views/propertyeditors/blockeditor/blockeditor.default.html"; - } _.each($scope.config, function (config) { contentResource.getScaffoldByUdi(-20, config.elementType).then(function (scaffold) { diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.simplelist.controller.js similarity index 57% rename from src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.controller.js rename to src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.simplelist.controller.js index c3287170a7..b98eb2cd6d 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.simplelist.controller.js @@ -1,4 +1,4 @@ -function BlockEditorDefaultController($scope, contentResource, editorService) { +function BlockEditorSimpleListController($scope, contentResource, editorService) { $scope.sortableOptions = { axis: "y", cursor: "move", @@ -6,4 +6,4 @@ tolerance: 'pointer' }; } -angular.module("umbraco").controller("Umbraco.PropertyEditors.BlockEditor.DefaultController", BlockEditorDefaultController); +angular.module("umbraco").controller("Umbraco.PropertyEditors.BlockEditor.SimpleListController", BlockEditorSimpleListController); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.simplelist.html similarity index 87% rename from src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.html rename to src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.simplelist.html index 84cf55fe7d..ff4809da77 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.default.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockeditor/blockeditor.simplelist.html @@ -1,4 +1,4 @@ -
+