[FIX] knowledge: minor fixes

Purpose
=======
Prevent users from dragging articles from Workspace/Private to Shared
section, correctly send title when creating article from command
palette, make command palette text translatable, remove mysterious
'once' file.

Task-2852908

Part-of: odoo/odoo#91430
This commit is contained in:
Fabio Barbero
2022-05-31 19:17:36 +02:00
parent af5d672084
commit 0321446caf
4 changed files with 24 additions and 28 deletions
@@ -121,21 +121,22 @@ const KnowledgeArticleFormRenderer = FormRenderer.extend(KnowledgeTreePanelMixin
});
// Allow drag and drop between sections:
const selectors = [
'section[data-section="workspace"] .o_tree',
'section[data-section="shared"] .o_tree',
this.$('section[data-section="workspace"] .o_tree').nestedSortable(
'option',
'connectWith',
'section[data-section="private"] .o_tree'
];
selectors.forEach(selector => {
// Note: An element can be connected to one selector at most.
this.$(selector).nestedSortable(
'option',
'connectWith',
`.o_tree:not(${selector})`
);
});
);
this.$('section[data-section="private"] .o_tree').nestedSortable(
'option',
'connectWith',
'section[data-section="workspace"] .o_tree'
);
// connectWith both workspace and private sections:
this.$('section[data-section="shared"] .o_tree').nestedSortable(
'option',
'connectWith',
'section[data-section="workspace"] .o_tree, section[data-section="private"] .o_tree'
);
},
/**
@@ -184,7 +185,7 @@ const KnowledgeArticleFormRenderer = FormRenderer.extend(KnowledgeTreePanelMixin
const { data } = this.state;
const $dropdown = this.$('.o_knowledge_icon > .o_article_emoji_dropdown');
$dropdown.attr('data-article-id', this.state.res_id);
$dropdown.find('.o_article_emoji').text(data.icon);
$dropdown.find('.o_article_emoji').text(data.icon || '');
},
/**
@@ -5,6 +5,7 @@ import { _lt } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { HotkeyCommandItem } from "@web/core/commands/default_providers";
import { splitCommandName } from "@web/core/commands/command_palette";
import { sprintf } from '@web/core/utils/strings';
const { Component } = owl;
@@ -60,7 +61,7 @@ commandProviderRegistry.add("knowledge", {
const articleId = await Component.env.services.rpc({
model: 'knowledge.article',
method: 'article_create',
args: [[options.searchValue]],
args: [options.searchValue],
kwargs: {
is_private: true
},
@@ -72,7 +73,7 @@ commandProviderRegistry.add("knowledge", {
}
});
},
name: "No Article found. Create \"" + options.searchValue + "\"",
name: sprintf(_lt('No Article found. Create "%s"'), options.searchValue),
props: {
articleName: options.searchValue,
},
@@ -106,20 +107,14 @@ commandProviderRegistry.add("knowledge", {
result.push({
Component: KnowledgeExtraCommand,
action() {
env.services.action.doAction({
type: "ir.actions.act_window",
res_model: "knowledge.article",
search_view_id: [false, "search"],
views: [[false, "list"]],
target: "current",
context: {
env.services.action.doAction('knowledge.knowledge_article_action', {
additionalContext: {
search_default_name: options.searchValue,
},
name: "Search Articles",
})
});
},
category: "knowledge_extra",
name: "Advanced Search",
name: _lt("Advanced Search"),
props: {
hotkey: "alt+B",
},
@@ -228,7 +228,7 @@
<field name="name">knowledge.article.view.tree</field>
<field name="model">knowledge.article</field>
<field name="arch" type="xml">
<tree default_order="is_user_favorite desc, favorite_count desc">
<tree create="0" default_order="is_user_favorite desc, favorite_count desc">
<field name="display_name"/>
<field name="is_user_favorite" widget="boolean_favorite" nolabel="1"
force_save="1" options="{'allow_order': '1'}"/>
View File