gpt4 book ai didi

alfresco - 如何在 Alfresco 中自定义文档列表?

转载 作者:行者123 更新时间:2023-12-04 05:51:44 27 4
gpt4 key购买 nike

在存储库中会有不同的文档列表。即会有数据字典、用户主页、访客主页等。当我将 View 更改为“详细 View ”时,它会显示收藏、喜欢、评论链接。如果我不想显示它们,我必须在哪里修改。你能告诉我必须在哪个文件中注释不显示这些链接的代码吗?在此先感谢您。

最佳答案

我想要这个问题的“模块化”答案,这个答案是为了展示我是如何处理这个问题的。

上下文: Alfresco 4.2.f,来自 org.alfresco.maven.archetype:alfresco-amp-archetype:1.1.1 原型(prototype)的 Maven 项目,我把所有东西都放在尽可能在嵌入式 JAR 中。

为共享创建一个模块扩展(更多细节见this blog)。这是我的扩展文件:

src/main/resources/alfresco/site-data/extensions/my-custom-extension.xml

<extension>
<modules>
<module>
<id>Main module of my custom extension</id>
<version>${project.version}</version>
<auto-deploy>true</auto-deploy>
<customizations>
<customization>
<!-- Order matters here! target before source, always! -->
<targetPackageRoot>org.alfresco</targetPackageRoot>
<sourcePackageRoot>my-custom.main</sourcePackageRoot>
</customization>
</customizations>
</module>
</modules>
</extension>

在模块包的 documentlibrary 组件中,创建此 FTL 以声明 javascript:

src/main/resources/alfresco/site-webscripts/my-custom/main/components/documentlibrary/documentlist-v2.get.html.ftl

<#-- Add a Javascript declaration -->
<@markup id="my-custom-js" target="js" action="after">
<@script type="text/javascript" group="documentlibrary"
src="${url.context}/res/my-custom/main/components/documentlibrary/documentlist.js"/>
</@>

在资源 (META-INF) 中,在 documentlibrary 组件下,创建 Javascript:

src/main/resources/META-INF/my-custom/main/components/documentlibrary/documentlist.js

YAHOO.lang.augmentObject(Alfresco.DocumentList.prototype, {

// Possible values: i18nLabel, lockBanner, syncFailed, syncTransientError
// date, size, name, version, description, tags, categories
myCustomDisabledRenderers: ["description", "version", "tags"],

// Possible values: favourites, likes, comments, quickShare
myCustomDisabledSocials: ["favourites", "comments", "likes", "quickShare"],

myCustomIsSocialDisabled: function(propertyName) {
return Alfresco.util.arrayContains(
this.myCustomDisabledSocials, propertyName);
},

myCustomIsRendererDisabled: function(propertyName) {
if (Alfresco.util.arrayContains(
this.myCustomDisabledRenderers, propertyName)) {
return true;
}
// Disable the social renderer when all the social features are
// disabled
if (propertyName === "social" && this.myCustomDisabledSocials.length == 4) {
return true;
}
return false;
},

/** Helper function to disable socials
* propertyName must be one of "favourites", "comments", "likes", "quickShare"
*/
myCustomDisableSocial: function(propertyName) {
if (!Alfresco.util.arrayContains(
this.myCustomDisabledSocials, propertyName)) {
this.myCustomDisabledSocials.push(propertyName);
}
},

// Custom registerRenderer for social features, originally defined in:
// webapps/share/components/documentlibrary/documentlist.js:2134
myCustomSocialRegisterRenderer: function(record) {
var jsNode = record.jsNode;
var html = "";
// Current usage of the separator variable allow to change the order
// of the different social features (the 'if' blocks below) without
// changing their content
var separator = "";
/* Favourite / Likes / Comments */
if (!this.myCustomIsSocialDisabled("favourites")) {
html += '<span class="item item-social' + separator + '">' +
Alfresco.DocumentList.generateFavourite(this, record) +
'</span>';
separator = " item-separator";
}
if (!this.myCustomIsSocialDisabled("likes")) {
html += '<span class="item item-social' + separator + '">' +
Alfresco.DocumentList.generateLikes(this, record) +
'</span>';
separator = " item-separator";
}
if (!this.myCustomIsSocialDisabled("comments") &&
jsNode.permissions.user.CreateChildren) {
html += '<span class="item item-social' + separator + '">' +
Alfresco.DocumentList.generateComments(this, record) +
'</span>';
separator = " item-separator";
}
if (!this.myCustomIsSocialDisabled("quickShare") && !record.node.isContainer &&
Alfresco.constants.QUICKSHARE_URL) {
html += '<span class="item' + separator + '">' +
Alfresco.DocumentList.generateQuickShare(this, record) +
'</span>';
separator = " item-separator";
}

return html;
},

// Overwrite registerRenderer which was originally defined in:
// webapps/share/components/documentlibrary/documentlist.js:1789
registerRenderer: function DL_registerRenderer(propertyName, renderer) {
if (Alfresco.util.isValueSet(propertyName) &&
Alfresco.util.isValueSet(renderer) &&
!this.myCustomIsRendererDisabled(propertyName)) {
if (propertyName === "social") {
this.renderers[propertyName] = this.myCustomSocialRegisterRenderer;
} else {
this.renderers[propertyName] = renderer;
}
return true;
}
return false;
}


}, true);

