diff --git a/.gitignore b/.gitignore index b91f0cc..a15858c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,43 +1,16 @@ -######################################### -# # -# TheOutfiled's Ignore file # - -##### File globs to match #### -syntax: glob -# Resharper _ReSharper.* -# Visual Studio Stuff -*.obj -*.pdb -*.user -*.aps -*.pch -*.vspscc -*.vssscc -*_i.c -*_p.c -*.ncb +[Bb]in/ +[Oo]bj/ *.suo -*.tlb -*.tlh -*.bak +*.user +*.userprefs *.cache -*.ilk -*.log -*.lib -*.sbr -*.scc -*.csproj.user -obj/ -bin/ -[Dd]ebug*/ -[Rr]elease*/ -*.[Pp]ublish.xml -# General *.orig -*/Thumbs.db -*/log.txt -/Assets/ -/Build/ -*.DS_Store -[Pp]ackages/*/** +Thumbs.db +.DS_Store +*.log + +artifacts/ +src/packages/*/** +build/App_plugins/ +build/bin/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..4009f6d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,142 @@ +# Contributing to this project + +Please take a moment to review this document in order to make the contribution +process easy and effective for everyone involved. + +Following these guidelines helps to communicate that you respect the time of +the developers managing and developing this open source project. In return, +they should reciprocate that respect in addressing your issue or assessing +patches and features. + + +## Using the issue tracker + +The issue tracker is the preferred channel for [bug reports](#bugs), +[features requests](#features) and [submitting pull +requests](#pull-requests), but please respect the following restrictions: + +* Please **do not** use the issue tracker for personal support requests (use + [Our Umbraco](https://our.umbraco.org/projects/backoffice-extensions/doc-type-grid-editor/doc-type-grid-editor-feedback/) or Twitter). + +* Please **do not** derail or troll issues. Keep the discussion on topic and + respect the opinions of others. + + + +## Bug reports + +A bug is a _demonstrable problem_ that is caused by the code in the repository. +Good bug reports are extremely helpful - thank you! + +Guidelines for bug reports: + +1. **Use the GitHub issue search** — check if the issue has already been + reported. + +2. **Check if the issue has been fixed** — try to reproduce it using the + latest `master` or development branch in the repository. + +3. **Isolate the problem** — create a [reduced test + case](http://css-tricks.com/6263-reduced-test-cases/) and a live example. + +A good bug report shouldn't leave others needing to chase you up for more +information. Please try to be as detailed as possible in your report. What is +your environment? What steps will reproduce the issue? What browser(s) and OS +experience the problem? What would you expect to be the outcome? All these +details will help people to fix any potential bugs. + +Example: + +> Short and descriptive example bug report title +> +> A summary of the issue and the browser/OS environment in which it occurs. If +> suitable, include the steps required to reproduce the bug. +> +> 1. This is the first step +> 2. This is the second step +> 3. Further steps, etc. +> +> `` - a link to the reduced test case +> +> Any other information you want to share that is relevant to the issue being +> reported. This might include the lines of code that you have identified as +> causing the bug, and potential solutions (and your opinions on their +> merits). + + + +## Feature requests + +Feature requests are welcome. But take a moment to find out whether your idea +fits with the scope and aims of the project. It's up to *you* to make a strong +case to convince the project's developers of the merits of this feature. Please +provide as much detail and context as possible. + + + +## Pull requests + +Good pull requests - patches, improvements, new features - are a fantastic +help. They should remain focused in scope and avoid containing unrelated +commits. + +**Please ask first** before embarking on any significant pull request (e.g. +implementing features, refactoring code, porting to a different language), +otherwise you risk spending a lot of time working on something that the +project's developers might not want to merge into the project. + +Please adhere to the coding conventions used throughout a project (indentation, +accurate comments, etc.) and any other requirements (such as test coverage). + +Follow this process if you'd like your work considered for inclusion in the +project: + +1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork, + and configure the remotes: + + ```bash + # Clone your fork of the repo into the current directory + git clone https://github.com// + # Navigate to the newly cloned directory + cd + # Assign the original repo to a remote called "upstream" + git remote add upstream https://github.com// + ``` + +2. If you cloned a while ago, get the latest changes from upstream: + + ```bash + git checkout develop + git pull upstream develop + ``` + +3. Create a new topic branch (off the main project `develop` branch) to + contain your feature, change, or fix: + + ```bash + git checkout -b + ``` + +4. Commit your changes in logical chunks. Please adhere to these [git commit + message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) + or your code is unlikely be merged into the main project. Use Git's + [interactive rebase](https://help.github.com/articles/interactive-rebase) + feature to tidy up your commits before making them public. + +5. Locally merge (or rebase) the upstream development branch into your topic branch: + + ```bash + git pull [--rebase] upstream develop + ``` + +6. Push your topic branch up to your fork: + + ```bash + git push origin + ``` + +7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) + with a clear title and description. + +**IMPORTANT**: By submitting a patch, you agree to allow the project owner to +license your work under the same license as that used by the project. \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..6271e30 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,19 @@ +Copyright © 2014 Umbrella Inc, Our Umbraco and other contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/MIT-LICENSE.txt b/MIT-LICENSE.txt deleted file mode 100644 index 3b853b4..0000000 --- a/MIT-LICENSE.txt +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2011 Umbraco Community - -This software consists of voluntary contributions made by Umbraco -Community (https://bitbucket.org/mattbrailsford/ugolive) For exact -contribution history, see the revision history and logs, available -at https://bitbucket.org/mattbrailsford/ugolive/changesets - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Package.build.cmd b/Package.build.cmd deleted file mode 100644 index 72e7747..0000000 --- a/Package.build.cmd +++ /dev/null @@ -1,2 +0,0 @@ -C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe Package.build.xml -pause \ No newline at end of file diff --git a/Package.build.xml b/Package.build.xml deleted file mode 100644 index 40f998d..0000000 --- a/Package.build.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - $(MSBuildProjectDirectory)\Tools\MSBuildCommunityTasks - $(MSBuildProjectDirectory)\Tools\MSBuildUmbracoTasks - - - - - - - - 0.1.1 - Our.Umbraco.DocTypeGridEditor - Debug - - - - $(MSBuildProjectDirectory) - $(RootDir)\Build - $(RootDir)\Package - $(RootDir)\Src\$(ProjectName) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Package.xml b/Package.xml deleted file mode 100644 index 7105714..0000000 --- a/Package.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - Doc Type Grid Editor - 0.0 - MIT license - http://our.umbraco.org/projects/backoffice-extensions/doc-type-grid-editor - - 7 - 2 - 0 - - - - Matt Brailsford, Lee Kelleher - http://our.umbraco.org - - - - - - - - - - - - - - - - - - - diff --git a/Package/Doc_Type_Grid_Editor_0.1.1.zip b/Package/Doc_Type_Grid_Editor_0.1.1.zip deleted file mode 100644 index 7cf96dd..0000000 Binary files a/Package/Doc_Type_Grid_Editor_0.1.1.zip and /dev/null differ diff --git a/Packages/repositories.config b/Packages/repositories.config deleted file mode 100644 index 497c9db..0000000 --- a/Packages/repositories.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/README.markdown b/README.markdown deleted file mode 100644 index 90af3a1..0000000 --- a/README.markdown +++ /dev/null @@ -1,3 +0,0 @@ -# Doc Type Grid Editor - -A grid editor for Umbraco 7 that allows you to use Doc Types as a blue print for cell data diff --git a/README.md b/README.md new file mode 100644 index 0000000..c9af94a --- /dev/null +++ b/README.md @@ -0,0 +1,88 @@ +# Doc Type Grid Editor + +[![Build status](https://img.shields.io/appveyor/ci/leekelleher/umbraco-doc-type-grid-editor.svg)](https://ci.appveyor.com/project/leekelleher/umbraco-doc-type-grid-editor) +[![Our Umbraco project page](https://img.shields.io/badge/our-umbraco-orange.svg)](https://our.umbraco.org/projects/backoffice-extensions/doc-type-grid-editor) +[![Chat on Gitter](https://img.shields.io/badge/gitter-join_chat-green.svg)](https://gitter.im/leekelleher/umbraco-doc-type-grid-editor) + + +A grid editor for Umbraco 7 that allows you to use Doc Types as a blue print for cell data. + + +## Getting Started + +### Installation + +> *Note:* Doc Type Grid Editor has been developed against **Umbraco v7.2.0** and will support that version and above. + +Doc Type Grid Editor can be installed from either Our Umbraco package repository, or build manually from the source-code. + +#### Our Umbraco package repository + +To install from Our Umbraco, please download the package from: + +> [https://our.umbraco.org/projects/backoffice-extensions/doc-type-grid-editor](https://our.umbraco.org/projects/backoffice-extensions/doc-type-grid-editor) + +#### Manual build + +If you prefer, you can compile Doc Type Grid Editor yourself, you'll need: + +* Visual Studio 2012 (or above) + +To clone it locally click the "Clone in Windows" button above or run the following git commands. + + git clone https://github.com/leekelleher/umbraco-doc-type-grid-editor.git umbraco-doc-type-grid-editor + cd umbraco-doc-type-grid-editor + .\build.cmd + +--- + +## Developers Guide + +For details on how to use the Doc Type Grid Editor package, please refer to our [Developers Guide](docs/developers-guide.md) documentation. + +A PDF download is also available: [Doc Type Grid Editor - Developers Guide v1.0.pdf](docs/Doc-Type-Grid-Editor--Developers-Guide-v1.0.pdf) + +--- + +## Known Issues + +Please be aware that not all property-editors will work within Doc Type Grid Editor. The following property-editors are known to have compatibility issues: + +* Upload (default Umbraco core) +* Image Cropper (default Umbraco core) +* Macro Container (default Umbraco core) + +--- + +## Contributing to this project + +Anyone and everyone is welcome to contribute. Please take a moment to review the [guidelines for contributing](CONTRIBUTING.md). + +* [Bug reports](CONTRIBUTING.md#bugs) +* [Feature requests](CONTRIBUTING.md#features) +* [Pull requests](CONTRIBUTING.md#pull-requests) + + +## Contact + +Have a question? + +* [Doc Type Grid Editor Forum](https://our.umbraco.org/projects/backoffice-extensions/doc-type-grid-editor/doc-type-grid-editor-feedback/) on Our Umbraco +* [Raise an issue](https://github.com/leekelleher/umbraco-doc-type-grid-editor/issues) on GitHub + + +## Dev Team + +* [Matt Brailsford](https://github.com/mattbrailsford) +* [Lee Kelleher](https://github.com/leekelleher) + +### Special thanks + +* Thanks to [Jeavon Leopold](https://github.com/Jeavon) for being a rockstar and adding AppVeyor support. + + +## License + +Copyright © 2015 Umbrella Inc, Our Umbraco and [other contributors](https://github.com/leekelleher/umbraco-doc-type-grid-editor/graphs/contributors) + +Licensed under the [MIT License](LICENSE.md) diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Helpers/DocTypeGridEditorHelper.cs b/Src/Our.Umbraco.DocTypeGridEditor/Helpers/DocTypeGridEditorHelper.cs deleted file mode 100644 index d8e5112..0000000 --- a/Src/Our.Umbraco.DocTypeGridEditor/Helpers/DocTypeGridEditorHelper.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Our.Umbraco.DocTypeGridEditor.Models; -using Our.Umbraco.DocTypeGridEditor.Extensions; -using Umbraco.Core; -using Umbraco.Core.Models; -using Umbraco.Core.Models.Editors; -using Umbraco.Core.Models.PublishedContent; -using Umbraco.Core.PropertyEditors; -using Umbraco.Core.Services; - -namespace Our.Umbraco.DocTypeGridEditor.Helpers -{ - public class DocTypeGridEditorHelper - { - private static ServiceContext Services - { - get { return ApplicationContext.Current.Services; } - } - - public static IPublishedContent ConvertValueToContent(string id, string docTypeAlias, string dataJson) - { - return (IPublishedContent)ApplicationContext.Current.ApplicationCache.RequestCache.GetCacheItem( - "DocTypeGridEditorHelper.ConvertValueToContent_" + id + "_" + docTypeAlias, () => - { - using (var timer = DisposableTimer.DebugDuration(string.Format("ConvertValueToContent ({0}, {1})", id, docTypeAlias))) - { - Guid docTypeGuid; - if (Guid.TryParse(docTypeAlias, out docTypeGuid)) - docTypeAlias = Services.ContentTypeService.GetAliasByGuid(docTypeGuid); - - var publishedContentType = PublishedContentType.Get(PublishedItemType.Content, docTypeAlias); - var contentType = ApplicationContext.Current.Services.ContentTypeService.GetContentType(docTypeAlias); - var properties = new List(); - - // Convert all the properties - var data = JsonConvert.DeserializeObject(dataJson); - var propValues = ((JObject) data).ToObject>(); - foreach (var jProp in propValues) - { - var propType = publishedContentType.GetPropertyType(jProp.Key); - if (propType != null) - { - /* Because we never store the value in the database, we never run the property editors - * "ConvertEditorToDb" method however the property editors will expect their value to - * be in a "DB" state so to get round this, we run the "ConvertEditorToDb" here before - * we go on to convert the value for the view. - */ - var propEditor = PropertyEditorResolver.Current.GetByAlias(propType.PropertyEditorAlias); - var propPreValues = Services.DataTypeService.GetPreValuesCollectionByDataTypeId( - propType.DataTypeId); - - var contentPropData = new ContentPropertyData( - jProp.Value == null ? null : jProp.Value.ToString(), - propPreValues, - new Dictionary()); - - var newValue = propEditor.ValueEditor.ConvertEditorToDb(contentPropData, jProp.Value); - - /* Now that we have the DB stored value, we actually need to then convert it into it's - * XML serialized state as expected by the published property by calling ConvertDbToString - */ - var propType2 = contentType.PropertyTypes.Single(x => x.Alias == propType.PropertyTypeAlias); - var newValue2 = propEditor.ValueEditor.ConvertDbToString(new Property(propType2, newValue), propType2, - ApplicationContext.Current.Services.DataTypeService); - - properties.Add(new DetachedPublishedProperty(propType, newValue2)); - } - } - - // Parse out the name manually - object nameObj = null; - if (propValues.TryGetValue("name", out nameObj)) - { - // Do nothing, we just want to parse out the name if we can - } - - return new DetachedPublishedContent(nameObj == null ? null : nameObj.ToString(), publishedContentType, - properties.ToArray()); - } - }); - } - } -} diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Properties/AssemblyInfo.cs b/Src/Our.Umbraco.DocTypeGridEditor/Properties/AssemblyInfo.cs deleted file mode 100644 index 0bcc2fd..0000000 --- a/Src/Our.Umbraco.DocTypeGridEditor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Our.Umbraco.DocTypeGridEditor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("The Umbraco Community")] -[assembly: AssemblyProduct("Our.Umbraco.DocTypeGridEditor")] -[assembly: AssemblyCopyright("Copyright The Umbraco Community 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("693e3ce7-edf1-4775-a317-9882495f3a2d")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("0.1.1")] -[assembly: AssemblyVersion("0.1.1")] -[assembly: AssemblyFileVersion("0.1.1")] diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorSurfaceController.cs b/Src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorSurfaceController.cs deleted file mode 100644 index 4930e6d..0000000 --- a/Src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorSurfaceController.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.Web.Mvc; -using Umbraco.Core.Logging; -using Umbraco.Core.Models; -using Umbraco.Web.Mvc; - -namespace Our.Umbraco.DocTypeGridEditor.Web.Controllers -{ - public abstract class DocTypeGridEditorSurfaceController - : DocTypeGridEditorSurfaceController - { } - - public abstract class DocTypeGridEditorSurfaceController : SurfaceController - { - public TModel Model - { - get { return (TModel)ControllerContext.RouteData.Values["dtgeModel"]; } - } - - public string ViewPath - { - get { return ControllerContext.RouteData.Values["dtgeViewPath"] as string ?? string.Empty; } - } - - protected ActionResult CurrentPartialView(object model = null) - { - if (model == null) - model = Model; - - var viewName = ControllerContext.RouteData.Values["action"].ToString(); - var viewPath = GetFullViewPath(viewName); - - if (ViewExists(viewPath, true)) - return base.PartialView(viewPath, model); - - return HttpNotFound(); - } - - protected new PartialViewResult PartialView(string viewName) - { - return PartialView(viewName, Model); - } - - protected override PartialViewResult PartialView(string viewName, object model) - { - var viewPath = GetFullViewPath(viewName); - return base.PartialView(viewPath, model); - } - - protected string GetFullViewPath(string viewName) - { - if (viewName.StartsWith("~") || viewName.StartsWith("/") - || viewName.StartsWith(".") || string.IsNullOrWhiteSpace(ViewPath)) - { - return viewName; - } - - return ViewPath.TrimEnd('/') + "/" + viewName + ".cshtml"; - } - - protected bool ViewExists(string viewName, bool isPartial = false) - { - var result = !isPartial - ? ViewEngines.Engines.FindView(ControllerContext, viewName, null) - : ViewEngines.Engines.FindPartialView(ControllerContext, viewName); - if (result.View != null) - return true; - - LogHelper.Warn("No view file found with the name " + viewName); - return false; - } - } -} diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/HtmlHelperExtensions.cs b/Src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/HtmlHelperExtensions.cs deleted file mode 100644 index 9e8c742..0000000 --- a/Src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/HtmlHelperExtensions.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Web; -using System.Web.Mvc; -using System.Web.Mvc.Html; -using Our.Umbraco.DocTypeGridEditor.Helpers; -using Umbraco.Core.Models; -using Umbraco.Web; - -namespace Our.Umbraco.DocTypeGridEditor.Web.Extensions -{ - public static class HtmlHelperExtensions - { - public static HtmlString RenderDocTypeGridEditorItem(this HtmlHelper helper, - string id, - string docType, - string value, - string viewPath = "", - string actionName = "", - object model = null) - { - var content = DocTypeGridEditorHelper.ConvertValueToContent(id, docType, value); - return helper.RenderDocTypeGridEditorItem(content, viewPath, actionName, model); - } - - public static HtmlString RenderDocTypeGridEditorItem(this HtmlHelper helper, - IPublishedContent content, - string viewPath = "", - string actionName = "", - object model = null) - { - - if (content == null) - return new HtmlString(string.Empty); - - var controllerName = content.DocumentTypeAlias + "Surface"; - - if (!string.IsNullOrWhiteSpace(viewPath)) - viewPath = viewPath.TrimEnd('/') + "/"; - - if (string.IsNullOrWhiteSpace(actionName)) - actionName = content.DocumentTypeAlias; - - var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); - if (umbracoHelper.SurfaceControllerExists(controllerName, actionName, true)) - { - return helper.Action(actionName, controllerName, new - { - dtgeModel = model ?? content, - dtgeViewPath = viewPath - }); - } - - if (!string.IsNullOrWhiteSpace(viewPath)) - return helper.Partial(viewPath + content.DocumentTypeAlias + ".cshtml", content); - - return helper.Partial(content.DocumentTypeAlias, content); - } - } -} diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Config/grid.editors.config.js b/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Config/grid.editors.config.js deleted file mode 100644 index 02fa57b..0000000 --- a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Config/grid.editors.config.js +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "Doc Type", - "alias": "docType", - "view": "/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.html", - "render": "/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml", - "icon": "icon-item-arrangement", - "config": { - "allowedDocTypes": [], - "enablePreview": true, - "viewPath": "/Views/Partials/" - } -} \ No newline at end of file diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js b/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js deleted file mode 100644 index 51769d1..0000000 --- a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js +++ /dev/null @@ -1,191 +0,0 @@ -angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.GridEditors.DocTypeGridEditor", [ - - "$scope", - "$rootScope", - "$timeout", - "$routeParams", - "Our.Umbraco.DocTypeGridEditor.Services.DocTypeDialogService", - "Our.Umbraco.DocTypeGridEditor.Resources.DocTypeGridEditorResources", - - function ($scope, $rootScope, $timeout, $routeParams, dtgeDialogService, dtgeResources) { - - $scope.title = "Click to insert item"; - $scope.icon = "icon-item-arrangement"; - - $scope.setValue = function (data) { - $scope.control.value = data; - if (!("id" in $scope.control.value) || $scope.control.value.id == "") { - $scope.control.value.id = guid(); - } - if ("name" in $scope.control.value.value && $scope.control.value.value.name) { - $scope.title = $scope.control.value.value.name; - } - if ("docType" in $scope.control.value && $scope.control.value.docType) { - dtgeResources.getContentTypeIcon($scope.control.value.docType).then(function (data2) { - if (data2.icon) { - $scope.icon = data2.icon; - } - }); - } - }; - - $scope.setDocType = function () { - dtgeDialogService.open({ - allowedDocTypes: $scope.control.editor.config.allowedDocTypes || [], - dialogData: { - docType: $scope.control.value.docType, - value: $scope.control.value.value - }, - callback: function (data) { - $scope.setValue({ - docType: data.docType, - value: data.value - }); - $scope.setPreview($scope.control.value); - } - }); - }; - - $scope.setPreview = function (model) { - if ("enablePreview" in $scope.control.editor.config && $scope.control.editor.config.enablePreview) { - var nodeId = $routeParams.id; - dtgeResources.getEditorMarkupForDocTypePartial(nodeId, model.id, model.docType, model.value, $scope.control.editor.config.viewPath) - .success(function(htmlResult) { - if (htmlResult.trim().length > 0) { - $scope.preview = htmlResult; - } - }); - } - }; - - $scope.setValue($scope.control.value || { - id: guid(), - docType: "", - value: {} - }); - - $timeout(function () { - if ($scope.control.$initializing) { - $scope.setDocType(); - } else if ($scope.control.value) { - $scope.setPreview($scope.control.value); - } - }, 200); - - function guid() { - function s4() { - return Math.floor((1 + Math.random()) * 0x10000) - .toString(16) - .substring(1); - } - return s4() + s4() + '-' + s4() + '-' + s4() + '-' + - s4() + '-' + s4() + s4() + s4(); - } - - } -]); - -angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.Dialogs.DocTypeGridEditorDialog", - [ - "$scope", - "editorState", - "contentResource", - "Our.Umbraco.DocTypeGridEditor.Resources.DocTypeGridEditorResources", - - function ($scope, editorState, contentResource, dtgeResources) { - - $scope.dialogOptions = $scope.$parent.dialogOptions; - - $scope.docTypes = []; - $scope.dialogMode = "selectDocType"; - $scope.selectedDocType = null; - $scope.node = null; - $scope.nameProperty = { - hideLabel: false, - alias: "name", - label: "Name", - description: "Give this piece of content a name.", - value: "" - }; - - $scope.selectDocType = function () { - $scope.dialogMode = "edit"; - $scope.dialogData.docType = $scope.selectedDocType.guid; - loadNode(); - }; - - $scope.save = function () { - - // Make sure form is valid - if (!$scope.dtgeForm.$valid) - return; - - // Copy property values to scope model value - if ($scope.node) { - var value = { - name: $scope.nameProperty.value - }; - for (var t = 0; t < $scope.node.tabs.length; t++) { - var tab = $scope.node.tabs[t]; - for (var p = 0; p < tab.properties.length; p++) { - var prop = tab.properties[p]; - if (typeof prop.value !== "function") { - value[prop.alias] = prop.value; - } - } - } - $scope.dialogData.value = value; - } else { - $scope.dialogData.value = null; - } - - $scope.submit($scope.dialogData); - }; - - function loadNode() { - dtgeResources.getContentAliasByGuid($scope.dialogData.docType).then(function (data1) { - contentResource.getScaffold(-20, data1.alias).then(function (data) { - // Remove the last tab - data.tabs.pop(); - - // Merge current value - if ($scope.dialogData.value) { - $scope.nameProperty.value = $scope.dialogData.value.name; - for (var t = 0; t < data.tabs.length; t++) { - var tab = data.tabs[t]; - for (var p = 0; p < tab.properties.length; p++) { - var prop = tab.properties[p]; - if ($scope.dialogData.value[prop.alias]) { - prop.value = $scope.dialogData.value[prop.alias]; - } - } - } - }; - - // Assign the model to scope - $scope.node = data; - - editorState.set($scope.node); - }); - }); - }; - - if ($scope.dialogData.docType) { - $scope.dialogMode = "edit"; - loadNode(); - } else { - $scope.dialogMode = "selectDocType"; - // No data type, so load a list to choose from - dtgeResources.getContentTypes($scope.dialogOptions.allowedDocTypes).then(function (docTypes) { - $scope.docTypes = docTypes; - if ($scope.docTypes.length == 1) { - $scope.dialogData.docType = $scope.docTypes[0].guid; - $scope.dialogMode = "edit"; - loadNode(); - } - }); - } - - } - - ]); \ No newline at end of file diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.services.js b/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.services.js deleted file mode 100644 index 069f820..0000000 --- a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.services.js +++ /dev/null @@ -1,46 +0,0 @@ -angular.module('umbraco.services').factory('Our.Umbraco.DocTypeGridEditor.Services.DocTypeDialogService', - function (dialogService, editorState) { - return { - open: function (options) { - - var currentEditorState = editorState.current; - var callback = function () { - // We create a new editor state in the dialog, - // so be sure to set the previous one back - // when we are done. - editorState.set(currentEditorState); - }; - - var o = $.extend({}, { - template: "/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.dialog.html", - show: true, - requireName: true, - }, options); - - - // Wrap callbacks and reset the editor state - if ("callback" in o) { - var oldCallback = o.callback; - o.callback = function (data) { - oldCallback(data); - callback(data); - }; - } else { - o.callback = callback; - } - - if ("closeCallback" in o) { - var oldCloseCallback = o.closeCallback; - o.closeCallback = function (data) { - oldCloseCallback(data); - callback(data); - }; - } else { - o.closeCallback = callback; - } - - // Launch the dialog - dialogService.open(o); - } - }; - }); \ No newline at end of file diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml b/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml deleted file mode 100644 index 0c01f63..0000000 --- a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml +++ /dev/null @@ -1,15 +0,0 @@ -@using System.Web.Mvc.Html -@using Our.Umbraco.DocTypeGridEditor.Helpers -@using Our.Umbraco.DocTypeGridEditor.Web.Extensions -@inherits Umbraco.Web.Mvc.UmbracoViewPage -@if (Model.value != null) -{ - string id = Model.value.id.ToString(); - string docType = Model.value.docType.ToString(); - string value = Model.value.value.ToString(); - string viewPath = Model.editor.config.viewPath.ToString(); - - var content = DocTypeGridEditorHelper.ConvertValueToContent(id, docType, value); - - @Html.RenderDocTypeGridEditorItem(content, viewPath) -} diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.dialog.html b/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.dialog.html deleted file mode 100644 index 7787293..0000000 --- a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.dialog.html +++ /dev/null @@ -1,51 +0,0 @@ -
- - - - -
\ No newline at end of file diff --git a/Tools/MSBuildUmbracoTasks/MSBuild.Umbraco.Tasks.dll b/Tools/MSBuildUmbracoTasks/MSBuild.Umbraco.Tasks.dll deleted file mode 100644 index b5241bd..0000000 Binary files a/Tools/MSBuildUmbracoTasks/MSBuild.Umbraco.Tasks.dll and /dev/null differ diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..f57f956 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,46 @@ +# version format +version: 0.2.0.{build} + +# UMBRACO_PACKAGE_PRERELEASE_SUFFIX if a rtm release build this should be blank, otherwise if empty will default to alpha +# example UMBRACO_PACKAGE_PRERELEASE_SUFFIX=beta +init: + - set UMBRACO_PACKAGE_PRERELEASE_SUFFIX= + +build_script: +- build-appveyor.cmd + +artifacts: + - path: artifacts\*.nupkg + - path: artifacts\*.zip + +deploy: +# # MyGet Deployment for builds & releases +# - provider: NuGet +# server: https://www.myget.org/F/name/ +# symbol_server: https://nuget.symbolsource.org/MyGet/name +# api_key: +# secure: +# artifact: /.*\.nupkg/ +# on: +# branch: develop + + # GitHub Deployment for releases + - provider: GitHub + auth_token: + secure: pEozEGTqJutQwOidJU6BTB+Ix0NV4vrUnomhfeqheVz4RNwfxjEYLoqR4XabhlPz + artifact: /.*\.zip/ # upload all Zip packages to release assets + draft: false + prerelease: false + on: + branch: master + appveyor_repo_tag: true # deploy on tag push only + +# # NuGet Deployment for releases +# - provider: NuGet +# server: +# api_key: +# secure: +# artifact: /.*\.nupkg/ +# on: +# branch: master +# appveyor_repo_tag: true \ No newline at end of file diff --git a/build-appveyor.cmd b/build-appveyor.cmd new file mode 100644 index 0000000..88f973d --- /dev/null +++ b/build-appveyor.cmd @@ -0,0 +1,7 @@ +ECHO APPVEYOR_REPO_BRANCH: %APPVEYOR_REPO_BRANCH% +ECHO APPVEYOR_REPO_TAG: %APPVEYOR_REPO_TAG% +ECHO APPVEYOR_BUILD_NUMBER : %APPVEYOR_BUILD_NUMBER% +ECHO APPVEYOR_BUILD_VERSION : %APPVEYOR_BUILD_VERSION% + +CALL src\.nuget\NuGet.exe restore src\Our.Umbraco.DocTypeGridEditor.sln +CALL "%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" build\package.proj \ No newline at end of file diff --git a/build.cmd b/build.cmd new file mode 100644 index 0000000..7e1a2d8 --- /dev/null +++ b/build.cmd @@ -0,0 +1,24 @@ +ECHO off + +SET /P APPVEYOR_BUILD_NUMBER=Please enter a build number (e.g. 134): +SET /P PACKAGE_VERISON=Please enter your package version (e.g. 1.0.5): +SET /P UMBRACO_PACKAGE_PRERELEASE_SUFFIX=Please enter your package release suffix or leave empty (e.g. beta): + +SET /P APPVEYOR_REPO_TAG=If you want to simulate a GitHub tag for a release (e.g. true): + +if "%APPVEYOR_BUILD_NUMBER%" == "" ( + SET APPVEYOR_BUILD_NUMBER=100 +) +if "%PACKAGE_VERISON%" == "" ( + SET PACKAGE_VERISON=0.0.0 +) + +SET APPVEYOR_BUILD_VERSION=%PACKAGE_VERISON%.%APPVEYOR_BUILD_NUMBER% + +build-appveyor.cmd + +@IF %ERRORLEVEL% NEQ 0 GOTO err +@EXIT /B 0 +:err +@PAUSE +@EXIT /B 1 \ No newline at end of file diff --git a/build/package.nuspec b/build/package.nuspec new file mode 100644 index 0000000..fe4ca48 --- /dev/null +++ b/build/package.nuspec @@ -0,0 +1,22 @@ + + + + + 0.0.0 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build/package.proj b/build/package.proj new file mode 100644 index 0000000..9901bfc --- /dev/null +++ b/build/package.proj @@ -0,0 +1,206 @@ + + + + + + $(MSBuildProjectDirectory)\tools\MSBuildCommunityTasks + $(MSBuildProjectDirectory)\tools\MSBuildUmbracoTasks + $(MSBuildProjectDirectory)\tools\MSBuildNugetTasks + $(MSBuildProjectDirectory)\tools\AppVeyorUmbraco + + + + + + + + + + Our.Umbraco.DocTypeGridEditor + Doc Type Grid Editor + 7.2.0 + Doc Type Grid Editor is an advanced grid editor for the new Umbraco v7.2 Grid + Matt Brailsford, Lee Kelleher + https://github.com/leekelleher/umbraco-doc-type-grid-editor/graphs/contributors + MIT license + http://opensource.org/licenses/MIT + https://github.com/leekelleher/umbraco-doc-type-grid-editor + + + + + Our.Umbraco.DocTypeGridEditor + Umbraco Doc Type Grid Editor + Copyright © 2015 Matt Brailsford, Lee Kelleher + Matt Brailsford, Lee Kelleher + https://our.umbraco.org/media/wiki/145708/635623742802070736_dtgepng.png + umbraco grid document type editor + en-GB + false + + + + + $(APPVEYOR_BUILD_VERSION) + + + + + false + + + + + true + + + + + + + + true + + + + + false + + + + + + + Release + $(MSBuildProjectDirectory)\.. + $(MSBuildProjectDirectory)\_umbraco + $(MSBuildProjectDirectory)\_nuget + $(RootDir)\artifacts + $(RootDir)\src\$(ProjectName) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build/package.xml b/build/package.xml new file mode 100644 index 0000000..4855efa --- /dev/null +++ b/build/package.xml @@ -0,0 +1,41 @@ + + + + + + 0.0.0 + + + + 0 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build/tools/AppVeyorUmbraco/AppVeyorUmbraco.Targets b/build/tools/AppVeyorUmbraco/AppVeyorUmbraco.Targets new file mode 100644 index 0000000..67be406 --- /dev/null +++ b/build/tools/AppVeyorUmbraco/AppVeyorUmbraco.Targets @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tools/MSBuildCommunityTasks/ICSharpCode.SharpZipLib.dll b/build/tools/MSBuildCommunityTasks/ICSharpCode.SharpZipLib.dll similarity index 100% rename from Tools/MSBuildCommunityTasks/ICSharpCode.SharpZipLib.dll rename to build/tools/MSBuildCommunityTasks/ICSharpCode.SharpZipLib.dll diff --git a/Tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.Targets b/build/tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.Targets similarity index 100% rename from Tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.Targets rename to build/tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.Targets diff --git a/Tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.chm b/build/tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.chm similarity index 100% rename from Tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.chm rename to build/tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.chm diff --git a/Tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.dll b/build/tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.dll similarity index 100% rename from Tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.dll rename to build/tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.dll diff --git a/Tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.xml b/build/tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.xml similarity index 100% rename from Tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.xml rename to build/tools/MSBuildCommunityTasks/MSBuild.Community.Tasks.xml diff --git a/Tools/MSBuildCommunityTasks/Sample.proj b/build/tools/MSBuildCommunityTasks/Sample.proj similarity index 100% rename from Tools/MSBuildCommunityTasks/Sample.proj rename to build/tools/MSBuildCommunityTasks/Sample.proj diff --git a/build/tools/MSBuildNugetTasks/MSBuild.NuGet.Tasks.Targets b/build/tools/MSBuildNugetTasks/MSBuild.NuGet.Tasks.Targets new file mode 100644 index 0000000..83ac6e2 --- /dev/null +++ b/build/tools/MSBuildNugetTasks/MSBuild.NuGet.Tasks.Targets @@ -0,0 +1,12 @@ + + + + + $(MSBuildProjectDirectory)\MSBuildTasks + $(MSBuildNuGetTasksPath)\MSBuild.NuGet.Tasks.dll + + + + + + diff --git a/build/tools/MSBuildNugetTasks/MSBuild.NuGet.Tasks.dll b/build/tools/MSBuildNugetTasks/MSBuild.NuGet.Tasks.dll new file mode 100644 index 0000000..d7bc3f3 Binary files /dev/null and b/build/tools/MSBuildNugetTasks/MSBuild.NuGet.Tasks.dll differ diff --git a/Tools/MSBuildUmbracoTasks/ICSharpCode.SharpZipLib.dll b/build/tools/MSBuildUmbracoTasks/ICSharpCode.SharpZipLib.dll similarity index 100% rename from Tools/MSBuildUmbracoTasks/ICSharpCode.SharpZipLib.dll rename to build/tools/MSBuildUmbracoTasks/ICSharpCode.SharpZipLib.dll diff --git a/Tools/MSBuildUmbracoTasks/MSBuild.Umbraco.Tasks.Targets b/build/tools/MSBuildUmbracoTasks/MSBuild.Umbraco.Tasks.Targets similarity index 88% rename from Tools/MSBuildUmbracoTasks/MSBuild.Umbraco.Tasks.Targets rename to build/tools/MSBuildUmbracoTasks/MSBuild.Umbraco.Tasks.Targets index 20034af..61f3346 100644 --- a/Tools/MSBuildUmbracoTasks/MSBuild.Umbraco.Tasks.Targets +++ b/build/tools/MSBuildUmbracoTasks/MSBuild.Umbraco.Tasks.Targets @@ -2,7 +2,7 @@ - $(MSBuildProjectDirectory)\MSBuildUmbracoTasks + $(MSBuildProjectDirectory)\MSBuildTasks $(MSBuildUmbracoTasksPath)\MSBuild.Umbraco.Tasks.dll diff --git a/build/tools/MSBuildUmbracoTasks/MSBuild.Umbraco.Tasks.dll b/build/tools/MSBuildUmbracoTasks/MSBuild.Umbraco.Tasks.dll new file mode 100644 index 0000000..cb05f27 Binary files /dev/null and b/build/tools/MSBuildUmbracoTasks/MSBuild.Umbraco.Tasks.dll differ diff --git a/docs/Doc-Type-Grid-Editor--Developers-Guide-v1.0.pdf b/docs/Doc-Type-Grid-Editor--Developers-Guide-v1.0.pdf new file mode 100644 index 0000000..20967fa Binary files /dev/null and b/docs/Doc-Type-Grid-Editor--Developers-Guide-v1.0.pdf differ diff --git a/docs/Doc-Type-Grid-Editor--Developers-Guide-v1.1.docx b/docs/Doc-Type-Grid-Editor--Developers-Guide-v1.1.docx new file mode 100644 index 0000000..5e8129d Binary files /dev/null and b/docs/Doc-Type-Grid-Editor--Developers-Guide-v1.1.docx differ diff --git a/docs/Doc-Type-Grid-Editor--Developers-Guide-v1.1.pdf b/docs/Doc-Type-Grid-Editor--Developers-Guide-v1.1.pdf new file mode 100644 index 0000000..1f6cb8c Binary files /dev/null and b/docs/Doc-Type-Grid-Editor--Developers-Guide-v1.1.pdf differ diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..54ba28e --- /dev/null +++ b/docs/README.md @@ -0,0 +1,4 @@ +# Doc Type Grid Editor +## Documentation + +* [Doc Type Grid Editor - Developers Guide](developers-guide.md) \ No newline at end of file diff --git a/docs/developers-guide.md b/docs/developers-guide.md new file mode 100644 index 0000000..779ddb3 --- /dev/null +++ b/docs/developers-guide.md @@ -0,0 +1,183 @@ +# Doc Type Grid Editor - Developers Guide + +### Contents + +1. [Introduction](#introduction) +2. [Getting Set Up](#getting-set-up) + * [System Requirements](#system-requirements) +3. [Configuring The Doc Type Grid Editor](#configuring-the-doc-type-grid-editor) +4. [Hooking Up The Doc Type Grid Editor](#hooking-up-the-doc-type-grid-editor) +5. [Rendering a Doc Type Grid Editor](#rendering-a-doc-type-grid-editor) + * [Rendering Alternative Preview Content](#rendering-alternative-preview-content) + * [DocTypeGridEditorSurfaceController](#doctypegrideditorsurfacecontroller) +6. [Useful Links](#useful-links) + +--- + +### Introduction + +**Doc Type Grid Editor** is an advanced grid editor for the new Umbraco grid, offering similar functionality as the macro grid editor but using the full power of the Doc Type editor and data types. + +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. + +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. + +--- + +### Getting Set Up + +#### System Requirements + +Before you get started, there are a number of things you will need: + +1. .NET 4.5+ +2. Umbraco 7.2.0+ +3. The **Doc Type Grid Editor** package installed + +--- + +### Configuring The Doc Type Grid Editor + +The **Doc Type Grid Editor** is configured via the grid.editors.config.js config file located in the `~/Config` folder. A default configuration should be installed along with the package, but for details on the configuration options, please see below. + +#### Example + +```javascript +[ + ... + { + "name": "Doc Type", + "alias": "docType", + "view": "/App_Plugins/../doctypegrideditor.html", + "render": "/App_Plugins/../doctypegrideditor.cshtml", + "icon": "icon-item-arrangement", + "config": { + "allowedDocTypes": [...], + "enablePreview": true, + "viewPath": "/Views/Partials/" + }, + ... + ] +``` + +![Doc Type Grid Editor - JSON configuration](img/screenshot-07.png) + +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. + +| Member | Type | Description | +|--------|--------|-------------| +| Name | String | The name of the grid editor as it appears in the grid editor prevalue editor / selector screen. | +| Alias | String | A unique alias for this grid editor. | +| View | String | The path to the **Doc Type Grid Editor** editor view. **MUST NOT BE CHANGED**. | +| Render | String | The path to the **Doc Type Grid Editor** render view. **MUST NOT BE CHANGED**. | +| Icon | String | The icon class name to use for this grid editor (minus the '.') | +| Config | Object | Config options for this grid editor. | + +The **Doc Type Grid Editor** supports 3 config options, all of which are optional. + +| Member | Type | Description | +|-----------------|----------|-------------| +| AllowedDocTypes | String[] | An array of doc type aliases of which should be allowed to be selected in the grid editor. Strings can be REGEX patterns to allow matching groups of doc types in a single entry. e.g. "Widget$" will match all doc types with an alias ending in "Widget". | +| EnablePreview | Boolean | Enables rendering a preview of the grid cell in the grid editor. | +| ViewPath | String | Set's an alternative view path for where the **Doc Type Grid Editor** should look for views when rendering. Defaults to `~/Views/Partials/` | + +--- + +### Hooking Up The Doc Type Grid Editor + +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. (NB: If you changed the name in the config, then select the item with the name you enter in the config). + +![Doc Type Grid Editor - Prevalue Editor](img/screenshot-01.png) + +With the Doc Type Grid Editor enabled, from within your grid editor, you should now have a new option in the **Insert Control** dialog. + +![Doc Type Grid Editor - Insert Control](img/screenshot-02.png) + +From there, simply click the **Doc Type** icon and chose the doc type you wish to render. + +![Doc Type Grid Editor - Select Doc Type](img/screenshot-03.png) + +Then you should be presented with a form for all the fields in your doc type. + +![Doc Type Grid Editor - Doc Type Fields](img/screenshot-04.png) + +Fill in the fields and click save. You should then see the grid populated with a preview of your item. + +![Doc Type Grid Editor - Grid Preview](img/screenshot-05.png) + +Make sure save / save & publish the current page to persist your changes. + +--- + +### Rendering a Doc Type Grid Editor + +The **Doc Type Grid Editor** uses standard ASP.NET MVC partials as the rendering mechanism. By default it will look for partial files in `~/Views/Partials` with a name that matches the doc type alias. For example, if your doc type alias is `TestDocType`, the Doc Type Grid Editor will look for the partial file `~/Views/Partials/TestDocType.cshtml`. + +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 `IPublishedContent` instance. + +``` +@inherits Umbraco.Web.Mvc.UmbracoViewPage +

