DEWD for Umbraco v2.0 beta

Rating: No reviews yet
Downloads: 35
Change Set: ebd4e36d04a8
Released: Jun 14, 2013
Updated: Jun 14, 2013 by suneboeegh
Dev status: Beta Help Icon

Recommended Download

Application Eksponent.Dewd-2.0-beta.umb.zip
application, 120K, uploaded Jun 14, 2013 - 35 downloads

Release Notes

Beta'ish release of DEWD for Umbraco v2.0:
  • Refactored code base
  • You can use the new fluid configuration feature (supports dynamic compilation) or the "old school" XML file to set things up
  • SQL/TableRepository supports automatic mapping of tables
  • Lot more flexibility compared to v1.x - dynamic tree, dynamic views and fields

Tested with Microsoft SQL CE and SQL server 2008. Umbraco 4.11 and Umbraco 6.0.x. But not much more, so be cautious if you're considering using it in a production environment :)

Example of fluid configuration, which is included in the package:
<%@ Control Language="c#" %>
<%@ Implements interface="Eksponent.Dewd.Configuration.IFluidConfiguration" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="Eksponent.Dewd.Containers" %>
<%@ Import Namespace="Eksponent.Dewd.Controls" %>
<%@ Import Namespace="Eksponent.Dewd.Controls.View" %>
<%@ Import Namespace="Eksponent.Dewd.Extensions" %>
<%@ Import Namespace="Eksponent.Dewd.Fields" %>
<%@ Import Namespace="Eksponent.Dewd.Repositories.Table" %>
<%@ Import Namespace="Eksponent.Dewd.Views.Buttons" %>

<script runat="server">
    public void BuildContainerTree(IContainer root) {        
        var secureRoot = (Container)root;
        secureRoot.Allow("admin", "*"); // enable admin user access to everything as default

        // Basic editing of Languages table, with View, Editor, Fields
        root.Add(() => (new TableRepository { Name = "Languages", PrimaryKeyName = "id" })
            .SetEditor((new TableEditor { TableName = "umbracoLanguage" })
                .AddField(new Field("Iso Code", "languageISOCode"))
                .AddField(new Field("Culture Name", "languageCultureName"))
            )
            .AddView((new TableView { Name = "Default", DisableNativeButtons = false })
                .SetSql("SELECT id, [languageISOCode], [languageCultureName] FROM [umbracoLanguage]")
                )
            );

        // Automatically map fields for just one table in a SQL database
        root.Add(() => (TableRepository.CreateAutoMappedRespository("umbracoLanguage"))
            .Modify(t => t.Name = "Languages Automapped") // set new name in tree
            .Allow("admin", "ra") /* Allow admin only read and add */
            ); 

        // Editing of Languages table, with validation, custom buttons on View and Editor
        Func<object, string> CultureValidator = o =>
            {
                const string validationError = "Field {0} must contain a valid .NET culture name (eg. da-DK)";
                try { new CultureInfo((string) o); return null; } catch { return validationError; }
            };
        root.Add(() =>
             (new TableRepository { Name = "Languages Extended", PrimaryKeyName = "id" })
                 //.Modify(r => r.ConnectionString = "Custom connection string could go here.")
                 .SetEditor((new TableEditor { TableName = "umbracoLanguage" })
                    .AddField(new Field("Iso Code", "languageISOCode")
                        .AddValidator(CultureValidator)
                    )
                    .AddField(new Field("Culture Name", "languageCultureName"))
                    .AddCustomButton((new CustomButton("/umbraco/plugins/Dewd/page_add.png"))
                        .AddClickHandler((sender, args) =>
                        {
                            throw new NotImplementedException("Behold! An Exception thrown on purpose!");
                        }))
                 )
                 .AddView((new TableView { Name = "Default", SearchEnabled = true })
                    .SetSql("SELECT id, [languageISOCode], [languageCultureName] FROM [umbracoLanguage]")
                    .AddCustomButton(new ExportToExcelButton() { UseXlsExtension = true })
                    .AddCustomButton((new CustomButton("/umbraco/plugins/Eksponent.Dewd/excel.png") { AltText = "Fake button" })
                        .AddClickHandler((sender, args) =>
                        {
                            var view = Eksponent.Dewd.Context.View;
                            var multi = (ISupportsMultiSelection)view.ViewControl;
                            foreach (var rowId in multi.GetSelectedRowIDs())
                            {
                                Eksponent.Dewd.Trace.Info("Do something to row: {0}", rowId.Value);
                            }
                        }))
                    )
                .AddView((new TableView { Name = "No Buttons", DisableNativeButtons = true }
                    .SetSql("SELECT * FROM [umbracoLanguage]")
                        )
                    )
            );

        // Just a container (folder in the tree) with custom url and icon
        root.Add(() => new Container("Dashboard") { Url = "/umbraco/dashboard.aspx?app=content", Icon = "repository.gif" });

        // Container type that allows editing entire sql database without configuration.
        root.Add(() => (new TableContainer { Name = "SQL exploration" }) /* Name the parent container */
            .SetTableFilter(tableName => tableName.StartsWith("umb")) /* Take only the tables starting with "umb" */
            .Allow("admin", "r") /* Allow only read access for admin on these tables */
            );

        // File system container - browse Umbraco file system root (just for test, please don't use it for anything)
        //root.Add(() => new Eksponent.Dewd.Repositories.FileSystem.FsRepository { Name = "Files", Path = "/" });

        // See database schema information (used this during development of TableContainer) 
        //root.Add(() => new Eksponent.Dewd.Repositories.TableSchema.TableSchemaContainer { Name = "Schema" });
    }
</script>

You probably noticed that the configuration above is wrapped in a user control. You can compile the configuration into a DLL as well, but the user control approach makes on-the-fly very fast, while still having intellisense. And of course the XML configuration is still possible., schema is more or less the same as versions 1.x.

Built and released at CodeGarden13 :)

Reviews for this release

No reviews yet for this release.