Copied to clipboard

Flag this post as spam?

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


  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Feb 05, 2019 @ 02:35
    Nicholas Westby
    0

    Archetype Label Template for nuPicker Property Editors

    Not a question. Just a bit of code some others may be interested in:

    // ALT = Archetype Label Templates.
    window.NuPickerAlt = {};
    
    /**
     * Used in Archetype as a label template to show a value for a NuPicker drop down.
     * @param {any} value The value to show the label template for.
     * @returns {Function} The function that subsequently returns a promise that resolves
     *      to the string value to show in the Archetype label.
     */
    window.NuPickerAlt.nuPickerDropDown = function (value) {
        return function ($q) {
            var deferred = $q.defer();
            if (value && value.length) {
    
                // Get the value of the nuPicker drop down. Note that this doesn't
                // seem to update until publishing the content node.
                deferred.resolve(value[0].label);
    
            } else {
                deferred.resolve(null);
            }
            return deferred.promise;
        };
    };
    

    That adds NuPickerAlt.nuPickerDropDown as an Archetype label function that shows the value of a nuPicker drop down (useful when you want to show the value of a nuPicker drop down in the header of an Archetype fieldset, such as when it's collapsed). Might work for the other nuPickers as well, but I've only tested it with the drop down.

    You can just toss this in a JavaScript file, then load the JavaScript file with a package.manifest file in App_Plugins that points to the JavaScript file (that way, it will run in the back office).

Please Sign in or register to post replies

Write your reply to:

Draft