+1-888-365-2779
Try Now
More in this section

Forums / Project Feather / Custom Designer for Custom Widget isn't registering

Custom Designer for Custom Widget isn't registering

5 posts, 1 answered
  1. Bryson
    Bryson avatar
    13 posts
    Registered:
    14 Jan 2016
    01 Feb
    Link to this post

    I've followed the custom designer tutorial so many times now. I'm at the point of giving up now. I'm attempting to have a label that uses the advanced editor and allows shared content. That's why you see all the bells and whistles from https://github.com/Sitefinity/feather-widgets/tree/master/Telerik.Sitefinity.Frontend.ContentBlock. My custom designer is not registering as the primary and I don't see it as an option in the designer window. I'm not using the standard Content Block widget because I want to have this  be in a widget. Imagine a label that's editable and allows shared content and a button in one widget. That's as basic as I can describe it. We want to allow our Content Managers free reign over the text, but have no control over the other stuff going on in a widget like that button.

    I have my model MyCustom.cs. I have MyCustomController.cs that is being called. Under Mvc->Scripts->MyCustom I have designerview-mycustom.js 

    (function ($) {
        var EMPTY_GUID = '00000000-0000-0000-0000-000000000000';
     
        var simpleViewModule = angular.module('simpleViewModule', ['designer', 'kendo.directives', 'sharedContentServices', 'sfFields', 'sfSelectors']);
        angular.module('designer').requires.push('simpleViewModule');
     
        simpleViewModule.factory('contentBlockService', ['dialogFeedbackService', 'sharedContentService', function (dialogFeedbackService, sharedContentService) {
            var contentItem;
            var properties;
     
            var unlockContentItem = function () {
                return sharedContentService.deleteTemp(properties.SharedContentID.PropertyValue);
            };
     
            var updateContentItem = function () {
                return sharedContentService.update(contentItem, properties.Content.PropertyValue, properties.ProviderName.PropertyValue);
            };
     
            return function (data) {
                properties = data;
     
                var isShared = properties.SharedContentID.PropertyValue != EMPTY_GUID;
     
                if (isShared && !contentItem) {
                    var checkOut = true;
                    return sharedContentService.get(properties.SharedContentID.PropertyValue, properties.ProviderName.PropertyValue, checkOut)
                        .then(function (data) {
                            contentItem = data;
                            if (contentItem) {
                                properties.Content.PropertyValue = contentItem.Item.Content.Value;
                                dialogFeedbackService.savingHandlers.push(updateContentItem);
                                dialogFeedbackService.cancelingHandlers.push(unlockContentItem);
                            }
                        }, function () {
                            properties.Content.PropertyValue = '';
                            properties.SharedContentID.PropertyValue = EMPTY_GUID;
                        });
                }
            };
        }]);
     
        //basic controller for the simple designer view
        simpleViewModule.controller('MyCustomCtrl', ['$scope', 'propertyService', 'sharedContentService', 'contentBlockService',
            function ($scope, propertyService, sharedContentService, contentBlockService) {
                var contentItem;
     
                // ------------------------------------------------------------------------
                // event handlers
                // ------------------------------------------------------------------------
     
                var onGetPropertiesSuccess = function (data) {
                    $scope.properties = propertyService.toAssociativeArray(data.Items);
                    $scope.isShared = $scope.properties.SharedContentID.PropertyValue != EMPTY_GUID;
     
                    kendo.bind();
     
                    if ($scope.isShared) {
                        return contentBlockService($scope.properties);
                    }
                };
     
                // ------------------------------------------------------------------------
                // scope variables and set up
                // ------------------------------------------------------------------------
     
                $scope.feedback.showLoadingIndicator = true;
     
                $scope.isShared = false;
     
                propertyService.get()
                    .then(onGetPropertiesSuccess)
                    .catch(function (data) {
                        $scope.feedback.showError = true;
                        if (data)
                            $scope.feedback.errorMessage = data.Detail;
                    })
                    .finally(function () {
                        $scope.isShared = $scope.properties.SharedContentID.PropertyValue != EMPTY_GUID;
                        $scope.feedback.showLoadingIndicator = false;
                    });
            }
        ]);
    })(jQuery);

     

    I have under Mvc->Views->MyCustom DesignerView.MyCustom.cshtml and DesignerView.MyCustom.json as embedded files. There's also Default.cshtml.

    DesignerView.MyCustom.cshtml.

    @using Telerik.Sitefinity.Frontend.Mvc.Helpers
     
    <h3>Is any of this working?</h3>
    <div ng-show="isShared" class="alert alert-warning">
        <b>@Html.Resource("ThisContentIsShared")</b> @Html.Resource("SharedContentWarning")
    </div>
    <sf-html-field class="kendo-content-block" sf-model="properties.Content.PropertyValue"></sf-html-field>

    DesignerView.MyCustom.json

    {
      "priority": 1,
      "scripts": [
        "Mvc/Scripts/ContentBlock/shared-content-services.js",
        "client-components/selectors/taxonomies/sf-taxonomy-service.js"
      ],
      "components": [ "sf-html-field" ]
    }

    "sf-html-field" is located under ResourcePackages->Bootstrap->client-components->fields->html-fields->sf-html-field.sf-cshtml

    I have the Feather nuget package and the module hasn't been enabled on the server (it breaks stuff when I do it). Can anyone see what I'm messing up?

  2. Mariush
    Mariush avatar
    43 posts
    Registered:
    08 Aug 2014
    02 Feb in reply to Bryson
    Link to this post
    Bryson said:

    I have the Feather nuget package and the module hasn't been enabled on the server (it breaks stuff when I do it). Can anyone see what I'm messing up?

    Do you mean that the Feather module hasn't been enabled?

  3. Bryson
    Bryson avatar
    13 posts
    Registered:
    14 Jan 2016
    02 Feb
    Link to this post

    The Feather Module isn't enabled. When I did it breaks things. See this guy: http://www.sitefinity.com/developer-network/forums/bugs-issues-/turning-on-feather-caused-unable-to-upgrade-database-schema-warnings-and-error

    In that case, I upgraded Feather and all of its nuget dependencies THEN turned on the Feather module. I'll try again and see if it works this time.

  4. Bryson
    Bryson avatar
    13 posts
    Registered:
    14 Jan 2016
    02 Feb
    Link to this post
    It's working now. All of it. I upgraded Feather nuget packages, built it, turned on the Feather module, the project didn't reinitialize, and all was good.
    Answered
  5. Mariush
    Mariush avatar
    43 posts
    Registered:
    08 Aug 2014
    02 Feb in reply to Bryson
    Link to this post

    Yes, without the Feather module being activated, things won't work. I am happy you resolved it, thanks for the update!

5 posts, 1 answered