然后您可以通过更新 myCustomDisabledRenderers 和/或 mySocialDisabledRenderers 来禁用链接。

这种方式还允许您创建一个模块,仅需 6 个简单的步骤即可独立禁用(例如)“对文档的评论”或“对文档的喜欢”功能!

示例,如何通过 6 个步骤制作一个仅禁用文档评论的模块

  1. 重要提示:首先从主模块的 documentlist.js 中删除“评论禁用”。

    myCustomDisabledSocials: ["favourites", "likes", "quickShare"],
  2. 创建一个具有相同结构的新模块“my-custom.nocomment”。

    <extension>
    <modules>
    <module>
    <id>Main module of my custom extension</id>
    [...]
    </module>
    <module>
    <id>No comment module of my custom extension</id>
    <version>${project.version}</version>
    <customizations>
    <customization>
    <targetPackageRoot>org.alfresco</targetPackageRoot>
    <sourcePackageRoot>my-custom.nocomment</sourcePackageRoot>
    </customization>
    </customizations>
    </module>
    </modules>
    </extension>
  3. 添加 FTL...

    src/main/resources/alfresco/site-webscripts/my-custom/nocomment/components/documentlibrary/documentlist-v2.get.html.ftl

    <#-- Add a Javascript declaration -->
    <@markup id="my-custom-js" target="js" action="after">
    <@script type="text/javascript" group="documentlibrary"
    src="${url.context}/res/my-custom/nocomment/components/documentlibrary/documentlist.js"/>
    </@>
  4. 然后是 Javascript...

    src/main/resources/META-INF/my-custom/nocomment/components/documentlibrary/documentlist.js

    Alfresco.DocumentList.prototype.myCustomDisableSocial("comment");
  5. 然后我很高兴,如果您觉得一切顺利,请鼓掌!

  6. 注意事项:

    • nocomment 模块依赖于main 模块。
    • nocomment 模块在 main 模块之后加载是很重要的(在 http://localhost:8080/share/page/modules/deploy).
    • 为了完成 nocomment 模块,您还需要从文档详细信息页面禁用评论,见下文。

禁用文档详细信息页面的评论

即使这个在其他地方有记录,这几天我花了很多时间搜索,我觉得我需要尽可能全面。

src/main/resources/alfresco/site-data/extensions/my-custom-extension.xml

将此添加到您的 my-custom.nocomment 模块声明中,您将从文档详细信息页面中删除注释表单和列表。

[...]
<module>
<id>No comment module of my custom extension</id>
[...]
<components>
<component>
<region-id>comments</region-id>
<source-id>document-details</source-id>
<scope>template</scope>
<sub-components>
<sub-component id="default">
<evaluations>
<evaluation id="guaranteedToHide">
<render>false</render>
</evaluation>
</evaluations>
</sub-component>
</sub-components>
</component>
</components>
</module>
[...]

src/main/resources/alfresco/site-webscripts/my-custom/nocomment/components/node-details/node-header.get.js

这是为了禁用文档详细信息页面标题上的按钮。

// Disable comments
for (var i = 0; i < model.widgets.length; i++) {
if (model.widgets[i].id == "NodeHeader") {
model.widgets[i].options.showComments = false;
}
}
// And since it does not work, disable comments this way too
model.showComments = "false";

注意:我没有测试这些片段,它们是在“匿名化”(基本上是重命名模块)之后从我的项目中提取的。如果您发现错误,请告诉我。

关于alfresco - 如何在 Alfresco 中自定义文档列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11115822/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com