Skip to content

Commit

Permalink
copy rows when adding new section + clean up rows on submit and close
Browse files Browse the repository at this point in the history
  • Loading branch information
madsrasmussen committed May 6, 2021
1 parent 45e2254 commit ca4d43d
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ca4d43d

Please sign in to comment.