Files
odoo_source/addons/knowledge/views/knowledge_templates_common.xml
T
Fabio Barbero 121c240dfd [IMP] knowledge: merge read only and edit article template
Purpose
=======
Clean up templates to avoid duplicate code for article sidebar.

Task-2852908

Part-of: odoo/odoo#91430
2022-05-31 19:17:36 +02:00

72 lines
4.0 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="knowledge_article_tree_favorites">
<section class="o_favorite_container" t-if="favorites">
<div class="h4 mb-0">Favorites</div>
<ul class="o_tree_favorite">
<t t-call="knowledge.articles_template">
<t t-set="articles" t-value="favorites.mapped('article_id')"/>
<t t-set="hideChildren" t-value="true"/>
</t>
</ul>
</section>
<section class="o_favorite_container" t-else=""/>
</template>
<template id="articles_template">
<t t-set="unfolded_articles" t-value="unfolded_articles or []"/>
<t t-foreach="articles" t-as="article">
<t t-set="readonly" t-value="portal_readonly_mode or not article.user_has_write_access"/>
<t t-set="favorite" t-value="favorites.filtered(lambda f: f.article_id == article) if favorites else False"/>
<!-- readonly is used to for the drag and drop cancel.-->
<li t-attf-class="o_article #{ 'readonly' if readonly else '' }" t-attf-id="article_#{article.id}"
t-att-data-article-id="article.id" t-att-data-parent-id="article.parent_id.id"
t-att-data-favorite-article-id="favorite.id if favorite else False"
t-att-data-category="article.category">
<t t-set="isActive" t-value="article.id == active_article.id if active_article else False"/>
<div t-attf-class="#{ '' if readonly else 'o_article_handle' } d-flex align-items-center #{ 'o_article_active font-weight-bold' if isActive else 'text-muted' }">
<button t-if="not hideChildren and article.child_ids" class="o_article_caret btn btn-link text-muted p-0" type="button">
<i t-if="article.child_ids" t-att-class="'align-self-center fa fa-fw fa-caret-' + ('down' if article.id in unfolded_articles else 'right')"/>
<i t-else="" class="pl-3 align-self-center"/>
</button>
<t t-call="knowledge.articles_template_name"/>
</div>
<ul t-if="not hideChildren and article.child_ids and article.id in unfolded_articles">
<t t-call="knowledge.articles_template">
<t t-set="articles" t-value="article.child_ids.sorted('sequence')"/>
</t>
</ul>
</li>
</t>
</template>
<template id="articles_template_name">
<t t-if="not portal_readonly_mode">
<div class="o_article_emoji_dropdown dropdown" t-att-data-article-id="article.id">
<a t-attf-class="o_article_emoji p-1 {{'o_article_emoji_active text-900' if isActive else ''}}" type="button"
t-attf-id="o_article_emoji_dropdown_#{article.id}" data-toggle="dropdown" aria-expanded="true"
t-if="not readonly and not article.is_locked">
<t t-if="article.icon" t-out="article.icon"/>
<t t-else="">📄</t>
</a>
<a t-else="" class="p-1">
<t t-if="article.icon" t-out="article.icon"/>
<t t-else="">📄</t>
</a>
<div class="o_article_emoji_dropdown_panel dropdown-menu rounded p-0" role="menu"
t-attf-aria-labelledby="o_article_emoji_dropdown_#{article.id}"/>
</div>
<div class="o_article_name flex-grow-1 text-truncate o_cursor_pointer" t-out="article.name"/>
<button t-if="not hideChildren and not readonly" class="o_article_create btn p-0 opacity-75 opacity-100-hover" type="button">
<i class="fa fa-fw fa-plus" title="Create a nested article" />
</button>
</t>
<div class="o_article_name flex-grow-1 text-truncate o_cursor_pointer" t-else="">
<a t-out="article.display_name" t-attf-href="/knowledge/article/{{article.id}}" class="text-decoration-none"/>
</div>
</template>
</data>
</odoo>