Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Maff 141 posts 465 karma points
    Dec 09, 2014 @ 16:18
    Maff
    0

    Problem creating custom Editor

    Hi,

    I'm following this how-to on creating a custom editor, and as far as I Can tell I'm doing everything correct, but I just can't get it to work: http://umbraco.github.io/Belle/#/tutorials/Creating-Editors-Trees

    My code class looks like this:

    [PluginController("DataExport")]
      [Umbraco.Web.Trees.Tree("DataExport", "DataExportTree", "Data Export", iconClosed: "icon-doc")]
      public class DataExportTreeController : TreeController
      {
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
          var nodes = new TreeNodeCollection();
    
          var parentNode = CreateTreeNode("exportData", id, queryStrings, "Export Data", "icon-truck", false);
    
          nodes.Add(parentNode);
    
          return nodes;
        }
    
        protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
        {
          var menu = new MenuItemCollection();
    
          return menu;
        }
      }

     

    My AngularJS controller code looks like this:

    'use strict';
    
    (function() {
      //create the controller
      function dataExportController($scope, $routeParams) {
        $scope.content = { tabs: [{ id: 1, label: "Export Organisation Data" }, { id: 2, label: "Export Member Data" }] };
      };
    
      //register the controller
      angular.module("umbraco").controller('DataExport.DataExportTree.EditController', dataExportController);
    })();

    and my edit.html view looks like this:

     

     

    <div ng-controller="DataExport.DataExportTree.EditController">
    markup goes here...
    </div>

    My App_Plugins folder structure looks like this:

    However, when I run Umbraco and navigate to my custom editor page I'm getting an error with the AngularJS Controller "Error: Argument 'DataExport.DataExportTree.EditController' is not a function, got undefined". If I take the ng-controller="DataExport.DataExportTree.EditController" tag out of my markup then the page renders with no errors (but obviously no AngularJS kicking in), so my tree configuration and paths all seem to be correct.

    The tutorial doesn't mention anything about how the javascript file is picked up by Umbraco - do I need to reference this in a .manifest file or somewhere else?

    Any clues would be greatly appreciated as I've been through this tutorial a few times now and I'm not getting anywhere... :s

     

     

     

     

     

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Dec 09, 2014 @ 16:26
    Jan Skovgaard
    0

    Hi Maff

    Not quite sure where things go wrong in the above code but just want to mention that you should try and check out the Umbraco Angular workbook at https://github.com/umbraco/AngularWorkbook there is some sample code in chapter 5 I think, which you may be able to benefit from.

    Also yes your javascript needs to be referenced in the manifest as is shown in the examples in this book as well.

    Hope this helps a bit.

    /Jan

  • Maff 141 posts 465 karma points
    Dec 09, 2014 @ 16:29
    Maff
    0

    Thanks Jan - I'll check that out!

    Maff

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Dec 09, 2014 @ 16:42
    Dave Woestenborghs
    100

    As Jan already stated you have to add the js file to your package manifest

    For some example code on creating custom sections have a look at the source code of my DUUG and UmbUkFest talks

    https://bitbucket.org/dawoe/duugcustomsections

    https://bitbucket.org/dawoe/umbukfestival2014

    And of course my slides of the DUUG talk which contains some useful links at the end :

    http://www.slideshare.net/dawoe/duug-meetup-custom-sections-v6-vs-v7

    Dave

  • Maff 141 posts 465 karma points
    Dec 09, 2014 @ 17:09
    Maff
    0

    Thanks Dave - the code in your first link helped me get it working! I think the issue was the manifest file was not in the root of my plugin, so my controller wasn't being registered...

    Thanks again :)

    Maff

Please Sign in or register to post replies

Write your reply to:

Draft