93
93
id : $scope . control . value . id
94
94
} ;
95
95
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
+ }
99
102
}
100
103
101
104
editorService . close ( ) ;
102
105
}
103
106
overlayOptions . submit = function ( newModel ) {
104
107
105
- // Copy property values to scope model value
106
- if ( newModel . node ) {
107
- var value = {
108
- name : newModel . editorName
109
- } ;
110
-
111
- for ( var v = 0 ; v < newModel . node . variants . length ; v ++ ) {
112
- var variant = newModel . node . variants [ v ] ;
113
- for ( var t = 0 ; t < variant . tabs . length ; t ++ ) {
114
- var tab = variant . tabs [ t ] ;
115
- for ( var p = 0 ; p < tab . properties . length ; p ++ ) {
116
- var prop = tab . properties [ p ] ;
117
- if ( typeof prop . value !== "function" ) {
118
- value [ prop . alias ] = prop . value ;
119
- }
120
- }
121
- }
122
- }
108
+ // Copy property values to scope model value
109
+ if ( newModel . node ) {
110
+ var value = {
111
+ name : newModel . editorName
112
+ } ;
123
113
124
- if ( newModel . nameExp ) {
125
- var newName = newModel . nameExp ( value ) ; // Run it against the stored dictionary value, NOT the node object
126
- if ( newName && ( newName = $ . trim ( newName ) ) ) {
127
- value . name = newName ;
114
+ for ( var v = 0 ; v < newModel . node . variants . length ; v ++ ) {
115
+ var variant = newModel . node . variants [ v ] ;
116
+ for ( var t = 0 ; t < variant . tabs . length ; t ++ ) {
117
+ var tab = variant . tabs [ t ] ;
118
+ for ( var p = 0 ; p < tab . properties . length ; p ++ ) {
119
+ var prop = tab . properties [ p ] ;
120
+ if ( typeof prop . value !== "function" ) {
121
+ value [ prop . alias ] = prop . value ;
128
122
}
129
123
}
124
+ }
125
+ }
130
126
131
- newModel . dialogData . value = value ;
132
- } else {
133
- newModel . dialogData . value = null ;
134
-
127
+ if ( newModel . nameExp ) {
128
+ var newName = newModel . nameExp ( value ) ; // Run it against the stored dictionary value, NOT the node object
129
+ if ( newName && ( newName = $ . trim ( newName ) ) ) {
130
+ value . name = newName ;
135
131
}
132
+ }
136
133
137
- $scope . setValue ( {
138
- dtgeContentTypeAlias : newModel . dialogData . docTypeAlias ,
139
- value : newModel . dialogData . value ,
140
- id : newModel . dialogData . id
141
- } ) ;
142
- $scope . setPreview ( $scope . control . value ) ;
143
- editorService . close ( ) ;
134
+ newModel . dialogData . value = value ;
135
+ } else {
136
+ newModel . dialogData . value = null ;
137
+
138
+ }
139
+
140
+ $scope . setValue ( {
141
+ dtgeContentTypeAlias : newModel . dialogData . docTypeAlias ,
142
+ value : newModel . dialogData . value ,
143
+ id : newModel . dialogData . id
144
+ } ) ;
145
+ $scope . setPreview ( $scope . control . value ) ;
146
+ editorService . close ( ) ;
144
147
} ;
145
148
146
149
editorService . open ( overlayOptions ) ;
@@ -244,7 +247,7 @@ angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.Dialogs.DocT
244
247
vm . blueprintConfig = blueprintConfig ;
245
248
246
249
function cleanup ( ) {
247
- if ( $scope . model . node . id > 0 ) {
250
+ if ( $scope . model . node && $scope . model . node . id > 0 ) {
248
251
// delete any temporary blueprints used for validation
249
252
contentResource . deleteBlueprint ( $scope . model . node . id ) ;
250
253
}
@@ -268,15 +271,15 @@ angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.Dialogs.DocT
268
271
content : $scope . model . node ,
269
272
create : true ,
270
273
action : "save" ,
271
- showNotifications : true ,
274
+ showNotifications : false ,
272
275
softRedirect : true
273
276
}
274
277
275
278
contentEditingHelper . contentEditorPerformSave ( args ) . then ( function ( data ) {
276
- $scope . model . submit ( $scope . model ) ;
277
- } ,
279
+ $scope . model . submit ( $scope . model ) ;
280
+ } ,
278
281
function ( err ) {
279
-
282
+
280
283
} ) ;
281
284
}
282
285
}
0 commit comments