From 71c6a840084101ce5d98cc9bcbcec0b6d91d63eb Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Tue, 23 Feb 2021 18:26:52 +0100 Subject: [PATCH 01/12] Fix wrong end closing tag --- .../views/propertyeditors/grid/dialogs/layoutconfig.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html index 6ff18e83ad9c..856831e3f1d6 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html @@ -39,8 +39,8 @@ ng-click="configureSection(section, currentLayout)" ng-style="{width: percentage(section.grid) +'%'}"> - Edit grid layout - + Edit grid layout + From 5e746bc1ad61d1b1a70fafd08538342c1c39b794 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Tue, 23 Feb 2021 18:29:40 +0100 Subject: [PATCH 02/12] Add button type attribute --- .../views/propertyeditors/grid/dialogs/layoutconfig.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html index 856831e3f1d6..294bf869738c 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html @@ -108,9 +108,9 @@ on-change="selectRow(currentSection, row)"> - diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js index 83a9fd53941c..4931547724bd 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js @@ -80,7 +80,7 @@ function RowConfigController($scope, localizationService) { } }; - $scope.toggleAllowed = function (cell) { + vm.toggleAllowed = function (cell) { cell.allowAll = !cell.allowAll; if (cell.allowed) { diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.html index 9d105e26295b..8040ea36f715 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.html @@ -93,7 +93,7 @@ Date: Wed, 24 Feb 2021 00:07:06 +0100 Subject: [PATCH 06/12] Cleanup output --- .../propertyeditors/grid/dialogs/layoutconfig.controller.js | 4 ---- .../src/views/propertyeditors/grid/dialogs/layoutconfig.html | 4 ---- 2 files changed, 8 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js index 062dc08591b6..ac8f5bd5b7d2 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js @@ -79,14 +79,10 @@ angular.module("umbraco") template.sections.push(section); } - console.log("section 1", section); - if (section.allowAll && (!section.allowed || !section.allowed.length)) { section.allowAll = true; } - console.log("section 2", section); - $scope.currentSection = section; }; diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html index bdd2e0e6b2d6..6adc16c26ca3 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html @@ -82,8 +82,6 @@ - {{currentSection.allowAll}} - - {{currentSection | json}} -

From b4c7342a8a87c1dd928339abe4ddb9a653f16ac3 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Wed, 24 Feb 2021 00:07:37 +0100 Subject: [PATCH 07/12] Register functions in vm --- .../grid/dialogs/layoutconfig.controller.js | 46 ++++++++------ .../grid/dialogs/layoutconfig.html | 25 ++++---- .../grid/dialogs/rowconfig.controller.js | 60 +++++++++++-------- .../grid/dialogs/rowconfig.html | 24 ++++---- 4 files changed, 88 insertions(+), 67 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js index ac8f5bd5b7d2..468a2f3829e3 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js @@ -4,6 +4,16 @@ angular.module("umbraco") var vm = this; + vm.toggleAllowed = toggleAllowed; + vm.configureSection = configureSection; + vm.deleteSection = deleteSection; + vm.selectRow = selectRow; + vm.percentage = percentage; + vm.scaleUp = scaleUp; + vm.scaleDown = scaleDown; + vm.close = close; + vm.submit = submit; + vm.labels = {}; vm.layout = { sections: [] @@ -48,28 +58,28 @@ angular.module("umbraco") } } - $scope.scaleUp = function(section, max, overflow){ + function scaleUp(section, max, overflow){ var add = 1; if (overflow !== true){ add = (max > 1) ? 1 : max; } //var add = (max > 1) ? 1 : max; section.grid = section.grid+add; - }; + } - $scope.scaleDown = function(section){ + function scaleDown(section){ var remove = (section.grid > 1) ? 1 : 0; section.grid = section.grid-remove; - }; + } - $scope.percentage = function(spans){ + function percentage(spans){ return ((spans / $scope.columns) * 100).toFixed(8); - }; + } /**************** Section *****************/ - $scope.configureSection = function(section, template) { + function configureSection(section, template) { if (section === null || section === undefined) { var space = ($scope.availableLayoutSpace > 4) ? 4 : $scope.availableLayoutSpace; section = { @@ -84,9 +94,9 @@ angular.module("umbraco") } $scope.currentSection = section; - }; + } - vm.toggleAllowed = function (section) { + function toggleAllowed(section) { section.allowAll = !section.allowAll; if (section.allowed) { @@ -95,17 +105,17 @@ angular.module("umbraco") else { section.allowed = []; } - }; + } - $scope.deleteSection = function(section, template) { + function deleteSection(section, template) { if ($scope.currentSection === section) { $scope.currentSection = null; } var index = template.sections.indexOf(section) template.sections.splice(index, 1); - }; + } - $scope.selectRow = function (section, row) { + function selectRow(section, row) { section.allowed = section.allowed || []; @@ -118,15 +128,15 @@ angular.module("umbraco") else { section.allowed.splice(index, 1); } - }; + } - $scope.close = function() { + function close() { if ($scope.model.close) { $scope.model.close(); } - }; + } - $scope.submit = function () { + function submit() { if ($scope.model.submit) { // Delete temporary rows configurated in init. @@ -136,7 +146,7 @@ angular.module("umbraco") $scope.model.submit($scope.currentLayout); } - }; + } $scope.$watch("currentLayout", function(layout){ if (layout) { diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html index 6adc16c26ca3..5e05f56b4819 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.html @@ -36,16 +36,16 @@ {{currentSection.grid}} -
@@ -74,7 +73,7 @@ @@ -105,19 +104,19 @@ + on-change="vm.selectRow(currentSection, row)"> {{currentCell.grid}} - @@ -84,7 +84,7 @@ - @@ -108,7 +108,7 @@ + on-change="vm.selectEditor(currentCell, editor)"> {{editor.name}} ({{editor.alias}}) @@ -132,13 +132,13 @@ button-style="link" label-key="general_close" shortcut="esc" - action="close()"> + action="vm.close()"> + action="vm.submit()"> From 69cbc4798002e3242ca2bff4674627e66a2807d9 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Wed, 24 Feb 2021 00:13:30 +0100 Subject: [PATCH 08/12] Move nameChanged property to init function --- .../propertyeditors/grid/dialogs/rowconfig.controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js index 9ed37b3959c1..2abbc6e15cda 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js @@ -20,6 +20,7 @@ function RowConfigController($scope, localizationService) { $scope.currentRow = $scope.model.currentRow; $scope.columns = $scope.model.columns; $scope.editors = $scope.model.editors; + $scope.nameChanged = false; var labelKeys = [ "grid_addRowConfiguration", @@ -141,8 +142,6 @@ function RowConfigController($scope, localizationService) { } } - $scope.nameChanged = false; - var originalName = $scope.currentRow.name; $scope.$watch("currentRow", function(row) { if (row) { @@ -153,6 +152,7 @@ function RowConfigController($scope, localizationService) { $scope.availableRowSpace = $scope.columns - total; + var originalName = $scope.currentRow.name; if (originalName) { if (originalName != row.name) { $scope.nameChanged = true; From fce63b991b89c9c70cfb125f785ae602050907e9 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Wed, 24 Feb 2021 00:40:03 +0100 Subject: [PATCH 09/12] Don't set toggled as checked when switching columns in row --- .../propertyeditors/grid/dialogs/rowconfig.controller.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js index 2abbc6e15cda..7e7f63470a12 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js @@ -87,8 +87,11 @@ function RowConfigController($scope, localizationService) { $scope.editors.forEach(function (e) { e.allowed = cell.allowed.indexOf(e.alias) !== -1 }); + if (cell.allowAll && (!cell.allowed || !cell.allowed.length)) { + cell.allowAll = true; + } + $scope.currentCell = cell; - $scope.currentCell.allowAll = cell.allowAll || !cell.allowed || !cell.allowed.length; } } From 7d89bd8c6e510bf3a1add6358f3a098404f997f5 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Wed, 24 Feb 2021 00:48:14 +0100 Subject: [PATCH 10/12] Use existing behaviour to set allowAll --- .../propertyeditors/grid/dialogs/layoutconfig.controller.js | 4 +--- .../propertyeditors/grid/dialogs/rowconfig.controller.js | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js index 468a2f3829e3..5c589b55bd86 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js @@ -89,9 +89,7 @@ angular.module("umbraco") template.sections.push(section); } - if (section.allowAll && (!section.allowed || !section.allowed.length)) { - section.allowAll = true; - } + section.allowAll = section.allowAll || !section.allowed || !section.allowed.length; $scope.currentSection = section; } diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js index 7e7f63470a12..b36352a66bfb 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/rowconfig.controller.js @@ -87,9 +87,7 @@ function RowConfigController($scope, localizationService) { $scope.editors.forEach(function (e) { e.allowed = cell.allowed.indexOf(e.alias) !== -1 }); - if (cell.allowAll && (!cell.allowed || !cell.allowed.length)) { - cell.allowAll = true; - } + cell.allowAll = cell.allowAll || !cell.allowed || !cell.allowed.length; $scope.currentCell = cell; } From 786c561048e12b54214c57b079cb4dcd3836a7c6 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Wed, 24 Feb 2021 00:54:04 +0100 Subject: [PATCH 11/12] Remove vm.layout again --- .../propertyeditors/grid/dialogs/layoutconfig.controller.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js index 5c589b55bd86..9ada334da7e7 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js @@ -15,9 +15,6 @@ angular.module("umbraco") vm.submit = submit; vm.labels = {}; - vm.layout = { - sections: [] - }; function init() { From ca4d43d28a8ce537a61eae35688a3fc0cc9cc494 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 6 May 2021 16:50:47 +0200 Subject: [PATCH 12/12] copy rows when adding new section + clean up rows on submit and close --- .../grid/dialogs/layoutconfig.controller.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js index 9ada334da7e7..fdf70693b2ef 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/dialogs/layoutconfig.controller.js @@ -81,7 +81,7 @@ angular.module("umbraco") var space = ($scope.availableLayoutSpace > 4) ? 4 : $scope.availableLayoutSpace; section = { grid: space, - rows: [] + rows: Utilities.copy($scope.rows) }; template.sections.push(section); } @@ -127,22 +127,26 @@ angular.module("umbraco") function close() { if ($scope.model.close) { + cleanUpRows(); $scope.model.close(); } } function submit() { if ($scope.model.submit) { - - // Delete temporary rows configurated in init. - if ($scope.currentLayout.rows) { - delete $scope.currentLayout.rows; - } - + cleanUpRows(); $scope.model.submit($scope.currentLayout); } } + function cleanUpRows () { + $scope.currentLayout.sections.forEach(section => { + if (section.rows) { + delete section.rows; + } + }); + } + $scope.$watch("currentLayout", function(layout){ if (layout) { var total = 0;