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

Commit 32cca26

Browse files
author
Arnold Visser
committed
WIP Trying some fixes to make this work on V8
1 parent f3fec97 commit 32cca26

File tree

4 files changed

+41
-81
lines changed

4 files changed

+41
-81
lines changed

src/Our.Umbraco.DocTypeGridEditor/Helpers/DocTypeGridEditorHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public DocTypeGridEditorHelper(IUmbracoContextAccessor umbracoContext)
2424
_umbracoContext = umbracoContext;
2525
}
2626

27-
public IPublishedContent ConvertValueToContent(string id, string contentTypeAlias, string dataJson)
27+
public IPublishedElement ConvertValueToContent(string id, string contentTypeAlias, string dataJson)
2828
{
2929
if (string.IsNullOrWhiteSpace(contentTypeAlias))
3030
return null;
@@ -43,7 +43,7 @@ public IPublishedContent ConvertValueToContent(string id, string contentTypeAlia
4343
});
4444
}
4545

46-
private static IPublishedContent ConvertValue(string id, string contentTypeAlias, string dataJson)
46+
private static IPublishedElement ConvertValue(string id, string contentTypeAlias, string dataJson)
4747
{
4848
using (Current.ProfilingLogger.DebugDuration<DocTypeGridEditorHelper>(string.Format("ConvertValue ({0}, {1})", id, contentTypeAlias)))
4949
{
@@ -75,7 +75,7 @@ private static IPublishedContent ConvertValue(string id, string contentTypeAlias
7575
/* Now that we have the DB stored value, we actually need to then convert it into its
7676
* XML serialized state as expected by the published property by calling ConvertDbToString
7777
*/
78-
var propType2 = contentTypes.ContentType.CompositionPropertyTypes.First(x => x.Alias.InvariantEquals(propType.DataType.EditorAlias));
78+
var propType2 = contentTypes.ContentType.CompositionPropertyTypes.First(x => x.PropertyEditorAlias.InvariantEquals(propType.DataType.EditorAlias));
7979

8080
// TODO: Do we still need this weird tag conversion?
8181
//Property prop2 = null;

src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorApiController.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public DocTypeGridEditorApiController(IUmbracoContextAccessor umbracoContext,
4141
{
4242
_umbracoContext = umbracoContext;
4343
_contentTypeService = contentTypeService;
44-
this._dataTypeService = dataTypeService;
45-
this._contentCache = contentCache;
44+
_dataTypeService = dataTypeService;
45+
_contentCache = contentCache;
4646
}
4747

4848
[HttpGet]
@@ -90,9 +90,9 @@ public object GetContentTypeIcon([ModelBinder] string contentTypeAlias)
9090
{
9191
Guid docTypeGuid;
9292
if (Guid.TryParse(contentTypeAlias, out docTypeGuid))
93-
contentTypeAlias = Services.ContentTypeService.GetAliasByGuid(docTypeGuid);
93+
contentTypeAlias = Current.Services.ContentTypeService.GetAliasByGuid(docTypeGuid);
9494

95-
var contentType = _contentTypeService.Get(contentTypeAlias);
95+
var contentType = Current.Services.ContentTypeService.Get(contentTypeAlias);
9696
return new
9797
{
9898
icon = contentType != null ? contentType.Icon : string.Empty
@@ -146,7 +146,7 @@ public HttpResponseMessage GetPreviewMarkup([FromBody] PreviewData data, [FromUr
146146
if (pageId > 0)
147147
{
148148
// Get page container node
149-
page = _contentCache.GetById(pageId);
149+
page = Umbraco.Content(pageId);
150150
if (page == null)
151151
{
152152
// If unpublished, then fake PublishedContent
@@ -174,9 +174,12 @@ public HttpResponseMessage GetPreviewMarkup([FromBody] PreviewData data, [FromUr
174174
// Set the culture for the preview
175175
if (page != null)
176176
{
177-
var culture = new CultureInfo(page.GetCulture().Culture);
178-
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
179-
System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
177+
if (page.GetCulture() != null)
178+
{
179+
var culture = new CultureInfo(page.GetCulture().Culture);
180+
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
181+
System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
182+
}
180183
}
181184

182185
// Get content node object

src/Our.Umbraco.DocTypeGridEditor/Web/Models/PreviewModel.cs

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
namespace Our.Umbraco.DocTypeGridEditor.Web
66
{
7-
public class PreviewModel : IPublishedContent
7+
public class PreviewModel : IPublishedElement
88
{
99
public IPublishedContent Page { get; set; }
1010

11-
public IPublishedContent Item { get; set; }
11+
public IPublishedElement Item { get; set; }
1212

1313
public string EditorAlias { get; set; }
1414

@@ -26,50 +26,6 @@ public class PreviewModel : IPublishedContent
2626

2727
public IEnumerable<IPublishedProperty> Properties => Item.Properties;
2828

29-
public string GetUrl(string culture = null) => Item.GetUrl(culture);
30-
31-
public PublishedCultureInfo GetCulture(string culture = null) => Item.GetCulture(culture);
32-
33-
public bool IsDraft(string culture = null) => Item.IsDraft(culture);
34-
35-
public bool IsPublished(string culture = null) => Item.IsPublished(culture);
36-
37-
public int Id => Item.Id;
38-
39-
public string Name => Item.Name;
40-
41-
public string UrlSegment => Item.UrlSegment;
42-
43-
public int SortOrder => Item.SortOrder;
44-
45-
public int Level => Item.Level;
46-
47-
public string Path => Item.Path;
48-
49-
public int? TemplateId => Item.TemplateId;
50-
51-
public int CreatorId => Item.CreatorId;
52-
53-
public string CreatorName => Item.CreatorName;
54-
55-
public DateTime CreateDate => Item.CreateDate;
56-
57-
public int WriterId => Item.WriterId;
58-
59-
public string WriterName => Item.WriterName;
60-
61-
public DateTime UpdateDate => Item.UpdateDate;
62-
63-
public string Url => Item.Url;
64-
65-
public IReadOnlyDictionary<string, PublishedCultureInfo> Cultures => Item.Cultures;
66-
67-
public PublishedItemType ItemType => Item.ItemType;
68-
69-
public IPublishedContent Parent => Item.Parent;
70-
71-
public IEnumerable<IPublishedContent> Children => Item.Children;
72-
7329
#endregion
7430
}
7531
}

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

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,18 @@
8282
name: newModel.editorName
8383
};
8484

85-
for (var t = 0; t < newModel.node.tabs.length; t++) {
86-
var tab = newModel.node.tabs[t];
87-
for (var p = 0; p < tab.properties.length; p++) {
88-
var prop = tab.properties[p];
89-
if (typeof prop.value !== "function") {
90-
value[prop.alias] = prop.value;
91-
}
92-
}
93-
}
85+
for (var v = 0; v < newModel.node.variants.length; v++) {
86+
var variant = newModel.node.variants[v];
87+
for (var t = 0; t < variant.tabs.length; t++) {
88+
var tab = variant.tabs[t];
89+
for (var p = 0; p < tab.properties.length; p++) {
90+
var prop = tab.properties[p];
91+
if (typeof prop.value !== "function") {
92+
value[prop.alias] = prop.value;
93+
}
94+
}
95+
}
96+
}
9497

9598
if (newModel.nameExp) {
9699
var newName = newModel.nameExp(value); // Run it against the stored dictionary value, NOT the node object
@@ -222,23 +225,21 @@ angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.Dialogs.DocT
222225

223226
function loadNode() {
224227
contentResource.getScaffold(-20, $scope.model.dialogData.docTypeAlias).then(function (data) {
225-
226-
if (dtgeUtilityService.compareCurrentUmbracoVersion("7.8", { zeroExtend: true }) < 0) {
227-
// Remove the "Generic properties" tab (removed in v7.8)
228-
data.tabs.pop();
229-
}
230-
228+
231229
// Merge current value
232230
if ($scope.model.dialogData.value) {
233-
for (var t = 0; t < data.tabs.length; t++) {
234-
var tab = data.tabs[t];
235-
for (var p = 0; p < tab.properties.length; p++) {
236-
var prop = tab.properties[p];
237-
if ($scope.model.dialogData.value[prop.alias]) {
238-
prop.value = $scope.model.dialogData.value[prop.alias];
239-
}
240-
}
241-
}
231+
for (var v = 0; v < data.variants.length; v++) {
232+
var variant = data.variants[v];
233+
for (var t = 0; t < variant.tabs.length; t++) {
234+
var tab = variant.tabs[t];
235+
for (var p = 0; p < tab.properties.length; p++) {
236+
var prop = tab.properties[p];
237+
if ($scope.model.dialogData.value[prop.alias]) {
238+
prop.value = $scope.model.dialogData.value[prop.alias];
239+
}
240+
}
241+
}
242+
}
242243
};
243244

244245
// Assign the model to scope

0 commit comments

Comments
 (0)