Copied to clipboard

Flag this post as spam?

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


  • Graham 4 posts 94 karma points
    Jan 24, 2018 @ 11:54
    Graham
    0

    Property Editor Settings example not working?

    Hello, I'm new to Umbraco and to Angular, so apologies if this is a stupid question.

    I have followed the video tutorials on umbraco.tv, and am currently adding settings to a property editor: https://umbraco.tv/videos/umbraco-v7/developer/extending/property-editors/using-services/

    The code was working fine when I hard coded a character limit, but as soon as I introduce the $scope.model.config.limit, it stops working (if I look at $scope.model.config in Chrome inspector, it just says "Object", and there is no limit property).

    I can see that my limit property is there when I edit the datatype (/developer/dataTypes/edit/id), but it is not there when editing the content itself.

    I've been scratching my head (and banging it against my desk) for a while now.

    I found the download for the source code, and copied / pasted it over my own work. I also made sure my cache is cleared and application fully restarted by changing web.config. I'm not sure if it is relevant, but I am debugging through Visual Studio 2015, and I am using the latest version of Umbraco (7.7.8). I have the same problem in Chome and Firefox.

    The code, as I say, is a direct copy of what is available from the website, but for info, here it is:

    charlimit.controller.js:

    angular.module("umbraco").controller("Example.CharLimitController", function ($scope) {
    
        $scope.limitchars = function () {
            var limit = $scope.model.config.limit;
            if ($scope.model.value.length > limit) {
                $scope.info = 'You cannot write more then ' + limit + ' characters!';
                $scope.model.value = $scope.model.value.substr(0, limit);
            }
            else {
                $scope.info = 'You have ' + (limit - $scope.model.value.length) + ' characters left.';
            }
        };
    
    });
    

    charlimit.editor.html:

    <div ng-controller="Example.CharLimitController">
        <textarea cols="10" ng-model="model.value" ng-change="limitchars()"></textarea>
        <br />
        <span ng-bind="info"></span>
    </div>
    

    package.manifest:

    {
        propertyEditors: [
            {
                alias: "CharLimit",
                name: "Char limit",
                editor: {
                    view: "~/App_Plugins/Example/charlimit.editor.html"
                },
    
                prevalues: {
                    fields: [
                        {
                            label : "Number of chars",
                            description: "The number of characters to limit on",
                            key: "limit",
                            view: "number"
                        }
    
                    ]
    
                }
            }
        ],
    
        javascript: [
            "~/App_Plugins/Example/charlimit.controller.js"
        ]
    
    }
    
  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jan 24, 2018 @ 12:22
    Alex Skrypnyk
    100

    Hi Graham

    What you added property editor to the document type, did you set value for a limit configuration?

    You can do it in the add property to the docType, please, have a look at this gif:

    enter image description here

    Thanks,

    Alex

  • Graham 4 posts 94 karma points
    Jan 24, 2018 @ 12:27
    Graham
    0

    Aha! Thank you so much.

    So, what is the purpose of the setting that I did set then? The one in umbraco#/developer/dataTypes/edit/

    Is that just a red herring? Surely not?

  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jan 24, 2018 @ 12:29
    Alex Skrypnyk
    1

    The purpose of the setting that is that you can specify property editor configuration for each document type.

    If you need the same configuration for all document Type - use default configuration - https://our.umbraco.org/documentation/extending/property-editors/package-manifest#default-config

    /Alex

Please Sign in or register to post replies

Write your reply to:

Draft