Try our conversational search powered by Generative AI!

Episerver custom dojo widget property/attribute lookup

Vote:
 

Hi,

trying to implement a dojo widget that will prompt editor to answer yes/no after a publish. But the prompt should only appear if the page has an attribute set to true. 

This is how far I have gotten, i can subscribe to publish topic and show the prompt. But context doesn't tell me anything about properties.

[Display(
  GroupName = Global.GroupNames.Custom,
  Name = "Ask editor after publish",
  Description = "Some desc",
  Order = 1)]
public virtual bool AskEditor { get; set; }
define([
    "dojo",
    "dojo/_base/declare",
    "epi/_Module",
    "dojo/topic",
    "epi/shell/DialogService",
    "epi/dependency"
], function (
    dojo,
    declare,
    module,
    topic,
    dialogService,
    dependency
) {
    return declare([module], {
        initialize: function () {
            this.inherited(arguments);
            topic.subscribe("/epi/cms/contentdata/childrenchanged", this._onPublish);
        },

        _onPublish: function (context, caller) {

            var contextService = dependency.resolve("epi.shell.ContextService");
            var currentContext = contextService.currentContext;
            var publicUrl = currentContext.publicUrl;

            var shouldPrompt = currentContext.askEditor;

            if (shouldPrompt) {
                dialogService.confirmation({
                    title: "Do you want to do this?",
                    heading: "Answer yes or no",
                    content: "An attribute has marked this page! Proceed?",
                    description: "Some description that doesn't tell you anything",
                    iconClass: ".epi-iconUpload"
                }).then(function () {
                    alert("clicked OK");
                }).otherwise(function () {
                    alert("clicked cancel");
                });
            }
        }
    });
});

the shouldPrompt variable is just a fake example on what I wish to accomplish here.

Anyone with dojo experience care to assist?

#245944
Dec 22, 2020 13:06
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.