【问题标题】:Alfresco dashlet post formAlfresco dashlet post 表单
【发布时间】:2017-01-20 07:23:19
【问题描述】:

我已经在谷歌上搜索了几天,找不到任何解决我的问题的方法。

我创建了一个自定义的 Alfresco Aukai dashlet 并在其中放置了一个表单:

define(["dojo/_base/declare",
    "dijit/_WidgetBase",
    "alfresco/core/Core",
    "alfresco/core/I18nUtils",
    "alfresco/dashlets/Dashlet"],
function(declare, AlfCore, I18nUtils, Dashlet) {
    // First define a form...
    var form = {
        name: "alfresco/forms/Form",
        config: {
            showOkButton: true,
            okButtonLabel: "Save",
            showCancelButton: false,
            cancelButtonLabel: "Doesn't Matter",
            okButtonPublishTopic: "PUBLISH_TOPIC",
            okButtonPublishGlobal: true,
            widgets: []
        }
    };
// Define a text box...
    var textBox = {
        name: "alfresco/forms/controls/DojoValidationTextBox",
        config: {
            fieldId: "EMAIL",
            name: "email",
            label: "Contact",
            description: "Your e-mail address",
            placeHolder: "name@address.com",
            validationConfig: [
                {
                    validation: "regex",
                    regex: "^([0-9a-zA-Z]([-.w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-w]*[0-9a-zA-Z].)+[a-zA-Z]{2,9})$",
                    errorMessage: "Valid E-mail Address Required"
                }
            ]
        }
    };
    form.config.widgets.push(textBox);
// Define a checkbox...
    var checkbox = {
        name: "alfresco/forms/controls/DojoCheckBox",
        config: {
            fieldId: "SHOW",
            name: "showEmail",
            label: "Show E-mail",
            description: "Uncheck to hide the e-mail field",
            value: true
        }
    };
    form.config.widgets.push(checkbox);
// Update the textbox to respond to checkbox changes...
    textBox.config.visibilityConfig = {
        initialValue: true,
        rules: [
            {
                targetId: "SHOW",
                is: [true]
            }
        ]
    };
    return declare([Dashlet], {
        /*
         * Add padding to the body.
         * smallpad (4px padding), mediumpad (10px padding - recommended) and largepad (16px padding)
         */
        additionalCssClasses: "mediumpad",
        /**
         * Explicit height in pixels of the Dashlet body.
         */
        bodyHeight: 200,
        /**
         * Id that will be used to store properties for this Dashlet.
         * i.e. the Dashlet height when using the resizer.
         */
        componentId: "component.messaging-dashlet",
        /**
         * The i18n scope to use for this Dashlet.
         */
        i18nScope: "dashlets.MessagingDashlet",
        /**
         * An array of the i18n files to use with this Dashlet.
         */
        i18nRequirements: [{i18nFile: "./i18n/MessagingDashlet.properties"}],
        /**
         * The widgets to be acting as title bar actions.
         */
        widgetsForTitleBarActions: [
            {
                id: "MESSAGING_DASHLET_ACTIONS",
                name: "alfresco/html/Label",
                config: {
                    label: "Title-bar actions"
                }
            }
        ],
        /**
         * The widgets to be placed in the top toolbar.
         */
        widgetsForToolbar: [
            {
                id: "MESSAGING_DASHLET_TOOLBAR",
                name: "alfresco/html/Label",
                config: {
                    label: "Toolbar"
                }
            }
        ],
        /**
         * The widgets to be placed in the body of the dashlet.
         */
        widgetsForBody: [
            {
                id: "HELLO_DASHLET_VERTICAL_LAYOUT",
                name: "alfresco/layout/VerticalWidgets",
                config: {
                    widgetWidth: 50,
                    widgets: [
                        form
                    ]
                }
            }
        ]
    });
});

表单已显示,但“保存”按钮处于非活动状态。

检查 fire bug 时,我被告知页面上没有 javascript!

除此之外,一切正常,甚至在输入无效电子邮件地址时收到错误消息。

有什么建议吗?或者,在 dashlet 发布中的表单的工作示例会很好:)

我在尝试使用 OptionsService 填充选择框时对此进行了进一步研究。

optionsConfig: {
    publishTopic: "ALF_GET_FORM_CONTROL_OPTIONS",
    publishPayload: {
        url: url.context + "/proxy/alfresco/api/people",
        itemsAttribute: "people",
        labelAttribute: "firstName",
        valueAttribute: "userName"
    }

在调试中我可以看到这一点,但是通过网络没有任何反应,没有相应的请求发送到服务器!

这与我在帖子中遇到的问题相同,因此这表明我的代码存在更根本的问题。

【问题讨论】:

    标签: alfresco-share


    【解决方案1】:

    您的表单没有定义任何小部件/控件。

    okButtonPublishGlobal: true,
                widgets: []
    

    请参考使用 aikau 的简单 CRUD 示例,http://www.codingfreaks.net/2015/03/aikau-form-example-for-simple-student.html

    https://github.com/Alfresco/Aikau/blob/develop/aikau/src/main/resources/alfresco/reports/TopSiteContributorReport.js

    你能看看这个链接吗?

    Alfresco share 使用 Site Contributor Breakdown Dashlet,输入表单控件使用 aikau。

    【讨论】:

    • 试过这个和许多其他选项。完全重新排列的代码!添加小部件并更改小部件类型!为各种事物添加服务。在每个获得由于错误而无法加载的小面板或具有未发布的预期形式的小面板中!单击按钮时,同时使用 Firefox 和 Chrome 调试不会发生任何事情:(
    • 我一定遗漏了一些基本的东西!我已经尝试了作为指南给出的示例,但无处可去。我认为我的问题在于示例是报告并从饼图上的事件进行提交,而我想从仪表板中的表单上的按钮进行提交。我发现表格非常混乱,示例非常有限。我的任务是使用 Alfresco 作为替代 Java 系统的基础来生成概念证明。 Java 系统的主要问题是文档管理,这绝对是由 Alfresco 提供的,所以没有问题。
    • 我们希望以 Alfresco 的方式提供现有功能,以便未来新系统可以由有能力的 Alfresco 开发人员维护。所以 POC 的计划是将消息传递系统迁移到 Alfresco。这将是一个创建 MESSAGE 类型文档的 dashlet,该文档不可编辑且只能由发送和接收的人查看。有点像系统内的短信,可以附加文档。它比这更复杂,但一般的想法。
    • 别担心。只需附上表单 UI 屏幕截图,让我尝试为您提供帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多