@Model.Name

+``` + +Because we treat your data as a standard `IPublishedContent` entity, that means you can use all the property value converters you are used to using, as well as the build in `@Umbraco.Field(...)` helper methods. + +``` +@inherits Umbraco.Web.Mvc.UmbracoViewPage +

@Model.Name

+@Umbraco.Field(Model, "bodyText") + More +``` + +![Doc Type Grid Editor - Rendered Content](img/screenshot-06.png) + + +#### Rendering Alternative Preview Content + +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, within your Razor view/partial, simply check for a querystring parameter `dtgePreview` being set to "1" to detect being in preview mode to provide an alternative view. + +``` +@inherits Umbraco.Web.Mvc.UmbracoViewPage +@if (Request.QueryString["dtgePreview"] == "1") +{ + // Render preview view +} +else +{ + // Render front end view +} +``` + +#### DocTypeGridEditorSurfaceController + +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`. + +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. + +```csharp +public class TestDocTypeSurfaceController + : DocTypeGridEditorSurfaceController +{ + public ActionResult TestDocType() + { + // Do your thing... + return CurrentPartialView(); + } +} +``` + +By inheriting from the `DocTypeGridEditorSurfaceController` base class, you'll also have instant access to the following helper properties / methods. + +| Member | Type | Description | +|---------------------------------------------------|-------------------|-------------| +| Model | IPublishedContent | The IPublishedContent instance for you cells data. | +| ViewPath | String | A reference to the currently configured ViewPath | +| 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. | +| 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. | + +--- + +### Useful Links + +* [Source Code](https://github.com/leekelleher/umbraco-doc-type-grid-editor) +* [Our Umbraco Project Page](http://our.umbraco.org/projects/backoffice-extensions/doc-type-grid-editor) diff --git a/docs/img/doc-type-grid-editor.png b/docs/img/doc-type-grid-editor.png new file mode 100644 index 0000000..11c0311 Binary files /dev/null and b/docs/img/doc-type-grid-editor.png differ diff --git a/docs/img/doc-type-grid-editor.psd b/docs/img/doc-type-grid-editor.psd new file mode 100644 index 0000000..b93ac4a Binary files /dev/null and b/docs/img/doc-type-grid-editor.psd differ diff --git a/docs/img/screenshot-01.png b/docs/img/screenshot-01.png new file mode 100644 index 0000000..8e49346 Binary files /dev/null and b/docs/img/screenshot-01.png differ diff --git a/docs/img/screenshot-02.png b/docs/img/screenshot-02.png new file mode 100644 index 0000000..c534e83 Binary files /dev/null and b/docs/img/screenshot-02.png differ diff --git a/docs/img/screenshot-03.png b/docs/img/screenshot-03.png new file mode 100644 index 0000000..7f3f07a Binary files /dev/null and b/docs/img/screenshot-03.png differ diff --git a/docs/img/screenshot-04.png b/docs/img/screenshot-04.png new file mode 100644 index 0000000..39fce95 Binary files /dev/null and b/docs/img/screenshot-04.png differ diff --git a/docs/img/screenshot-05.png b/docs/img/screenshot-05.png new file mode 100644 index 0000000..2a95142 Binary files /dev/null and b/docs/img/screenshot-05.png differ diff --git a/docs/img/screenshot-06.png b/docs/img/screenshot-06.png new file mode 100644 index 0000000..d1d2f41 Binary files /dev/null and b/docs/img/screenshot-06.png differ diff --git a/docs/img/screenshot-07.png b/docs/img/screenshot-07.png new file mode 100644 index 0000000..b08ef11 Binary files /dev/null and b/docs/img/screenshot-07.png differ diff --git a/.nuget/NuGet.Config b/src/.nuget/NuGet.Config similarity index 100% rename from .nuget/NuGet.Config rename to src/.nuget/NuGet.Config diff --git a/.nuget/NuGet.exe b/src/.nuget/NuGet.exe similarity index 100% rename from .nuget/NuGet.exe rename to src/.nuget/NuGet.exe diff --git a/.nuget/NuGet.targets b/src/.nuget/NuGet.targets similarity index 100% rename from .nuget/NuGet.targets rename to src/.nuget/NuGet.targets diff --git a/Our.Umbraco.DocTypeGridEditor.sln b/src/Our.Umbraco.DocTypeGridEditor.sln similarity index 63% rename from Our.Umbraco.DocTypeGridEditor.sln rename to src/Our.Umbraco.DocTypeGridEditor.sln index 4ee5ee8..ff4475a 100644 --- a/Our.Umbraco.DocTypeGridEditor.sln +++ b/src/Our.Umbraco.DocTypeGridEditor.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.21005.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Our.Umbraco.DocTypeGridEditor", "Src\Our.Umbraco.DocTypeGridEditor\Our.Umbraco.DocTypeGridEditor.csproj", "{4BD1DB40-1B39-4966-8740-D6A39D658598}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Our.Umbraco.DocTypeGridEditor", "Our.Umbraco.DocTypeGridEditor\Our.Umbraco.DocTypeGridEditor.csproj", "{4BD1DB40-1B39-4966-8740-D6A39D658598}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{CEE9961C-D747-40CD-B0B2-868D6B46833E}" ProjectSection(SolutionItems) = preProject @@ -12,12 +12,19 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{CEE996 .nuget\NuGet.targets = .nuget\NuGet.targets EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Package", "Package", "{D588B45D-9E67-4136-8271-2B8724C8165F}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{D588B45D-9E67-4136-8271-2B8724C8165F}" ProjectSection(SolutionItems) = preProject - Package.build.cmd = Package.build.cmd - Package.build.xml = Package.build.xml - Package.xml = Package.xml - README.markdown = README.markdown + ..\README.md = ..\README.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Package", "Build Package", "{42CE1449-272B-453B-B162-4558FD38BF41}" + ProjectSection(SolutionItems) = preProject + ..\appveyor.yml = ..\appveyor.yml + ..\build-appveyor.cmd = ..\build-appveyor.cmd + ..\build.cmd = ..\build.cmd + ..\build\package.nuspec = ..\build\package.nuspec + ..\build\package.proj = ..\build\package.proj + ..\build\package.xml = ..\build\package.xml EndProjectSection EndProject Global diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Bootstrap.cs b/src/Our.Umbraco.DocTypeGridEditor/Bootstrap.cs similarity index 86% rename from Src/Our.Umbraco.DocTypeGridEditor/Bootstrap.cs rename to src/Our.Umbraco.DocTypeGridEditor/Bootstrap.cs index 9f538ae..d2b1d1c 100644 --- a/Src/Our.Umbraco.DocTypeGridEditor/Bootstrap.cs +++ b/src/Our.Umbraco.DocTypeGridEditor/Bootstrap.cs @@ -1,5 +1,6 @@ using System.Web.Mvc; using Our.Umbraco.DocTypeGridEditor.Web.Attributes; +using Our.Umbraco.DocTypeGridEditor.Web.Mvc; using Umbraco.Core; using Umbraco.Core.Services; @@ -10,6 +11,8 @@ internal class Bootstrap : ApplicationEventHandler protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { GlobalFilters.Filters.Add(new DocTypeGridEditorPreviewAttribute()); + + DefaultDocTypeGridEditorSurfaceControllerResolver.Current = new DefaultDocTypeGridEditorSurfaceControllerResolver(); } protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Extensions/ContentTypeServiceExtensions.cs b/src/Our.Umbraco.DocTypeGridEditor/Extensions/ContentTypeServiceExtensions.cs similarity index 100% rename from Src/Our.Umbraco.DocTypeGridEditor/Extensions/ContentTypeServiceExtensions.cs rename to src/Our.Umbraco.DocTypeGridEditor/Extensions/ContentTypeServiceExtensions.cs diff --git a/src/Our.Umbraco.DocTypeGridEditor/Extensions/ViewEnginesCollectionExtensions.cs b/src/Our.Umbraco.DocTypeGridEditor/Extensions/ViewEnginesCollectionExtensions.cs new file mode 100644 index 0000000..97a6e9e --- /dev/null +++ b/src/Our.Umbraco.DocTypeGridEditor/Extensions/ViewEnginesCollectionExtensions.cs @@ -0,0 +1,22 @@ +using System.Web.Mvc; +using Umbraco.Core.Logging; + +namespace Our.Umbraco.DocTypeGridEditor.Extensions +{ + internal static class ViewEnginesCollectionExtensions + { + public static bool ViewExists(this ViewEngineCollection viewEngines, + ControllerContext controllerContext, + string viewName, bool isPartial = false) + { + var result = !isPartial + ? viewEngines.FindView(controllerContext, viewName, null) + : viewEngines.FindPartialView(controllerContext, viewName); + if (result.View != null) + return true; + + LogHelper.Warn("No view file found with the name " + viewName); + return false; + } + } +} diff --git a/src/Our.Umbraco.DocTypeGridEditor/Helpers/DocTypeGridEditorHelper.cs b/src/Our.Umbraco.DocTypeGridEditor/Helpers/DocTypeGridEditorHelper.cs new file mode 100644 index 0000000..c813f90 --- /dev/null +++ b/src/Our.Umbraco.DocTypeGridEditor/Helpers/DocTypeGridEditorHelper.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Our.Umbraco.DocTypeGridEditor.Extensions; +using Our.Umbraco.DocTypeGridEditor.Models; +using Umbraco.Core; +using Umbraco.Core.Models; +using Umbraco.Core.Models.Editors; +using Umbraco.Core.Models.PublishedContent; +using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Services; +using Umbraco.Web; + +namespace Our.Umbraco.DocTypeGridEditor.Helpers +{ + public class DocTypeGridEditorHelper + { + private static ServiceContext Services + { + get { return ApplicationContext.Current.Services; } + } + + public static IPublishedContent ConvertValueToContent(string id, string contentTypeAlias, string dataJson) + { + if (string.IsNullOrWhiteSpace(contentTypeAlias)) + return null; + + if (UmbracoContext.Current == null) + return ConvertValue(id, contentTypeAlias, dataJson); + + return (IPublishedContent)ApplicationContext.Current.ApplicationCache.RequestCache.GetCacheItem( + string.Concat("DocTypeGridEditorHelper.ConvertValueToContent_", id, "_", contentTypeAlias), + () => + { + return ConvertValue(id, contentTypeAlias, dataJson); + }); + } + + private static IPublishedContent ConvertValue(string id, string contentTypeAlias, string dataJson) + { + using (var timer = DisposableTimer.DebugDuration(string.Format("ConvertValueToContent ({0}, {1})", id, contentTypeAlias))) + { + Guid contentTypeGuid; + if (Guid.TryParse(contentTypeAlias, out contentTypeGuid)) + contentTypeAlias = Services.ContentTypeService.GetAliasByGuid(contentTypeGuid); + + var publishedContentType = PublishedContentType.Get(PublishedItemType.Content, contentTypeAlias); + var contentType = ApplicationContext.Current.Services.ContentTypeService.GetContentType(contentTypeAlias); + var properties = new List(); + + // Convert all the properties + var data = JsonConvert.DeserializeObject(dataJson); + var propValues = ((JObject)data).ToObject>(); + foreach (var jProp in propValues) + { + var propType = publishedContentType.GetPropertyType(jProp.Key); + if (propType != null) + { + /* Because we never store the value in the database, we never run the property editors + * "ConvertEditorToDb" method however the property editors will expect their value to + * be in a "DB" state so to get round this, we run the "ConvertEditorToDb" here before + * we go on to convert the value for the view. + */ + var propEditor = PropertyEditorResolver.Current.GetByAlias(propType.PropertyEditorAlias); + var propPreValues = Services.DataTypeService.GetPreValuesCollectionByDataTypeId( + propType.DataTypeId); + + var contentPropData = new ContentPropertyData( + jProp.Value, + propPreValues, + new Dictionary()); + + var newValue = propEditor.ValueEditor.ConvertEditorToDb(contentPropData, jProp.Value); + + /* Now that we have the DB stored value, we actually need to then convert it into it's + * XML serialized state as expected by the published property by calling ConvertDbToString + */ + var propType2 = contentType.CompositionPropertyTypes.Single(x => x.Alias == propType.PropertyTypeAlias); + var newValue2 = propEditor.ValueEditor.ConvertDbToString(new Property(propType2, newValue), propType2, + ApplicationContext.Current.Services.DataTypeService); + + properties.Add(new DetachedPublishedProperty(propType, newValue2)); + } + } + + // Parse out the name manually + object nameObj = null; + if (propValues.TryGetValue("name", out nameObj)) + { + // Do nothing, we just want to parse out the name if we can + } + + // Get the current request node we are embedded in + var pcr = UmbracoContext.Current != null ? UmbracoContext.Current.PublishedContentRequest : null; + var containerNode = pcr != null && pcr.HasPublishedContent ? pcr.PublishedContent : null; + + return new DetachedPublishedContent(nameObj != null ? nameObj.ToString() : null, + publishedContentType, + properties.ToArray(), + containerNode); + } + + } + } +} \ No newline at end of file diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Helpers/XmlHelper.cs b/src/Our.Umbraco.DocTypeGridEditor/Helpers/XmlHelper.cs similarity index 100% rename from Src/Our.Umbraco.DocTypeGridEditor/Helpers/XmlHelper.cs rename to src/Our.Umbraco.DocTypeGridEditor/Helpers/XmlHelper.cs diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Models/DetachedPublishedContent.cs b/src/Our.Umbraco.DocTypeGridEditor/Models/DetachedPublishedContent.cs similarity index 80% rename from Src/Our.Umbraco.DocTypeGridEditor/Models/DetachedPublishedContent.cs rename to src/Our.Umbraco.DocTypeGridEditor/Models/DetachedPublishedContent.cs index 0c458f1..3a55536 100644 --- a/Src/Our.Umbraco.DocTypeGridEditor/Models/DetachedPublishedContent.cs +++ b/src/Our.Umbraco.DocTypeGridEditor/Models/DetachedPublishedContent.cs @@ -14,15 +14,18 @@ internal class DetachedPublishedContent : PublishedContentBase private readonly PublishedContentType _contentType; private readonly IEnumerable _properties; private readonly bool _isPreviewing; + private readonly IPublishedContent _containerNode; public DetachedPublishedContent(string name, PublishedContentType contentType, IEnumerable properties, + IPublishedContent containerNode = null, bool isPreviewing = false) { _name = name; _contentType = contentType; _properties = properties; + _containerNode = containerNode; _isPreviewing = isPreviewing; } @@ -106,22 +109,22 @@ public override string UrlName public override string WriterName { - get { return null; } + get { return _containerNode != null ? _containerNode.WriterName : null; } } public override string CreatorName { - get { return null; } + get { return _containerNode != null ? _containerNode.CreatorName : null; } } public override int WriterId { - get { return 0; } + get { return _containerNode != null ? _containerNode.WriterId : 0; } } public override int CreatorId { - get { return 0; } + get { return _containerNode != null ? _containerNode.CreatorId : 0; } } public override string Path @@ -131,17 +134,17 @@ public override string Path public override DateTime CreateDate { - get { return DateTime.MinValue; } + get { return _containerNode != null ? _containerNode.CreateDate : DateTime.MinValue; } } public override DateTime UpdateDate { - get { return DateTime.MinValue; } + get { return _containerNode != null ? _containerNode.UpdateDate : DateTime.MinValue; } } public override Guid Version { - get { return Guid.Empty; } + get { return _containerNode != null ? _containerNode.Version : Guid.Empty; } } public override int Level diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Models/DetachedPublishedProperty.cs b/src/Our.Umbraco.DocTypeGridEditor/Models/DetachedPublishedProperty.cs similarity index 100% rename from Src/Our.Umbraco.DocTypeGridEditor/Models/DetachedPublishedProperty.cs rename to src/Our.Umbraco.DocTypeGridEditor/Models/DetachedPublishedProperty.cs diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Our.Umbraco.DocTypeGridEditor.csproj b/src/Our.Umbraco.DocTypeGridEditor/Our.Umbraco.DocTypeGridEditor.csproj similarity index 60% rename from Src/Our.Umbraco.DocTypeGridEditor/Our.Umbraco.DocTypeGridEditor.csproj rename to src/Our.Umbraco.DocTypeGridEditor/Our.Umbraco.DocTypeGridEditor.csproj index 7b731da..a1e3a35 100644 --- a/Src/Our.Umbraco.DocTypeGridEditor/Our.Umbraco.DocTypeGridEditor.csproj +++ b/src/Our.Umbraco.DocTypeGridEditor/Our.Umbraco.DocTypeGridEditor.csproj @@ -11,7 +11,7 @@ Our.Umbraco.DocTypeGridEditor v4.5 512 - ..\..\ + ..\ true @@ -33,124 +33,148 @@ - ..\..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.dll + ..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.dll + False - ..\..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.Net4.dll + ..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.Net4.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\businesslogic.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\businesslogic.dll + False - ..\..\packages\ClientDependency.1.8.2.1\lib\net45\ClientDependency.Core.dll + ..\packages\ClientDependency.1.8.2.1\lib\net45\ClientDependency.Core.dll + False - ..\..\packages\ClientDependency-Mvc.1.8.0.0\lib\net45\ClientDependency.Core.Mvc.dll + ..\packages\ClientDependency-Mvc.1.8.0.0\lib\net45\ClientDependency.Core.Mvc.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\cms.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\cms.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\controls.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\controls.dll + False - ..\..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll + ..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll + False - ..\..\packages\Examine.0.1.57.2941\lib\Examine.dll + ..\packages\Examine.0.1.57.2941\lib\Examine.dll + False - ..\..\packages\HtmlAgilityPack.1.4.6\lib\Net45\HtmlAgilityPack.dll + ..\packages\HtmlAgilityPack.1.4.6\lib\Net45\HtmlAgilityPack.dll + False - ..\..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll + ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll + False - ..\..\packages\ImageProcessor.1.9.5.0\lib\ImageProcessor.dll + ..\packages\ImageProcessor.1.9.5.0\lib\ImageProcessor.dll + False - ..\..\packages\ImageProcessor.Web.3.3.1.0\lib\net45\ImageProcessor.Web.dll + ..\packages\ImageProcessor.Web.3.3.1.0\lib\net45\ImageProcessor.Web.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\interfaces.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\interfaces.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\log4net.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\log4net.dll + False - ..\..\packages\Lucene.Net.2.9.4.1\lib\net40\Lucene.Net.dll + ..\packages\Lucene.Net.2.9.4.1\lib\net40\Lucene.Net.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\Microsoft.ApplicationBlocks.Data.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\Microsoft.ApplicationBlocks.Data.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\Microsoft.Web.Helpers.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\Microsoft.Web.Helpers.dll + False - True - ..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + False + ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - ..\..\packages\Microsoft.AspNet.Mvc.FixedDisplayModes.1.0.1\lib\net40\Microsoft.Web.Mvc.FixedDisplayModes.dll + ..\packages\Microsoft.AspNet.Mvc.FixedDisplayModes.1.0.1\lib\net40\Microsoft.Web.Mvc.FixedDisplayModes.dll + False - ..\..\packages\MiniProfiler.2.1.0\lib\net40\MiniProfiler.dll + ..\packages\MiniProfiler.2.1.0\lib\net40\MiniProfiler.dll + False - ..\..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll + ..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll + False - ..\..\packages\Newtonsoft.Json.6.0.5\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.6.0.5\lib\net45\Newtonsoft.Json.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\SQLCE4Umbraco.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\SQLCE4Umbraco.dll + False - True - ..\..\packages\UmbracoCms.Core.7.2.0\lib\System.Data.SqlServerCe.dll + False + ..\packages\UmbracoCms.Core.7.2.0\lib\System.Data.SqlServerCe.dll - True - ..\..\packages\UmbracoCms.Core.7.2.0\lib\System.Data.SqlServerCe.Entity.dll + False + ..\packages\UmbracoCms.Core.7.2.0\lib\System.Data.SqlServerCe.Entity.dll - True - ..\..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll + False + ..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll - True - ..\..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.Helpers.dll + False + ..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.Helpers.dll - True - ..\..\packages\Microsoft.AspNet.WebApi.Core.4.0.30506.0\lib\net40\System.Web.Http.dll + False + ..\packages\Microsoft.AspNet.WebApi.Core.4.0.30506.0\lib\net40\System.Web.Http.dll - True + False False - ..\..\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll + ..\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll + False - True - ..\..\packages\Microsoft.AspNet.Razor.2.0.20710.0\lib\net40\System.Web.Razor.dll + False + ..\packages\Microsoft.AspNet.Razor.2.0.20710.0\lib\net40\System.Web.Razor.dll - True - ..\..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.dll + False + ..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.dll - True - ..\..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Deployment.dll + False + ..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Deployment.dll - True - ..\..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll + False + ..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll @@ -158,50 +182,62 @@ - ..\..\packages\UmbracoCms.Core.7.2.0\lib\TidyNet.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\TidyNet.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\umbraco.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\umbraco.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\Umbraco.Core.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\Umbraco.Core.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\umbraco.DataLayer.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\umbraco.DataLayer.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\umbraco.editorControls.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\umbraco.editorControls.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\umbraco.MacroEngines.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\umbraco.MacroEngines.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\umbraco.providers.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\umbraco.providers.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\Umbraco.Web.UI.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\Umbraco.Web.UI.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\UmbracoExamine.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\UmbracoExamine.dll + False - ..\..\packages\UmbracoCms.Core.7.2.0\lib\UrlRewritingNet.UrlRewriter.dll + ..\packages\UmbracoCms.Core.7.2.0\lib\UrlRewritingNet.UrlRewriter.dll + False + - + + @@ -212,6 +248,7 @@ + @@ -230,9 +267,9 @@ IF %25ComputerName%25 == MBP13-PC-BC ( IF NOT "$(SolutionDir)" == "*Undefined*" ( - xcopy /s /y "$(TargetPath)" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoCms.7.2.2\bin" - xcopy /s /y "$(TargetDir)$(ProjectName).pdb" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoCms.7.2.2\bin" - xcopy /s /y "$(ProjectDir)Web\UI\*.*" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoCms.7.2.2" + xcopy /s /y "$(TargetPath)" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoUHangoutDemo\bin" + xcopy /s /y "$(TargetDir)$(ProjectName).pdb" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoUHangoutDemo\bin" + xcopy /s /y "$(ProjectDir)Web\UI\*.*" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoUHangoutDemo" ) ) diff --git a/Src/Our.Umbraco.DocTypeGridEditor/PackageActions/AddObjectToJsonArray.cs b/src/Our.Umbraco.DocTypeGridEditor/PackageActions/AddObjectToJsonArray.cs similarity index 100% rename from Src/Our.Umbraco.DocTypeGridEditor/PackageActions/AddObjectToJsonArray.cs rename to src/Our.Umbraco.DocTypeGridEditor/PackageActions/AddObjectToJsonArray.cs diff --git a/src/Our.Umbraco.DocTypeGridEditor/Properties/VersionInfo.cs b/src/Our.Umbraco.DocTypeGridEditor/Properties/VersionInfo.cs new file mode 100644 index 0000000..b34086b --- /dev/null +++ b/src/Our.Umbraco.DocTypeGridEditor/Properties/VersionInfo.cs @@ -0,0 +1,19 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34209 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyVersion("0.0.*")] +[assembly: AssemblyInformationalVersion("0.0.0-develop")] + + diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Web/Attributes/DocTypeGridEditorPreviewAttribute.cs b/src/Our.Umbraco.DocTypeGridEditor/Web/Attributes/DocTypeGridEditorPreviewAttribute.cs similarity index 100% rename from Src/Our.Umbraco.DocTypeGridEditor/Web/Attributes/DocTypeGridEditorPreviewAttribute.cs rename to src/Our.Umbraco.DocTypeGridEditor/Web/Attributes/DocTypeGridEditorPreviewAttribute.cs diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorApiController.cs b/src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorApiController.cs similarity index 92% rename from Src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorApiController.cs rename to src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorApiController.cs index 5d16f3c..0f0663f 100644 --- a/Src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorApiController.cs +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorApiController.cs @@ -40,9 +40,12 @@ public IEnumerable GetContentTypes([System.Web.Http.ModelBinding.ModelBi } [System.Web.Http.HttpGet] - public object GetContentTypeIcon([System.Web.Http.ModelBinding.ModelBinder] Guid guid) + public object GetContentTypeIcon([System.Web.Http.ModelBinding.ModelBinder] string contentTypeAlias) { - var contentTypeAlias = Services.ContentTypeService.GetAliasByGuid(guid); + Guid docTypeGuid; + if (Guid.TryParse(contentTypeAlias, out docTypeGuid)) + contentTypeAlias = Services.ContentTypeService.GetAliasByGuid(docTypeGuid); + var contentType = Services.ContentTypeService.GetContentType(contentTypeAlias); return new { diff --git a/src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorSurfaceController.cs b/src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorSurfaceController.cs new file mode 100644 index 0000000..039eaf3 --- /dev/null +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorSurfaceController.cs @@ -0,0 +1,94 @@ +using System.Web.Mvc; +using Our.Umbraco.DocTypeGridEditor.Extensions; +using Umbraco.Core.Models; +using Umbraco.Web.Mvc; + +namespace Our.Umbraco.DocTypeGridEditor.Web.Controllers +{ + public abstract class DocTypeGridEditorSurfaceController + : DocTypeGridEditorSurfaceController + { } + + public abstract class DocTypeGridEditorSurfaceController : SurfaceController + { + public TModel Model + { + get { return (TModel)ControllerContext.RouteData.Values["dtgeModel"]; } + } + + public string ViewPath + { + get { return ControllerContext.RouteData.Values["dtgeViewPath"] as string ?? string.Empty; } + } + + public string PreviewViewPath + { + get { return ControllerContext.RouteData.Values["dtgePreviewViewPath"] as string ?? string.Empty; } + } + + public bool IsPreview + { + get { return Request.QueryString["dtgePreview"] == "1"; } + } + + protected PartialViewResult CurrentPartialView(object model = null) + { + if (model == null) + model = Model; + + var viewName = ControllerContext.RouteData.Values["action"].ToString(); + + if (IsPreview && !string.IsNullOrWhiteSpace(PreviewViewPath)) + { + var previewViewPath = GetFullViewPath(viewName, PreviewViewPath); + if (ViewEngines.Engines.ViewExists(ControllerContext, previewViewPath, true)) + return base.PartialView(previewViewPath, model); + } + + if (!string.IsNullOrWhiteSpace(ViewPath)) + { + var viewPath = GetFullViewPath(viewName, ViewPath); + if (ViewEngines.Engines.ViewExists(ControllerContext, viewPath, true)) + return base.PartialView(viewPath, model); + } + + return base.PartialView(viewName, model); + } + + protected new PartialViewResult PartialView(string viewName) + { + return PartialView(viewName, Model); + } + + protected override PartialViewResult PartialView(string viewName, object model) + { + if (IsPreview && !string.IsNullOrWhiteSpace(PreviewViewPath)) + { + var previewViewPath = GetFullViewPath(viewName, PreviewViewPath); + if (ViewEngines.Engines.ViewExists(ControllerContext, previewViewPath, true)) + return base.PartialView(previewViewPath, model); + } + + if (!string.IsNullOrWhiteSpace(ViewPath)) + { + var viewPath = GetFullViewPath(viewName, ViewPath); + if (ViewEngines.Engines.ViewExists(ControllerContext, viewPath, true)) + return base.PartialView(viewPath, model); + } + + return base.PartialView(viewName, model); + } + + protected string GetFullViewPath(string viewName, string baseViewPath) + { + if (viewName.StartsWith("~") || viewName.StartsWith("/") + || viewName.StartsWith(".") || string.IsNullOrWhiteSpace(baseViewPath)) + { + return viewName; + } + + return baseViewPath.TrimEnd('/') + "/" + viewName + ".cshtml"; + } + + } +} diff --git a/src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/HtmlHelperExtensions.cs b/src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/HtmlHelperExtensions.cs new file mode 100644 index 0000000..1b82da9 --- /dev/null +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/HtmlHelperExtensions.cs @@ -0,0 +1,134 @@ +using System.Web; +using System.Web.Mvc; +using System.Web.Mvc.Html; +using Our.Umbraco.DocTypeGridEditor.Extensions; +using Our.Umbraco.DocTypeGridEditor.Web.Mvc; +using Umbraco.Core; +using Umbraco.Core.Models; +using Umbraco.Web; + +namespace Our.Umbraco.DocTypeGridEditor.Web.Extensions +{ + public static class HtmlHelperExtensions + { + public static HtmlString RenderDocTypeGridEditorItem(this HtmlHelper helper, + IPublishedContent content, + string editorAlias = "", + string viewPath = "", + string previewViewPath = "") + { + if (content == null) + return new HtmlString(string.Empty); + + var controllerName = content.DocumentTypeAlias + "Surface"; + + if (!string.IsNullOrWhiteSpace(viewPath)) + viewPath = viewPath.TrimEnd('/') + "/"; + + if (!string.IsNullOrWhiteSpace(previewViewPath)) + previewViewPath = previewViewPath.TrimEnd('/') + "/"; + + var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); + + // Try looking for surface controller with action named after the editor alias + if (!editorAlias.IsNullOrWhiteSpace() && umbracoHelper.SurfaceControllerExists(controllerName, editorAlias, true)) + { + return helper.Action(editorAlias, controllerName, new + { + dtgeModel = content, + dtgeViewPath = viewPath, + dtgePreviewViewPath = previewViewPath + }); + } + + // Try looking for surface controller with action named after the doc type alias alias + if (umbracoHelper.SurfaceControllerExists(controllerName, content.DocumentTypeAlias, true)) + { + return helper.Action(content.DocumentTypeAlias, controllerName, new + { + dtgeModel = content, + dtgeViewPath = viewPath, + dtgePreviewViewPath = previewViewPath + }); + } + + // See if a default surface controller has been registered + var defaultController = DefaultDocTypeGridEditorSurfaceControllerResolver.Current.GetDefaultControllerType(); + if (defaultController != null) + { + var defaultControllerName = defaultController.Name.Substring(0, defaultController.Name.LastIndexOf("Controller")); + + // Try looking for an action named after the editor alias + if (!editorAlias.IsNullOrWhiteSpace() && umbracoHelper.SurfaceControllerExists(defaultControllerName, editorAlias, true)) + { + return helper.Action(editorAlias, defaultControllerName, new + { + dtgeModel = content, + dtgeViewPath = viewPath, + dtgePreviewViewPath = previewViewPath + }); + } + + // Try looking for a doc type alias action + if (umbracoHelper.SurfaceControllerExists(defaultControllerName, content.DocumentTypeAlias, true)) + { + return helper.Action(content.DocumentTypeAlias, defaultControllerName, new + { + dtgeModel = content, + dtgeViewPath = viewPath, + dtgePreviewViewPath = previewViewPath + }); + } + + // Just go with a default action name + return helper.Action("Index", defaultControllerName, new + { + dtgeModel = content, + dtgeViewPath = viewPath, + dtgePreviewViewPath = previewViewPath + }); + } + + // Check for preview view + if (!string.IsNullOrWhiteSpace(previewViewPath) + && helper.ViewContext.RequestContext.HttpContext.Request.QueryString["dtgePreview"] == "1") + { + var fullPreviewViewPath = previewViewPath + editorAlias + ".cshtml"; + if (ViewEngines.Engines.ViewExists(helper.ViewContext, fullPreviewViewPath, true)) + { + return helper.Partial(fullPreviewViewPath, content); + } + + fullPreviewViewPath = previewViewPath + content.DocumentTypeAlias + ".cshtml"; + if (ViewEngines.Engines.ViewExists(helper.ViewContext, fullPreviewViewPath, true)) + { + return helper.Partial(fullPreviewViewPath, content); + } + } + + // Check for view path view + if (!string.IsNullOrWhiteSpace(viewPath)) + { + var fullViewPath = viewPath + editorAlias + ".cshtml"; + if (ViewEngines.Engines.ViewExists(helper.ViewContext, fullViewPath, true)) + { + return helper.Partial(fullViewPath, content); + } + + fullViewPath = viewPath + content.DocumentTypeAlias + ".cshtml"; + if (ViewEngines.Engines.ViewExists(helper.ViewContext, fullViewPath, true)) + { + return helper.Partial(fullViewPath, content); + } + } + + // Resort to standard partial views + if (ViewEngines.Engines.ViewExists(helper.ViewContext, editorAlias, true)) + { + return helper.Partial(editorAlias, content); + } + + return helper.Partial(content.DocumentTypeAlias, content); + } + } +} diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/UmbracoHelperExtensions.cs b/src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/UmbracoHelperExtensions.cs similarity index 100% rename from Src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/UmbracoHelperExtensions.cs rename to src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/UmbracoHelperExtensions.cs diff --git a/src/Our.Umbraco.DocTypeGridEditor/Web/Mvc/DefaultDocTypeGridEditorSurfaceControllerResolver.cs b/src/Our.Umbraco.DocTypeGridEditor/Web/Mvc/DefaultDocTypeGridEditorSurfaceControllerResolver.cs new file mode 100644 index 0000000..b37cbf8 --- /dev/null +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/Mvc/DefaultDocTypeGridEditorSurfaceControllerResolver.cs @@ -0,0 +1,52 @@ +using System; +using Our.Umbraco.DocTypeGridEditor.Web.Controllers; +using Umbraco.Core; +using Umbraco.Core.ObjectResolution; + +namespace Our.Umbraco.DocTypeGridEditor.Web.Mvc +{ + /// + /// A resolver used to resolve the default SurfaceController that is used to render any front-end + /// Umbraco partial when using Nested Content. + /// + public class DefaultDocTypeGridEditorSurfaceControllerResolver : SingleObjectResolverBase + { + /// + /// Constructor accepting the default SurfaceController + /// + public DefaultDocTypeGridEditorSurfaceControllerResolver() + : base(null, true) + { } + + /// + /// Sets the default SurfaceController type + /// + /// + public void SetDefaultControllerType(Type controllerType) + { + ValidateType(controllerType); + Value = controllerType; + } + + /// + /// Returns the Default SurfaceController type + /// + /// + public Type GetDefaultControllerType() + { + return Value; + } + + /// + /// Ensures that the type passed in is of type SurfaceController + /// + /// + private void ValidateType(Type type) + { + if (!type.IsOfGenericType(typeof(DocTypeGridEditorSurfaceController<>))) + { + throw new InvalidOperationException("The Type specified (" + type + ") is not of type " + typeof(DocTypeGridEditorSurfaceController<>)); + } + } + } +} diff --git a/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Config/grid.editors.config.js b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Config/grid.editors.config.js new file mode 100644 index 0000000..dc109fa --- /dev/null +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Config/grid.editors.config.js @@ -0,0 +1,16 @@ +{ + "name": "Doc Type", + "alias": "docType", + "view": "/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.html", + "render": "/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml", + "icon": "icon-item-arrangement", + "config": { + "allowedDocTypes": [], + "nameTemplate": "", + "enablePreview": true, + "viewPath": "/Views/Partials/Grid/Editors/DocTypeGridEditor/", + "previewViewPath": "/Views/Partials/Grid/Editors/DocTypeGridEditor/Previews/", + "previewCssFilePath": "/Views/Partials/Grid/Editors/DocTypeGridEditor/Previews/Css/dtge.css", + "previewJsFilePath": "/Views/Partials/Grid/Editors/DocTypeGridEditor/Previews/Js/dtge.js" + } +} \ No newline at end of file diff --git a/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Css/doctypegrideditor.css b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Css/doctypegrideditor.css new file mode 100644 index 0000000..1d7ba52 --- /dev/null +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Css/doctypegrideditor.css @@ -0,0 +1,14 @@ +/*.dtge-dialog fieldset legend { + display: none; +}*/ + +.dtge-dialog input.ng-invalid { + border-color: #9d261d; + -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); + box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); +} + +.dtge-dialog .help-inline { + color: #9d261d; +} \ No newline at end of file diff --git a/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js new file mode 100644 index 0000000..6530789 --- /dev/null +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js @@ -0,0 +1,240 @@ +angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.GridEditors.DocTypeGridEditor", [ + + "$scope", + "$rootScope", + "$timeout", + "$routeParams", + "editorState", + 'assetsService', + "Our.Umbraco.DocTypeGridEditor.Services.DocTypeDialogService", + "Our.Umbraco.DocTypeGridEditor.Resources.DocTypeGridEditorResources", + + function ($scope, $rootScope, $timeout, $routeParams, editorState, assetsService, dtgeDialogService, dtgeResources) { + + $scope.title = "Click to insert item"; + $scope.icon = "icon-item-arrangement"; + + $scope.setValue = function (data, callback) { + $scope.control.value = data; + if (!("id" in $scope.control.value) || $scope.control.value.id == "") { + $scope.control.value.id = guid(); + } + if ("name" in $scope.control.value.value && $scope.control.value.value.name) { + $scope.title = $scope.control.value.value.name; + } + if ("dtgeContentTypeAlias" in $scope.control.value && $scope.control.value.dtgeContentTypeAlias) { + dtgeResources.getContentTypeIcon($scope.control.value.dtgeContentTypeAlias).then(function (data2) { + if (data2.icon) { + $scope.icon = data2.icon; + } + }); + } + if (callback) + callback(); + }; + + $scope.setDocType = function () { + dtgeDialogService.open({ + editorName: $scope.control.editor.name, + allowedDocTypes: $scope.control.editor.config.allowedDocTypes || [], + nameTemplate: $scope.control.editor.config.nameTemplate, + dialogData: { + docTypeAlias: $scope.control.value.dtgeContentTypeAlias, + value: $scope.control.value.value + }, + callback: function (data) { + $scope.setValue({ + dtgeContentTypeAlias: data.docTypeAlias, + value: data.value + }); + $scope.setPreview($scope.control.value); + } + }); + }; + + $scope.setPreview = function (model) { + if ("enablePreview" in $scope.control.editor.config && $scope.control.editor.config.enablePreview) { + console.log(editorState.current); + dtgeResources.getEditorMarkupForDocTypePartial(editorState.current.id, model.id, + $scope.control.editor.alias, model.dtgeContentTypeAlias, model.value, + $scope.control.editor.config.viewPath, + $scope.control.editor.config.previewViewPath, + !!editorState.current.publishDate) + .success(function(htmlResult) { + if (htmlResult.trim().length > 0) { + $scope.preview = htmlResult; + } + }); + } + }; + + function init() { + $timeout(function () { + if ($scope.control.$initializing) { + $scope.setDocType(); + } else if ($scope.control.value) { + $scope.setPreview($scope.control.value); + } + }, 200); + } + + if ($scope.control.value) { + if (!$scope.control.value.dtgeContentTypeAlias && $scope.control.value.docType) { + $scope.control.value.dtgeContentTypeAlias = $scope.control.value.docType; + } + if ($scope.control.value.docType) { + delete $scope.control.value.docType; + } + if (isGuid($scope.control.value.dtgeContentTypeAlias)) { + dtgeResources.getContentTypeAliasByGuid($scope.control.value.dtgeContentTypeAlias).then(function(data1) { + $scope.control.value.dtgeContentTypeAlias = data1.alias; + $scope.setValue($scope.control.value, init); + }); + } else { + $scope.setValue($scope.control.value, init); + } + } else { + $scope.setValue({ + id: guid(), + dtgeContentTypeAlias: "", + value: {} + }, init); + } + + // Load preview css / js files + if ("enablePreview" in $scope.control.editor.config && $scope.control.editor.config.enablePreview) + { + if ("previewCssFilePath" in $scope.control.editor.config && $scope.control.editor.config.previewCssFilePath) { + assetsService.loadCss($scope.control.editor.config.previewCssFilePath, $scope); + }; + + if ("previewJsFilePath" in $scope.control.editor.config && $scope.control.editor.config.previewJsFilePath) { + assetsService.loadJs($scope.control.editor.config.previewJsFilePath, $scope); + } + } + + function guid() { + function s4() { + return Math.floor((1 + Math.random()) * 0x10000) + .toString(16) + .substring(1); + } + return s4() + s4() + '-' + s4() + '-' + s4() + '-' + + s4() + '-' + s4() + s4() + s4(); + } + + function isGuid(input) { + return new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$", "i").test(input.toString()); + } + + } +]); + +angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.Dialogs.DocTypeGridEditorDialog", + [ + "$scope", + "$interpolate", + "formHelper", + "contentResource", + "Our.Umbraco.DocTypeGridEditor.Resources.DocTypeGridEditorResources", + + function ($scope, $interpolate, formHelper, contentResource, dtgeResources) { + + $scope.dialogOptions = $scope.$parent.dialogOptions; + + $scope.docTypes = []; + $scope.dialogMode = "selectDocType"; + $scope.selectedDocType = null; + $scope.node = null; + + var nameExp = !!$scope.dialogOptions.nameTemplate + ? $interpolate($scope.dialogOptions.nameTemplate) + : undefined; + + $scope.selectDocType = function () { + $scope.dialogMode = "edit"; + $scope.dialogData.docTypeAlias = $scope.selectedDocType.alias; + loadNode(); + }; + + $scope.save = function () { + + // Cause form submitting + if (formHelper.submitForm({ scope: $scope, formCtrl: $scope.dtgeForm })) { + + // Copy property values to scope model value + if ($scope.node) { + var value = { + name: $scope.dialogOptions.editorName + }; + + for (var t = 0; t < $scope.node.tabs.length; t++) { + var tab = $scope.node.tabs[t]; + for (var p = 0; p < tab.properties.length; p++) { + var prop = tab.properties[p]; + if (typeof prop.value !== "function") { + value[prop.alias] = prop.value; + } + } + } + + if (nameExp) { + var newName = nameExp(value); // Run it against the stored dictionary value, NOT the node object + if (newName && (newName = $.trim(newName))) { + value.name = newName; + } + } + + $scope.dialogData.value = value; + } else { + $scope.dialogData.value = null; + } + + $scope.submit($scope.dialogData); + + } + }; + + function loadNode() { + contentResource.getScaffold(-20, $scope.dialogData.docTypeAlias).then(function (data) { + // Remove the last tab + data.tabs.pop(); + + // Merge current value + if ($scope.dialogData.value) { + for (var t = 0; t < data.tabs.length; t++) { + var tab = data.tabs[t]; + for (var p = 0; p < tab.properties.length; p++) { + var prop = tab.properties[p]; + console.log(prop.alias); + if ($scope.dialogData.value[prop.alias]) { + prop.value = $scope.dialogData.value[prop.alias]; + } + } + } + }; + + // Assign the model to scope + $scope.nodeContext = $scope.node = data; + }); + } + + if ($scope.dialogData.docTypeAlias) { + $scope.dialogMode = "edit"; + loadNode(); + } else { + $scope.dialogMode = "selectDocType"; + // No data type, so load a list to choose from + dtgeResources.getContentTypes($scope.dialogOptions.allowedDocTypes).then(function (docTypes) { + $scope.docTypes = docTypes; + if ($scope.docTypes.length == 1) { + $scope.dialogData.docTypeAlias = $scope.docTypes[0].alias; + $scope.dialogMode = "edit"; + loadNode(); + } + }); + } + + } + + ]); \ No newline at end of file diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.resources.js b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.resources.js similarity index 78% rename from Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.resources.js rename to src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.resources.js index 52ef3ec..aabf513 100644 --- a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.resources.js +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.resources.js @@ -1,7 +1,7 @@ angular.module('umbraco.resources').factory('Our.Umbraco.DocTypeGridEditor.Resources.DocTypeGridEditorResources', function ($q, $http, umbRequestHelper) { return { - getContentAliasByGuid: function (guid) { + getContentTypeAliasByGuid: function (guid) { var url = "/umbraco/backoffice/DocTypeGridEditorApi/DocTypeGridEditorApi/GetContentTypeAliasByGuid?guid=" + guid; return umbRequestHelper.resourcePromise( $http.get(url), @@ -20,8 +20,8 @@ 'Failed to retrieve content types' ); }, - getContentTypeIcon: function (guid) { - var url = "/umbraco/backoffice/DocTypeGridEditorApi/DocTypeGridEditorApi/GetContentTypeIcon?guid=" + guid; + getContentTypeIcon: function (contentTypeAlias) { + var url = "/umbraco/backoffice/DocTypeGridEditorApi/DocTypeGridEditorApi/GetContentTypeIcon?contentTypeAlias=" + contentTypeAlias; return umbRequestHelper.resourcePromise( $http.get(url), 'Failed to retrieve content type icon' @@ -34,16 +34,18 @@ 'Failed to retrieve datatypes' ); }, - getEditorMarkupForDocTypePartial: function (nodeId, id, docType, value, viewPath) { - var url = "/" + nodeId +"?dtgePreview=1"; + getEditorMarkupForDocTypePartial: function (nodeId, id, editorAlias, contentTypeAlias, value, viewPath, previewViewPath, published) { + var url = "/" + (published ? nodeId : "") + "?dtgePreview=1" + (published ? "" : "&nodeId=" + nodeId); return $http({ method: 'POST', url: url, data: $.param({ id: id, - docType: docType, + editorAlias: editorAlias, + contentTypeAlias: contentTypeAlias, value: JSON.stringify(value), - viewPath: viewPath + viewPath: viewPath, + previewViewPath: previewViewPath }), headers: { 'Content-Type': 'application/x-www-form-urlencoded' diff --git a/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.services.js b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.services.js new file mode 100644 index 0000000..256eab8 --- /dev/null +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.services.js @@ -0,0 +1,16 @@ +angular.module('umbraco.services').factory('Our.Umbraco.DocTypeGridEditor.Services.DocTypeDialogService', + function (dialogService, editorState) { + return { + open: function (options) { + + var o = $.extend({}, { + template: "/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.dialog.html", + show: true, + requireName: true, + }, options); + + // Launch the dialog + dialogService.open(o); + } + }; + }); \ No newline at end of file diff --git a/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml new file mode 100644 index 0000000..7666ce9 --- /dev/null +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml @@ -0,0 +1,30 @@ +@using System.Web.Mvc +@using System.Web.Mvc.Html +@using Microsoft.CSharp.RuntimeBinder +@using Our.Umbraco.DocTypeGridEditor.Helpers +@using Our.Umbraco.DocTypeGridEditor.Web.Extensions +@inherits Umbraco.Web.Mvc.UmbracoViewPage +@if (Model.value != null) +{ + string id = Model.value.id.ToString(); + string editorAlias = Model.editor.alias.ToString(); + string contentTypeAlias = ""; + string value = Model.value.value.ToString(); + string viewPath = Model.editor.config.viewPath.ToString(); + + try + { + contentTypeAlias = Model.value.dtgeContentTypeAlias.ToString(); + } + catch (RuntimeBinderException) + { + contentTypeAlias = Model.value.docType.ToString(); + } + + if (contentTypeAlias != "") + { + var content = DocTypeGridEditorHelper.ConvertValueToContent(id, contentTypeAlias, value); + + @Html.RenderDocTypeGridEditorItem(content, editorAlias, viewPath) + } +} diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditorPreviewer.cshtml b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditorPreviewer.cshtml similarity index 58% rename from Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditorPreviewer.cshtml rename to src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditorPreviewer.cshtml index a5e5389..9857ec0 100644 --- a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditorPreviewer.cshtml +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditorPreviewer.cshtml @@ -5,10 +5,13 @@ @inherits Umbraco.Web.Mvc.UmbracoViewPage @{ var id = Request.Form["id"]; - var docType = Request.Form["docType"]; + var editorAlias = Request.Form["editorAlias"]; + var contentTypeAlias = Request.Form["contentTypeAlias"]; var value = Request.Unvalidated.Form["value"]; var viewPath = Request.Form["viewPath"]; - var content = DocTypeGridEditorHelper.ConvertValueToContent(id, docType, value); + var previewViewPath = Request.Form["previewViewPath"]; + + var content = DocTypeGridEditorHelper.ConvertValueToContent(id, contentTypeAlias, value); - @Html.RenderDocTypeGridEditorItem(content, viewPath) + @Html.RenderDocTypeGridEditorItem(content, editorAlias, viewPath, previewViewPath) } \ No newline at end of file diff --git a/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.dialog.html b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.dialog.html new file mode 100644 index 0000000..7ba96d6 --- /dev/null +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.dialog.html @@ -0,0 +1,44 @@ + +
+ + + + +
+
\ No newline at end of file diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.html b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.html similarity index 68% rename from Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.html rename to src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.html index d7a097f..1580e29 100644 --- a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.html +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.html @@ -1,6 +1,8 @@ 
-
+
{{title}}
diff --git a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/package.manifest b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/package.manifest similarity index 75% rename from Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/package.manifest rename to src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/package.manifest index d9bdacb..bf30655 100644 --- a/Src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/package.manifest +++ b/src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/package.manifest @@ -3,5 +3,8 @@ '~/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.resources.js', '~/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.services.js', '~/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js' + ], + "css": [ + '~/App_Plugins/DocTypeGridEditor/Css/doctypegrideditor.css' ] } diff --git a/Src/Our.Umbraco.DocTypeGridEditor/app.config b/src/Our.Umbraco.DocTypeGridEditor/app.config similarity index 100% rename from Src/Our.Umbraco.DocTypeGridEditor/app.config rename to src/Our.Umbraco.DocTypeGridEditor/app.config diff --git a/Src/Our.Umbraco.DocTypeGridEditor/packages.config b/src/Our.Umbraco.DocTypeGridEditor/packages.config similarity index 100% rename from Src/Our.Umbraco.DocTypeGridEditor/packages.config rename to src/Our.Umbraco.DocTypeGridEditor/packages.config diff --git a/src/packages/repositories.config b/src/packages/repositories.config new file mode 100644 index 0000000..ea08bd3 --- /dev/null +++ b/src/packages/repositories.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file