142 | ```
143 |
144 | Because we treat your data as a standard `IPublishedElement` entity, that means you can use all the property value converters you are used to using.
145 |
146 | ```
147 | @inherits UmbracoViewPage
148 |
@Model.Name
149 | @Model.Value("bodyText")
150 | More
151 | ```
152 |
153 | Doc Type Grid Editor also supports ModelsBuilder, so you can simplify your views like this:
154 | ```
155 | @inherits UmbracoViewPage
156 |
@Model.Name
157 | @Model.BodyText
158 | More
159 | ```
160 |
161 | 
162 |
163 |
164 | #### Rendering Alternative Preview Content
165 |
166 | If your front end view is rather complex, you may decide that you want to feed the back office preview an alternative, less complex view. To do this, you can use the `PreviewViewPath` setting on your grid editor, and place a view named after your document type there. **Doc Type Grid Editor** will use the preview view file, when rendering previews in the backoffice.
167 |
168 | If you don't want to have a seperate preview view file, you can add preview logic within your Razor view/partial. Check for a querystring parameter `dtgePreview` being set to "1" to detect being in preview mode to provide an alternative view.
169 |
170 | ```
171 | @inherits UmbracoViewPage
172 | @if (Request.QueryString["dtgePreview"] == "1")
173 | {
174 | // Render preview view
175 | }
176 | else
177 | {
178 | // Render front end view
179 | }
180 | ```
181 |
182 | #### DocTypeGridEditorSurfaceController
183 |
184 | If you are not the type of developer that likes to put business logic in your views, then the ability to have a controller for you partial view is a must. To help with this, the **Doc Type Grid Editor** comes with a base surface controller you can used called `DocTypeGridEditorSurfaceController`.
185 |
186 | Simply create your controller inheriting from the above class, giving it a class name of `{DocTypeAlias}SurfaceController` and an action name of `{DocTypeAlias}` and the **Doc Type Grid Editor** will automatically wire it up for you and use it at render time.
187 |
188 | ```csharp
189 | public class TestDocTypeSurfaceController
190 | : DocTypeGridEditorSurfaceController
191 | {
192 | public ActionResult TestDocType()
193 | {
194 | // Do your thing...
195 | return CurrentPartialView();
196 | }
197 | }
198 | ```
199 |
200 | By inheriting from the `DocTypeGridEditorSurfaceController` base class, you'll also have instant access to the following helper properties / methods.
201 |
202 | | Member | Type | Description |
203 | |---------------------------------------------------|-------------------|-------------|
204 | | Model | IPublishedElement | The IPublishedElement instance of your cell's data. |
205 | | ViewPath | String | A reference to the currently configured ViewPath |
206 | | CurrentPartialView(object model = null) | Method | Helper method to return you to the default partial view for this cell. If no model is passed in, the standard Model will be passed down. |
207 | | PartialView(string viewName, object model = null) | Method | Helper method to return you to an alternative partial view for this cell. If no model is passed in, the standard Model will be passed down. |
208 |
209 | ---
210 |
211 | ### Value Processors
212 | Since Doc Type Grid Editor stores the data for each property as a JSON-blob, we're not processing the values in the same way as Umbraco-core before storing it. This also means that the values that comes back and are passed into a Property Value Converter might be in of a type/format that that Property Value Convert can't handle.
213 |
214 | We've added something that we call "ValueProcessors" and these can be used to modify the raw property value before we send it to the property value converter. One example of where this is needed is the Tags-editor.
215 |
216 | If you need to perform some processing of a value before it's sent to the property value converter you can add your own ValueProcessor.
217 |
218 | ```csharp
219 | public class UmbracoColorPickerValueProcessor : IDocTypeGridEditorValueProcessor
220 | {
221 | public bool IsProcessorFor(string propertyEditorAlias)
222 | => propertyEditorAlias.Equals(Constants.PropertyEditors.Aliases.ColorPicker);
223 |
224 | public object ProcessValue(object value)
225 | {
226 | // Do something with the value
227 | return value;
228 | }
229 | }
230 | ```
231 |
232 | Then register this during composition withing IUserComposer,
233 | ```csharp
234 | public class MyCustomDocTypeGridEditorComposer : IUserComposer
235 | {
236 | public void Compose(Composition composition)
237 | {
238 | composition.DocTypeGridEditorValueProcessors()
239 | .Append();
240 | }
241 | }
242 | ```
243 |
244 | Dot Type Grid editor ships with a ValueProcessor for the Umbraco-Tags property.
245 |
246 | **Note:** When using a Tag-editor inside a DTGE this would not create any relationship between the current node and that tag, if you need to tag a node you should use the Tags-editor as a property directly on the document type.
247 |
248 |
249 |
250 |
251 |
252 | ### Useful Links
253 |
254 | * [Source Code](https://github.com/skttl/umbraco-doc-type-grid-editor)
255 | * [Our Umbraco Project Page](http://our.umbraco.org/projects/backoffice-extensions/doc-type-grid-editor)
256 |
--------------------------------------------------------------------------------
/docs/developers-guide-v2.md:
--------------------------------------------------------------------------------
1 | # Doc Type Grid Editor 2 - Developers Guide
2 |
3 | ### Contents
4 |
5 | 1. [Introduction](#introduction)
6 | 2. [Getting Set Up](#getting-set-up)
7 | 1. [System Requirements](#system-requirements)
8 | 3. [Configuring The Doc Type Grid Editor](#configuring-the-doc-type-grid-editor)
9 | 4. [Hooking Up The Doc Type Grid Editor](#hooking-up-the-doc-type-grid-editor)
10 | 5. [Rendering a Doc Type Grid Editor](#rendering-a-doc-type-grid-editor)
11 | 1. [Rendering Alternative Preview Content](#rendering-alternative-preview-content)
12 | 2. [DocTypeGridEditorSurfaceController](#doctypegrideditorsurfacecontroller)
13 | 6. [Value Processors](#value-processors)
14 | 7. [Useful Links](#useful-links)
15 |
16 | ---
17 |
18 | ### Introduction
19 |
20 | **Doc Type Grid Editor** is an advanced grid editor for the Umbraco grid, offering similar functionality as the macro grid editor but using the full power of the Doc Type editor and data types.
21 |
22 | With the macro grid editor you are limited to only using the macro builder and thus the handful of parameter editors that are available. Of course you can create / config your own parameter editors, however this is cumbersome compared to how we can configure data types.
23 |
24 | With the **Doc Type Grid Editor** then, we bridge that gap, allowing you to reuse doc type definitions as blue prints for complex data to be rendered in a grid cell.
25 |
26 | ---
27 |
28 | ### Getting Set Up
29 |
30 | #### System Requirements
31 |
32 | Before you get started, there are a number of things you will need:
33 |
34 | 1. .NET 5+
35 | 2. Umbraco 9.0.0+
36 | 3. The **Doc Type Grid Editor** package installed
37 |
38 | ---
39 |
40 | ### Configuring The Doc Type Grid Editor
41 |
42 | The **Doc Type Grid Editor** is configured via package.manifest files located in `~/App_Plugins/*`. A default configuration is installed along with the package in `~/App_Plugins/DocTypeGridEditor/package.manifest`. If you want to add your own editor configurations you can create your own package manifest file with the gridEditor config values (somewhere like `~/App_Plugins/DocTypeGridEditor.CustomEditors/package.manifest`). For details on the configuration options, please see below.
43 |
44 | #### Example
45 |
46 | ```javascript
47 | [
48 | ...
49 | {
50 | "name": "Doc Type",
51 | "alias": "docType",
52 | "view": "/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.html",
53 | "render": "/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml",
54 | "icon": "icon-item-arrangement",
55 | "config": {
56 | "allowedDocTypes": [...],
57 | "nameTemplate": "",
58 | "enablePreview": true,
59 | "overlaySize": "medium",
60 | "viewPath": "/Views/Partials/Grid/Editors/DocTypeGridEditor/",
61 | "previewViewPath": "/Views/Partials/Grid/Editors/DocTypeGridEditor/Previews/",
62 | "previewCssFilePath": "",
63 | "previewJsFilePath": ""
64 | }
65 | },
66 | ...
67 | ]
68 | ```
69 |
70 | For the main part, the root properties shouldn’t need to be modified, however the only properties that MUST not be changed are the **view** and **render** properties.
71 |
72 | | Member | Type | Description |
73 | |--------|--------|-------------|
74 | | Name | String | The name of the grid editor as it appears in the grid editor prevalue editor / selector screen. |
75 | | Alias | String | A unique alias for this grid editor. |
76 | | View | String | The path to the **Doc Type Grid Editor** editor view. **MUST NOT BE CHANGED**. |
77 | | Render | String | The path to the **Doc Type Grid Editor** render view. **MUST NOT BE CHANGED**. |
78 | | Icon | String | The icon class name to use for this grid editor (minus the '.') |
79 | | Config | Object | Config options for this grid editor. |
80 |
81 | The **Doc Type Grid Editor** supports 3 config options, all of which are optional.
82 |
83 | | Member | Type | Description |
84 | |-----------------|----------|-------------|
85 | | AllowedDocTypes | String[] | An array of doc type aliases of which should be allowed to be selected in the grid editor. By default Strings are REGEX patterns to allow matching groups of doc types in a single entry. e.g. "widgetAlias" will match all doc types with an alias starting in "widgetAlias". By adding "$" to the end of the string you can stop this behaviour e.g. "widgetAlias$" will only match a doc type with an alias of "widgetAlias". However if a single doc type is matched, (aka **Single Doc Type Mode**), then doc type selection stage (in the DTGE panel) will be skipped. Note, your document type must be an Element type, in order to be usable in DTGE. |
86 | | NameTemplate | String | Allows using any of the doctype's property values in the name/label: {{propertyAlias}} |
87 | | EnablePreview | Boolean | Enables rendering a preview of the grid cell in the grid editor. |
88 | | overlaySize | String | Define the size of the grid editor dialog. You can write `large`, `medium` or `small`. If no size is set, the grid editor dialog will be small. Note, the medium size requires a minimum Umbraco version of 8.3 |
89 | | LargeDialog | Boolean | (obsolete, use overlaySize instead) Makes the editing dialog larger. Especially useful for grid editors with complex property editors. |
90 | | size | string | (obsolete, use overlaySize instead)
91 | | ViewPath | String | Sets an alternative view path for where the **Doc Type Grid Editor** should look for views when rendering. Defaults to `~/Views/Partials/` |
92 | | PreviewViewPath | String | Sets an alternative view path for where the **Doc Type Grid Editor** should look for views when rendering previews in the backoffice |
93 | | ShowDocTypeSelectAsGrid | Boolean | Makes the content type selection dialog render a grid, in stead of the default list with descriptions |
94 |
95 | By default, a universal grid editor allowing all available element document types is added upon installation.
96 |
97 | **Since Doc Type Grid Editor does not support culture variation, element document types allowing culture variations is not available for use in Doc Type Grid Editor.**
98 |
99 | ---
100 |
101 | ### Hooking Up The Doc Type Grid Editor
102 |
103 | To hook up the **Doc Type Grid Editor**, within your grids prevalue, select the row configs you want to use the **Doc Type Grid Editor** in and for each cell config, check the **Doc Type** checkbox option to true. If you changed the name in the config, then select the item with the name you enter in the config. And, if you add your own editors either by package.manifest, or by editing grid.editors.config.js, you will need to select those too.
104 |
105 | 
106 |
107 | With the Doc Type Grid Editor enabled, from within your grid editor, you should now have a new option in the **Choose type of content** dialog.
108 |
109 | 
110 |
111 | From there, simply click the **Doc Type** icon. If you have multiple document types matching the `AllowedDocTypes` setting in the selected grid editor (the default **Doc Type**, lets you pick between all available document types), you need to choose the document type you wish to render.
112 |
113 | 
114 |
115 | If you have any Content Templates available for the selected document type, you need to choose which template to use for the content.
116 |
117 | 
118 |
119 | Then you should be presented with a form for all the fields in your document type.
120 |
121 | 
122 |
123 | Fill in the fields and click Submit. You should then see the grid populated with a preview of your item. If you have disabled previews using the `EnablePreview` setting, an icon will be shown to represent your content block.
124 |
125 | 
126 |
127 | Make sure save / save & publish the current page to persist your changes.
128 |
129 | ---
130 |
131 | ### Rendering a Doc Type Grid Editor
132 |
133 | The **Doc Type Grid Editor** uses standard ASP.NET MVC partials as the rendering mechanism. By default it will look for partial files in the `ViewPath` setting of your grid editor, or in the default partial view location (for exmaple `~/Views/Partials`). The rendering mechanism looks for a file with a name that matches the document type alias. For example, for the default setup, if your document type alias is `TestDocType`, the Doc Type Grid Editor will look for the partial file `~/Views/Partials/Grid/Editors/DocTypeGridEditor/TestDocType.cshtml`.
134 |
135 | To access the properties of your completed doc type, simply have your partial view inherit the standard `UmbracoViewPage` class, and you’ll be able to access them via the standard `Model` view property as a native `IPublishedElement` instance.
136 |
137 | ```
138 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
139 |
@Model.Name
140 | ```
141 |
142 | Because we treat your data as a standard `IPublishedElement` entity, that means you can use all the property value converters you are used to using.
143 |
144 | ```
145 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
146 |
@Model.Name
147 | @Model.Value("bodyText")
148 | More
149 | ```
150 |
151 | Doc Type Grid Editor also supports ModelsBuilder, so you can simplify your views like this:
152 | ```
153 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
154 | @using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
155 |
@Model.Name
156 | @Model.BodyText
157 | More
158 | ```
159 |
160 | 
161 |
162 |
163 | #### Rendering Alternative Preview Content
164 |
165 | If your front end view is rather complex, you may decide that you want to feed the back office preview an alternative, less complex view. To do this, you can use the `PreviewViewPath` setting on your grid editor, and place a view named after your document type there. **Doc Type Grid Editor** will use the preview view file, when rendering previews in the backoffice.
166 |
167 | If you don't want to have a seperate preview view file, you can add preview logic within your Razor view/partial. Check for a querystring parameter `dtgePreview` being set to "1" to detect being in preview mode to provide an alternative view.
168 |
169 | ```
170 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
171 | @if (Request.QueryString["dtgePreview"] == "1")
172 | {
173 | // Render preview view
174 | }
175 | else
176 | {
177 | // Render front end view
178 | }
179 | ```
180 |
181 | #### DocTypeGridEditorViewComponent
182 | Behind the scenes, Doc Type Grid Editor uses a ViewComponent to render all items. You can let it use the default component for all your editors if you like, but you can also specify your own document type specific, or editor specific view component. Or specify your own default view component.
183 |
184 | If you are not the type of developer that likes to put business logic in your views, then the ability to seperate logic from your view is a must. To render your grid editor item with a document type or editor specific view component, you need to create a view component, and give it a name in the format `{EditorAlias or Document Type Alias}DocTypeGridEditorViewComponent`.
185 |
186 | Note: The name of the viewcomponent is case sensitive, but DTGE is helpful enough to look for view components starting both with an uppercase letter and lowercase letter of your alias.
187 |
188 | The view component must implement a method called Invoke taking a dynamic model parameter, and a viewPath parameter as a string. The method should return an IViewComponentResult. As an example, the default view component does this:
189 |
190 | ```cs
191 | public IViewComponentResult Invoke(dynamic model, string viewPath)
192 | {
193 | return View(viewPath, model);
194 | }
195 | ```
196 |
197 | #### Overriding the default view component
198 | Doc Type Grid Editor comes with a default view component, that simply takes the model of the editor and sends it to the correct view. If you want to override this ViewComponent and replace it with your own, you can do it in your Startup.cs file, in the ConfigureServices method.
199 |
200 | Add the following code, to configure DocTypeGridEditor:
201 |
202 | ```cs
203 | public void ConfigureServices(IServiceCollection services)
204 | {
205 | services.AddUmbraco(_env, _config)
206 | .AddBackOffice()
207 | .AddWebsite()
208 | .AddComposers()
209 | .Build();
210 |
211 | services.SetDocTypeGridEditorSettings(c =>
212 | {
213 | c.DefaultDocTypeGridEditorViewComponent = typeof(MyDocTypeGridEditorViewComponent);
214 | });
215 | }
216 | ```
217 |
218 | ---
219 |
220 | ### Value Processors
221 | Since Doc Type Grid Editor stores the data for each property as a JSON-blob, we're not processing the values in the same way as Umbraco-core before storing it. This also means that the values that comes back and are passed into a Property Value Converter might be in of a type/format that that Property Value Convert can't handle.
222 |
223 | We've added something that we call "ValueProcessors" and these can be used to modify the raw property value before we send it to the property value converter. One example of where this is needed is the Tags-editor.
224 |
225 | If you need to perform some processing of a value before it's sent to the property value converter you can add your own ValueProcessor.
226 |
227 | ```csharp
228 | public class UmbracoColorPickerValueProcessor : IDocTypeGridEditorValueProcessor
229 | {
230 | public bool IsProcessorFor(string propertyEditorAlias)
231 | => propertyEditorAlias.Equals(Constants.PropertyEditors.Aliases.ColorPicker);
232 |
233 | public object ProcessValue(object value)
234 | {
235 | // Do something with the value
236 | return value;
237 | }
238 | }
239 | ```
240 |
241 | Then register this during composition withing IUserComposer,
242 | ```csharp
243 | public class MyCustomDocTypeGridEditorComposer : IUserComposer
244 | {
245 | public void Compose(Composition composition)
246 | {
247 | composition.DocTypeGridEditorValueProcessors()
248 | .Append();
249 | }
250 | }
251 | ```
252 |
253 | Dot Type Grid editor ships with a ValueProcessor for the Umbraco-Tags property.
254 |
255 | **Note:** When using a Tag-editor inside a DTGE this would not create any relationship between the current node and that tag, if you need to tag a node you should use the Tags-editor as a property directly on the document type.
256 |
257 | TODO: How to do this with IUmbracoBuilder?
258 |
259 |
260 |
261 |
262 |
263 | ### Useful Links
264 |
265 | * [Source Code](https://github.com/skttl/umbraco-doc-type-grid-editor)
266 | * [Our Umbraco Project Page](http://our.umbraco.org/projects/backoffice-extensions/doc-type-grid-editor)
267 |
--------------------------------------------------------------------------------
/docs/img/doc-type-grid-editor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skttl/umbraco-doc-type-grid-editor/1ae7f19d45f7f4ed9801229c1cad238f3fa1f530/docs/img/doc-type-grid-editor.png
--------------------------------------------------------------------------------
/docs/img/doc-type-grid-editor.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skttl/umbraco-doc-type-grid-editor/1ae7f19d45f7f4ed9801229c1cad238f3fa1f530/docs/img/doc-type-grid-editor.psd
--------------------------------------------------------------------------------
/docs/img/screenshot-01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skttl/umbraco-doc-type-grid-editor/1ae7f19d45f7f4ed9801229c1cad238f3fa1f530/docs/img/screenshot-01.png
--------------------------------------------------------------------------------
/docs/img/screenshot-02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skttl/umbraco-doc-type-grid-editor/1ae7f19d45f7f4ed9801229c1cad238f3fa1f530/docs/img/screenshot-02.png
--------------------------------------------------------------------------------
/docs/img/screenshot-03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skttl/umbraco-doc-type-grid-editor/1ae7f19d45f7f4ed9801229c1cad238f3fa1f530/docs/img/screenshot-03.png
--------------------------------------------------------------------------------
/docs/img/screenshot-03b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skttl/umbraco-doc-type-grid-editor/1ae7f19d45f7f4ed9801229c1cad238f3fa1f530/docs/img/screenshot-03b.png
--------------------------------------------------------------------------------
/docs/img/screenshot-04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skttl/umbraco-doc-type-grid-editor/1ae7f19d45f7f4ed9801229c1cad238f3fa1f530/docs/img/screenshot-04.png
--------------------------------------------------------------------------------
/docs/img/screenshot-05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skttl/umbraco-doc-type-grid-editor/1ae7f19d45f7f4ed9801229c1cad238f3fa1f530/docs/img/screenshot-05.png
--------------------------------------------------------------------------------
/docs/img/screenshot-06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skttl/umbraco-doc-type-grid-editor/1ae7f19d45f7f4ed9801229c1cad238f3fa1f530/docs/img/screenshot-06.png
--------------------------------------------------------------------------------
/src/Our.Umbraco.DocTypeGridEditor.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.0.32014.148
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Our.Umbraco.DocTypeGridEditor", "Our.Umbraco.DocTypeGridEditor\Our.Umbraco.DocTypeGridEditor.csproj", "{D4318AFD-033C-46FC-9DD2-9FC57934CD2F}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4933D56D-BD6F-4C2D-A9CF-40B90148E933}"
9 | ProjectSection(SolutionItems) = preProject
10 | ..\CHANGELOG.md = ..\CHANGELOG.md
11 | ..\CONTRIBUTING.md = ..\CONTRIBUTING.md
12 | ..\FUNDING.yml = ..\FUNDING.yml
13 | ..\README.md = ..\README.md
14 | EndProjectSection
15 | EndProject
16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{8E6B61BE-CD4E-4C09-B386-81AF21ABE55D}"
17 | ProjectSection(SolutionItems) = preProject
18 | ..\docs\developers-guide-v1.md = ..\docs\developers-guide-v1.md
19 | ..\docs\developers-guide-v2.md = ..\docs\developers-guide-v2.md
20 | ..\docs\README.md = ..\docs\README.md
21 | EndProjectSection
22 | EndProject
23 | Global
24 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
25 | Debug|Any CPU = Debug|Any CPU
26 | Release|Any CPU = Release|Any CPU
27 | EndGlobalSection
28 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
29 | {D4318AFD-033C-46FC-9DD2-9FC57934CD2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30 | {D4318AFD-033C-46FC-9DD2-9FC57934CD2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
31 | {D4318AFD-033C-46FC-9DD2-9FC57934CD2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
32 | {D4318AFD-033C-46FC-9DD2-9FC57934CD2F}.Release|Any CPU.Build.0 = Release|Any CPU
33 | EndGlobalSection
34 | GlobalSection(SolutionProperties) = preSolution
35 | HideSolutionNode = FALSE
36 | EndGlobalSection
37 | GlobalSection(NestedProjects) = preSolution
38 | {8E6B61BE-CD4E-4C09-B386-81AF21ABE55D} = {4933D56D-BD6F-4C2D-A9CF-40B90148E933}
39 | EndGlobalSection
40 | GlobalSection(ExtensibilityGlobals) = postSolution
41 | SolutionGuid = {66EC167C-845A-4DCC-87B7-C7DB5CC1E38B}
42 | EndGlobalSection
43 | EndGlobal
44 |
--------------------------------------------------------------------------------
/src/Our.Umbraco.DocTypeGridEditor/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml:
--------------------------------------------------------------------------------
1 | @using Our.Umbraco.DocTypeGridEditor.Helpers
2 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
3 | @inject DocTypeGridEditorHelper DocTypeGridEditorHelper
4 | @DocTypeGridEditorHelper.RenderDocTypeGridEditorItem(Component, Html, Model)
--------------------------------------------------------------------------------
/src/Our.Umbraco.DocTypeGridEditor/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditorPreviewer.cshtml:
--------------------------------------------------------------------------------
1 | @using Our.Umbraco.DocTypeGridEditor.Helpers
2 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
3 | @inject DocTypeGridEditorHelper DocTypeGridEditorHelper
4 | @DocTypeGridEditorHelper.RenderDocTypeGridEditorItem(Component, Html, Model.Item, Model.EditorAlias, Model.ViewPath, Model.PreviewViewPath, true)
--------------------------------------------------------------------------------
/src/Our.Umbraco.DocTypeGridEditor/Config/DocTypeGridEditorSettings.cs:
--------------------------------------------------------------------------------
1 | using Our.Umbraco.DocTypeGridEditor.ViewComponents;
2 | using System;
3 |
4 | namespace Our.Umbraco.DocTypeGridEditor.Config
5 | {
6 | public class DocTypeGridEditorSettings
7 | {
8 | public Type DefaultDocTypeGridEditorViewComponent { get; set; } = typeof(DocTypeGridEditorViewComponent);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/Our.Umbraco.DocTypeGridEditor/Controllers/DocTypeGridEditorApiController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http.Extensions;
2 | using Microsoft.AspNetCore.Mvc;
3 | using Microsoft.AspNetCore.Mvc.ModelBinding;
4 | using Microsoft.AspNetCore.Mvc.ViewFeatures;
5 | using Our.Umbraco.DocTypeGridEditor.Helpers;
6 | using Our.Umbraco.DocTypeGridEditor.Models;
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Globalization;
10 | using System.Linq;
11 | using System.Text.RegularExpressions;
12 | using Umbraco.Cms.Core;
13 | using Umbraco.Cms.Core.Models;
14 | using Umbraco.Cms.Core.Models.PublishedContent;
15 | using Umbraco.Cms.Core.PropertyEditors;
16 | using Umbraco.Cms.Core.Routing;
17 | using Umbraco.Cms.Core.Services;
18 | using Umbraco.Cms.Core.Strings;
19 | using Umbraco.Cms.Core.Web;
20 | using Umbraco.Cms.Web.BackOffice.Controllers;
21 | using Umbraco.Cms.Web.Common.Attributes;
22 | using Umbraco.Extensions;
23 |
24 | namespace Our.Umbraco.DocTypeGridEditor.Controllers
25 | {
26 | [PluginController("DocTypeGridEditorApi")]
27 | public class DocTypeGridEditorApiController : UmbracoAuthorizedJsonController
28 | {
29 | private readonly IUmbracoContextAccessor _umbracoContext;
30 | private readonly IVariationContextAccessor _variationContextAccessor;
31 | private readonly IContentTypeService _contentTypeService;
32 | private readonly IContentService _contentService;
33 | private readonly IDataTypeService _dataTypeService;
34 | private readonly IShortStringHelper _shortStringHelper;
35 | private readonly IPublishedContentQuery _contentQuery;
36 | private readonly IPublishedRouter _router;
37 | private readonly DocTypeGridEditorHelper _dtgeHelper;
38 | private readonly ServiceContext _serviceContext;
39 | private readonly IPublishedContentTypeFactory _publishedContentTypeFactory;
40 | private readonly PropertyEditorCollection _propertyEditorCollection;
41 |
42 | public DocTypeGridEditorApiController(IUmbracoContextAccessor umbracoContext,
43 | IVariationContextAccessor variationContextAccessor,
44 | IContentTypeService contentTypeService,
45 | IContentService contentService,
46 | IDataTypeService dataTypeService,
47 | IShortStringHelper shortStringHelper,
48 | IPublishedContentQuery contentQuery,
49 | IPublishedRouter router,
50 | ServiceContext serviceContext,
51 | IPublishedContentTypeFactory publishedContentTypeFactory,
52 | PropertyEditorCollection propertyEditorCollection,
53 | DocTypeGridEditorHelper dtgeHelper)
54 | {
55 | _umbracoContext = umbracoContext;
56 | _variationContextAccessor = variationContextAccessor;
57 | _contentTypeService = contentTypeService;
58 | _contentService = contentService;
59 | _dataTypeService = dataTypeService;
60 | _shortStringHelper = shortStringHelper;
61 | _contentQuery = contentQuery;
62 | _router = router;
63 | _dtgeHelper = dtgeHelper;
64 | _serviceContext = serviceContext;
65 | _publishedContentTypeFactory = publishedContentTypeFactory;
66 | _propertyEditorCollection = propertyEditorCollection;
67 | }
68 |
69 | [HttpGet]
70 | public object GetContentTypeAliasByGuid([FromQuery] Guid guid)
71 | {
72 | return new
73 | {
74 | alias = _contentTypeService.GetAllContentTypeAliases(guid).FirstOrDefault()
75 | };
76 | }
77 |
78 | [HttpGet]
79 | public IEnumerable