Closed bielu closed 11 months ago
Hi Kevin, I noticed that migration for Block Grid expect ConfigAsString to be populated, but after comparing usync for v7:
<PreValue SortOrder="1" Alias="items"><![CDATA[{ "styles": [], "config": [], "columns": 1, "templates": [ { "name": "Full Width", "sections": [ { "grid": 1, "allowAll": false, "allowed": [ "Full Width" ] } ] } ], "layouts": [ { "name": "Full Width", "areas": [ { "grid": 1, "maxItems": 0, "allowAll": false, "allowed": [ "rte", ] } ], "label": "Content" }, { "name": "test", "areas": [] } ] }]]></PreValue> <PreValue SortOrder="2" Alias="rte"><![CDATA[{ "toolbar": [ "code", "styleselect", "bold", "italic", "alignleft", "aligncenter", "alignright", "bullist", "numlist", "outdent", "indent", "link", "umbmediapicker", "umbmacro", "umbembeddialog" ], "stylesheets": [ "editor" ], "dimensions": { "height": 0 }, "maxImageSize": 0 }]]></PreValue> <PreValue SortOrder="3" Alias="ignoreUserStartNodes"><![CDATA[0]]></PreValue> </PreValues>
and v8:
"Items": { "styles": [ { "label": "Set a background image", "description": "Set a row background", "key": "background-image", "view": "imagepicker", "modifier": "url({0})" } ], "config": [ { "label": "Class", "description": "Set a css class", "key": "class", "view": "textstring" } ], "columns": 12, "templates": [ { "name": "1 column layout", "sections": [ { "grid": 12 } ] }, { "name": "2 column layout", "sections": [ { "grid": 4 }, { "grid": 8 } ] } ], "layouts": [ { "label": "Headline", "name": "Headline", "areas": [ { "grid": 12, "editors": [ "headline" ] } ] }, { "label": "Article", "name": "Article", "areas": [ { "grid": 4 }, { "grid": 8 } ] } ] }, "Rte": { "toolbar": [ "ace", "styleselect", "bold", "italic", "alignleft", "aligncenter", "alignright", "bullist", "numlist", "outdent", "indent", "link", "umbmediapicker", "umbmacro", "umbembeddialog" ], "stylesheets": [], "maxImageSize": 500, "mode": "classic" }, "IgnoreUserStartNodes": false, "MediaParentId": null }]]></Config>
i came with hacky solution, to modify SyncMigrationDataTypeProperty(string dataTypeAlias, string editorAlias, string databaseType, IList<PreValue> preValues) to also translate prevalues in following way:
SyncMigrationDataTypeProperty(string dataTypeAlias, string editorAlias, string databaseType, IList<PreValue> preValues)
public SyncMigrationDataTypeProperty(string dataTypeAlias, string editorAlias, string databaseType, IList<PreValue> preValues) : base(editorAlias) { DatabaseType = databaseType; DataTypeAlias = dataTypeAlias; PreValues = new ReadOnlyCollection<PreValue>(preValues); ConfigAsString = TranslatePreValuesToConfig(preValues); } private string? TranslatePreValuesToConfig(IList<PreValue> preValues) { var json = new Dictionary<string, object>(); foreach (var oPreValue in preValues) { json.TryAdd(oPreValue.Alias, oPreValue.Value.ToString().DetectIsJson() ? JsonConvert.DeserializeObject(oPreValue.Value) : oPreValue); } return JsonConvert.SerializeObject(json); }
which works great, but not sure if we want introduce this type of code there as it add responsibility to class and we break KISS
@KevinJump if you are okay with solution I will submit pr :)
Closing as resolved for now.
Hi Kevin, I noticed that migration for Block Grid expect ConfigAsString to be populated, but after comparing usync for v7:
and v8:
i came with hacky solution, to modify
SyncMigrationDataTypeProperty(string dataTypeAlias, string editorAlias, string databaseType, IList<PreValue> preValues)
to also translate prevalues in following way:which works great, but not sure if we want introduce this type of code there as it add responsibility to class and we break KISS