@@ -133,7 +133,7 @@ private void Map(DocumentTypeSave source, IContentType target, MapperContext con
133
133
134
134
if ( target is IContentTypeWithHistoryCleanup targetWithHistoryCleanup )
135
135
{
136
- targetWithHistoryCleanup . HistoryCleanup = source . HistoryCleanup ;
136
+ MapHistoryCleanup ( source , targetWithHistoryCleanup ) ;
137
137
}
138
138
139
139
target . AllowedTemplates = source . AllowedTemplates
@@ -147,6 +147,34 @@ private void Map(DocumentTypeSave source, IContentType target, MapperContext con
147
147
: _fileService . GetTemplate ( source . DefaultTemplate ) ) ;
148
148
}
149
149
150
+ private static void MapHistoryCleanup ( DocumentTypeSave source , IContentTypeWithHistoryCleanup target )
151
+ {
152
+ // If source history cleanup is null we don't have to map all properties
153
+ if ( source . HistoryCleanup is null )
154
+ {
155
+ target . HistoryCleanup = null ;
156
+ return ;
157
+ }
158
+
159
+ // We need to reset the dirty properties, because it is otherwise true, just because the json serializer has set properties
160
+ target . HistoryCleanup . ResetDirtyProperties ( false ) ;
161
+ if ( target . HistoryCleanup . PreventCleanup != source . HistoryCleanup . PreventCleanup )
162
+ {
163
+ target . HistoryCleanup . PreventCleanup = source . HistoryCleanup . PreventCleanup ;
164
+ }
165
+
166
+ if ( target . HistoryCleanup . KeepAllVersionsNewerThanDays != source . HistoryCleanup . KeepAllVersionsNewerThanDays )
167
+ {
168
+ target . HistoryCleanup . KeepAllVersionsNewerThanDays = source . HistoryCleanup . KeepAllVersionsNewerThanDays ;
169
+ }
170
+
171
+ if ( target . HistoryCleanup . KeepLatestVersionPerDayForDays !=
172
+ source . HistoryCleanup . KeepLatestVersionPerDayForDays )
173
+ {
174
+ target . HistoryCleanup . KeepLatestVersionPerDayForDays = source . HistoryCleanup . KeepLatestVersionPerDayForDays ;
175
+ }
176
+ }
177
+
150
178
// no MapAll - take care
151
179
private void Map ( MediaTypeSave source , IMediaType target , MapperContext context )
152
180
{
@@ -328,7 +356,10 @@ private static void Map(PropertyTypeBasic source, IPropertyType target, MapperCo
328
356
329
357
if ( source . GroupId > 0 )
330
358
{
331
- target . PropertyGroupId = new Lazy < int > ( ( ) => source . GroupId , false ) ;
359
+ if ( target . PropertyGroupId ? . Value != source . GroupId )
360
+ {
361
+ target . PropertyGroupId = new Lazy < int > ( ( ) => source . GroupId , false ) ;
362
+ }
332
363
}
333
364
334
365
target . Alias = source . Alias ;
@@ -523,7 +554,15 @@ private static void MapSaveToTypeBase<TSource, TSourcePropertyType>(TSource sour
523
554
target . Thumbnail = source . Thumbnail ;
524
555
525
556
target . AllowedAsRoot = source . AllowAsRoot ;
526
- target . AllowedContentTypes = source . AllowedContentTypes . Select ( ( t , i ) => new ContentTypeSort ( t , i ) ) ;
557
+
558
+ bool allowedContentTypesUnchanged = target . AllowedContentTypes . Select ( x => x . Id . Value )
559
+ . SequenceEqual ( source . AllowedContentTypes ) ;
560
+
561
+ if ( allowedContentTypesUnchanged is false )
562
+ {
563
+ target . AllowedContentTypes = source . AllowedContentTypes . Select ( ( t , i ) => new ContentTypeSort ( t , i ) ) ;
564
+ }
565
+
527
566
528
567
if ( ! ( target is IMemberType ) )
529
568
{
@@ -574,13 +613,21 @@ private static void MapSaveToTypeBase<TSource, TSourcePropertyType>(TSource sour
574
613
575
614
// ensure no duplicate alias, then assign the group properties collection
576
615
EnsureUniqueAliases ( destProperties ) ;
577
- destGroup . PropertyTypes = new PropertyTypeCollection ( isPublishing , destProperties ) ;
616
+ if ( destGroup . PropertyTypes . SupportsPublishing != isPublishing || destGroup . PropertyTypes . SequenceEqual ( destProperties ) is false )
617
+ {
618
+ destGroup . PropertyTypes = new PropertyTypeCollection ( isPublishing , destProperties ) ;
619
+ }
620
+
578
621
destGroups . Add ( destGroup ) ;
579
622
}
580
623
581
624
// ensure no duplicate name, then assign the groups collection
582
625
EnsureUniqueAliases ( destGroups ) ;
583
- target . PropertyGroups = new PropertyGroupCollection ( destGroups ) ;
626
+
627
+ if ( target . PropertyGroups . SequenceEqual ( destGroups ) is false )
628
+ {
629
+ target . PropertyGroups = new PropertyGroupCollection ( destGroups ) ;
630
+ }
584
631
585
632
// because the property groups collection was rebuilt, there is no need to remove
586
633
// the old groups - they are just gone and will be cleared by the repository
0 commit comments