Skip to content

Commit ce8e258

Browse files
authored
Make sure listviews are initialized correctly in a new DB (#16418)
1 parent 57cca63 commit ce8e258

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/Umbraco.Infrastructure/Migrations/Install/DatabaseDataCreator.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,7 @@ private void CreateContentTypeData()
10621062
Thumbnail = Constants.Icons.MediaFolder,
10631063
AllowAtRoot = true,
10641064
Variations = (byte)ContentVariation.Nothing,
1065+
ListView = Constants.DataTypes.Guids.ListViewMediaGuid
10651066
});
10661067
}
10671068

@@ -1886,11 +1887,13 @@ void InsertDataTypeDto(int id, string editorAlias, string editorUiAlias, string
18861887
}
18871888

18881889
// layouts for the list view
1889-
const string cardLayout =
1890-
"{\"name\": \"Grid\",\"path\": \"views/propertyeditors/listview/layouts/grid/grid.html\", \"icon\": \"icon-thumbnails-small\", \"isSystem\": true, \"selected\": true}";
1891-
const string listLayout =
1892-
"{\"name\": \"List\",\"path\": \"views/propertyeditors/listview/layouts/list/list.html\",\"icon\": \"icon-list\", \"isSystem\": true,\"selected\": true}";
1893-
const string layouts = "[" + cardLayout + "," + listLayout + "]";
1890+
string TableCollectionView(string collectionViewType) =>
1891+
$"{{\"name\": \"List\",\"collectionView\": \"Umb.CollectionView.{collectionViewType}.Table\", \"icon\": \"icon-list\", \"isSystem\": true, \"selected\": true}}";
1892+
1893+
string GridCollectionView(string collectionViewType) =>
1894+
$"{{\"name\": \"Grid\",\"collectionView\": \"Umb.CollectionView.{collectionViewType}.Grid\",\"icon\": \"icon-thumbnails-small\", \"isSystem\": true,\"selected\": true}}";
1895+
1896+
string Layouts(string collectionViewType) => $"[{GridCollectionView(collectionViewType)},{TableCollectionView(collectionViewType)}]";
18941897

18951898
// Insert data types only if the corresponding Node record exists (which may or may not have been created depending on configuration
18961899
// of data types to create).
@@ -2094,7 +2097,7 @@ void InsertDataTypeDto(int id, string editorAlias, string editorUiAlias, string
20942097
DbType = "Nvarchar",
20952098
Configuration =
20962099
"{\"pageSize\":100, \"orderBy\":\"updateDate\", \"orderDirection\":\"desc\", \"layouts\":" +
2097-
layouts +
2100+
Layouts("Document") +
20982101
", \"includeProperties\":[{\"alias\":\"updateDate\",\"header\":\"Last edited\",\"isSystem\":true},{\"alias\":\"creator\",\"header\":\"Updated by\",\"isSystem\":true}]}",
20992102
});
21002103
}
@@ -2113,7 +2116,7 @@ void InsertDataTypeDto(int id, string editorAlias, string editorUiAlias, string
21132116
DbType = "Nvarchar",
21142117
Configuration =
21152118
"{\"pageSize\":100, \"orderBy\":\"updateDate\", \"orderDirection\":\"desc\", \"layouts\":" +
2116-
layouts +
2119+
Layouts("Media") +
21172120
", \"includeProperties\":[{\"alias\":\"updateDate\",\"header\":\"Last edited\",\"isSystem\":true},{\"alias\":\"creator\",\"header\":\"Updated by\",\"isSystem\":true}]}",
21182121
});
21192122
}

0 commit comments

Comments
 (0)