Skip to content
This repository was archived by the owner on Feb 10, 2024. It is now read-only.

Commit f594eb3

Browse files
committed
Ensure an empty DTGE without ContentType Alias is not persisted, without removing other editors
1 parent 7715ce0 commit f594eb3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@
9393
id: $scope.control.value.id
9494
};
9595
overlayOptions.close = function () {
96-
// ensure an empty doctype is not persisted
97-
if($scope.control.$initializing){
98-
$scope.removeControl($scope.area, $scope.control.$index -1);
96+
// ensure an empty DTGE without ContentType Alias is not persisted
97+
if ($scope.control.value && $scope.control.value.dtgeContentTypeAlias === "") {
98+
let indexOfThis = $scope.area.controls.map(function (control) { return control.$uniqueId }).indexOf($scope.control.$uniqueId);
99+
if (indexOfThis > -1) {
100+
$scope.removeControl($scope.area, indexOfThis);
101+
}
99102
}
100103

101104
editorService.close();

0 commit comments

Comments
 (0)