dashlet 查询中的表单

Form in dashlet query

我一直在努力让 Aukai 小面板中的表格能够工作一个多星期。让它出现在仪表板上真的很容易,但我所做的一切都没有导致任何它被发送到服务器!

有没有人或认识任何人拥有在 Dashlet 中完全可用的表单?

我的不会从 OPtionsService 读取(不填充 select 的下拉列表),也不会 post 提交任何主题,只是坐在那里什么也不做。我可以在调试 window 中看到事件,但在 chrome 和 firefox 调试视图中没有网络 activity,服务器什么也不做。

dashlet 获取 js

model.jsonModel = {
    rootNodeId: args.htmlid,
    pubSubScope: instance.object.id,
    bodyHeight: "400px",
    services: [
        {   name: "alfresco/services/LoggingService",
            config: {
                loggingPreferences:{
                    enabled: true,
                    all: true
                }
            }
        },
        "alfresco/services/OptionsService"
    ],
    widgets: [
        {
            name: "alfresco/dashlets/Dashlet",
            config: {
                title: "My Messages",
                bodyHeight: args.height || null,
                componentId: instance.object.id,
                widgetsForTitleBarActions: [
                    {
                        id: "MESSAGING_DASHLET_ACTIONS",
                        name: "alfresco/html/Label",
                        config: {
                            label: "Title-bar actions"
                        }
                    }
                ],
                widgetsForToolbar: [
                    {
                        id: "MESSAGING_DASHLET_TOOLBAR",
                        name: "alfresco/html/Label",
                        config: {
                            label: "Toolbar"
                        }
                    }
                ],
                widgetsForBody: [
                    {
                        id: "HELLO_DASHLET_VERTICAL_LAYOUT",
                        name: "alfresco/layout/VerticalWidgets",
                        config: {
                            widgetWidth: "350px",
                            widgets: [
                                { name: "alfresco/forms/Form",
                                    config: {
                                        showOkButton: true,
                                        okButtonLabel: "Send",
                                        showCancelButton: false,
                                        okButtonPublishTopic: "PUBLISH_TOPIC_MESSAGE",
                                        okButtonPublishGlobal: true,
                                        widgets: [{
                                            name: "alfresco/forms/controls/TinyMCE",
                                            config: {
                                                fieldId: "MESSAGE_TEXT",
                                                name: "message",
                                                label: "Message",
                                                widgetWidth: 200
                                            }
                                        },
                                        {
                                            name: "alfresco/forms/controls/Select",
                                            config: {
                                                fieldId: "RECIPENT",
                                                name: "recipient",
                                                label: "Send to",
                                                optionsConfig:{
                                                    publishTopic: "ALF_GET_FORM_CONTROL_OPTIONS",
                                                    publishPayload: {
                                                        url: url.context + "/proxy/alfresco/api/people",
                                                        itemsAttribute: "people",
                                                        labelAttribute: "firstName",
                                                        valueAttribute: "userName"
                                                    }
                                                }
                                           }
                                        }]
                                    }
                                }
                            ]
                        }
                    },
                    {
                        name: "alfresco/logging/DebugLog",
                    }
                ]
            }
        }
    ]
};

dashlet 获取 html ftl

<@markup id="widgets">
    <@processJsonModel group="share-dashlets" rootModule="alfresco/core/Page"/>
</@>

<@markup id="html">
<div id="${args.htmlid?html}"></div>
</@>

dashlet 获取描述 xml

<webscript>
    <shortname>Dashlet</shortname>
    <description>An Aikau dashlet</description>
    <family>dashlet</family>
    <url>/dashlets/messaging</url>
</webscript>

我稍微修改了您的代码以获取用户并在下拉列表中显示。 让我尝试使用 Option Service 并为您更新。 创建了一个新函数 getUserList 并调用 /api/people 来获取数据并显示在下拉列表中。

希望现在对您有所帮助。

model.jsonModel = {
    rootNodeId: args.htmlid,
    pubSubScope: instance.object.id,
    bodyHeight: "400px",
    services: [
        {   name: "alfresco/services/LoggingService",
            config: {
                loggingPreferences:{
                    enabled: false,
                    all: true
                }
            }
        },
        "alfresco/services/OptionsService"
    ],
    widgets: [
        {
            name: "alfresco/dashlets/Dashlet",
            config: {
                title: "My Messages",
                bodyHeight: args.height || null,
                componentId: instance.object.id,
                widgetsForTitleBarActions: [
                    {
                        id: "MESSAGING_DASHLET_ACTIONS",
                        name: "alfresco/html/Label",
                        config: {
                            label: "Title-bar actions"
                        }
                    }
                ],
                widgetsForToolbar: [
                    {
                        id: "MESSAGING_DASHLET_TOOLBAR",
                        name: "alfresco/html/Label",
                        config: {
                            label: "Toolbar"
                        }
                    }
                ],
                widgetsForBody: [
                    {
                        id: "HELLO_DASHLET_VERTICAL_LAYOUT",
                        name: "alfresco/layout/VerticalWidgets",
                        config: {
                            widgetWidth: "350px",
                            widgets: [
                                { name: "alfresco/forms/Form",
                                    config: {
                                        showOkButton: true,
                                        okButtonLabel: "Send",
                                        showCancelButton: false,
                                        okButtonPublishTopic: "PUBLISH_TOPIC_MESSAGE",
                                        okButtonPublishGlobal: true,
                                        widgets: [{
                                            name: "alfresco/forms/controls/TinyMCE",
                                            config: {
                                                fieldId: "MESSAGE_TEXT",
                                                name: "message",
                                                label: "Message",
                                                widgetWidth: 200
                                            }
                                        },                                        
                                        {
                                            name: "alfresco/forms/controls/Select",
                                            config: {                                                
                                                fieldId: "RECIPENT",
                                                name: "recipient",
                                                label: "Send to",
                                                optionsConfig: {
                                                    fixed: getUsersList()
                                                },
                                                requirementConfig: {
                                                    initialValue: true
                                                }
                                            }
                                        }

                                        ]
                                    }
                                }
                            ]
                        }
                    },
                    {
                        name: "alfresco/logging/DebugLog",
                    }
                ]
            }
        }
    ]
};

function getUsersList() {
    try {
        var result = remote.call("/api/people?sortBy=fullName&dir=asc");
        var userList = [];
        if (result.status == status.STATUS_OK) {
            var rawData = JSON.parse(result);
            if (rawData && rawData.people) {
                var dummyPerson = {
                    label: "Select Recipient",
                    value: " ",
                    selected: true
                };
                userList.push(dummyPerson);
                for (var x = 0; x < rawData.people.length; x++) {
                    var item = rawData.people[x];
                    if (item.firstName != null && item.firstName != "" && item.userName.indexOf("@") == -1 && item.enabled == true) {
                        var displayName = item.firstName + " " + item.lastName;
                        var person = {
                            label: displayName,
                            value: item.userName
                        };
                        userList.push(person);
                    }
                }
            }
        } else {
            throw new Error("Unable to fetch User List " + result.status);
        }
        return userList;
    } catch(err) {
        throw new Error(err);
    }
}