From 8925df7e75c853fa0c7a66efb7a06cf80dcf90f0 Mon Sep 17 00:00:00 2001 From: xO-Tx Date: Mon, 25 Apr 2022 18:18:52 +0200 Subject: [PATCH] [IMP] website, *: add new content dialogs *: website_blog, website_event, website_forum, website_livechat, website_sale, website_sale_slides, website_slides, website_slides_forum The goal of this commit is to add dialogs to create new website content using a 'target:new' action on the form view and an overridable "website" form controller. See merge commit for more information. task-2687506 --- addons/website/__manifest__.py | 1 + .../website/static/src/js/new_content_form.js | 24 ++++++ .../static/src/systray_items/new_content.js | 1 + addons/website_blog/__manifest__.py | 2 +- addons/website_blog/models/website_blog.py | 2 +- .../js/systray_items/blog_post_add_form.js | 13 ++++ .../src/js/systray_items/new_content.js | 10 ++- addons/website_blog/views/blog_post_add.xml | 26 +++++++ addons/website_event/__manifest__.py | 6 +- .../js/systray_items/event_event_add_form.js | 13 ++++ .../src/js/systray_items/new_content.js | 10 ++- .../website_event/views/event_event_add.xml | 67 ++++++++-------- addons/website_forum/__manifest__.py | 4 +- .../js/systray_items/forum_forum_add_form.js | 27 +++++++ .../src/js/systray_items/new_content.js | 10 ++- .../website_forum/views/forum_forum_add.xml | 78 +++++++------------ addons/website_livechat/__manifest__.py | 2 + .../im_livechat_channel_add_form.js | 13 ++++ .../src/js/systray_items/new_content.js | 10 ++- .../views/im_livechat_channel_add.xml | 25 ++++++ addons/website_sale/__manifest__.py | 5 +- .../src/js/systray_items/new_content.js | 44 ++--------- .../systray_items/product_product_add_form.js | 27 +++++++ .../views/product_product_add.xml | 25 ++++++ addons/website_sale_slides/__manifest__.py | 3 - .../src/js/website_sale_slides_editor.js | 26 ------- .../static/src/xml/website_slides_channel.xml | 52 ------------- .../views/slide_channel_views.xml | 15 ++++ addons/website_slides/__manifest__.py | 6 +- .../src/js/systray_items/new_content.js | 10 ++- .../systray_items/slide_channel_add_form.js | 27 +++++++ .../views/slide_channel_add.xml | 76 +++++++----------- .../views/website_slides_templates_utils.xml | 11 --- addons/website_slides_forum/__manifest__.py | 5 -- .../src/js/website_slides_forum.editor.js | 11 --- .../src/xml/website_slides_forum_channel.xml | 14 ---- .../views/slide_channel_views.xml | 14 ++++ 37 files changed, 402 insertions(+), 313 deletions(-) create mode 100644 addons/website/static/src/js/new_content_form.js create mode 100644 addons/website_blog/static/src/js/systray_items/blog_post_add_form.js create mode 100644 addons/website_blog/views/blog_post_add.xml create mode 100644 addons/website_event/static/src/js/systray_items/event_event_add_form.js create mode 100644 addons/website_forum/static/src/js/systray_items/forum_forum_add_form.js create mode 100644 addons/website_livechat/static/src/js/systray_items/im_livechat_channel_add_form.js create mode 100644 addons/website_livechat/views/im_livechat_channel_add.xml create mode 100644 addons/website_sale/static/src/js/systray_items/product_product_add_form.js create mode 100644 addons/website_sale/views/product_product_add.xml delete mode 100644 addons/website_sale_slides/static/src/js/website_sale_slides_editor.js delete mode 100644 addons/website_sale_slides/static/src/xml/website_slides_channel.xml create mode 100644 addons/website_slides/static/src/js/systray_items/slide_channel_add_form.js delete mode 100644 addons/website_slides_forum/static/src/js/website_slides_forum.editor.js delete mode 100644 addons/website_slides_forum/static/src/xml/website_slides_forum_channel.xml diff --git a/addons/website/__manifest__.py b/addons/website/__manifest__.py index fdc8bfc5acc..7a21fd85a19 100644 --- a/addons/website/__manifest__.py +++ b/addons/website/__manifest__.py @@ -182,6 +182,7 @@ 'website/static/src/components/fullscreen_indication/fullscreen_indication.scss', 'website/static/src/systray_items/*.js', 'website/static/src/systray_items/*.scss', + 'website/static/src/js/new_content_form.js', ], 'web.qunit_suite_tests': [ 'website/static/tests/dashboard_tests.js', diff --git a/addons/website/static/src/js/new_content_form.js b/addons/website/static/src/js/new_content_form.js new file mode 100644 index 00000000000..81ded8295fa --- /dev/null +++ b/addons/website/static/src/js/new_content_form.js @@ -0,0 +1,24 @@ +/** @odoo-module **/ + +import FormController from 'web.FormController'; + +export const NewContentFormController = FormController.extend({ + /** + * @override + */ + saveRecord() { + return this._super.apply(this, arguments).then(() => { + const state = this.model.get(this.handle); + this.do_action({ + type: 'ir.actions.act_window_close', + infos: {path: this._getPath(state)}, + }); + }); + }, + /** + * @private + */ + _getPath(state) { + return state.data.website_url; + } +}); diff --git a/addons/website/static/src/systray_items/new_content.js b/addons/website/static/src/systray_items/new_content.js index 0fcb3dcd6bf..03b89741e8e 100644 --- a/addons/website/static/src/systray_items/new_content.js +++ b/addons/website/static/src/systray_items/new_content.js @@ -44,6 +44,7 @@ export class NewContentModal extends Component { this.rpc = useService('rpc'); this.dialogs = useService('dialog'); this.website = useService('website'); + this.action = useService('action'); this.isSystem = this.user.isSystem; this.newContentText = { diff --git a/addons/website_blog/__manifest__.py b/addons/website_blog/__manifest__.py index a9b83797ab4..c2d6f5e5ed4 100644 --- a/addons/website_blog/__manifest__.py +++ b/addons/website_blog/__manifest__.py @@ -20,6 +20,7 @@ 'views/website_blog_templates.xml', 'views/snippets/snippets.xml', 'views/snippets/s_blog_posts.xml', + 'views/blog_post_add.xml', 'security/ir.model.access.csv', 'security/website_blog_security.xml', ], @@ -35,7 +36,6 @@ 'website_blog/static/src/snippets/s_blog_posts/options.js', ], 'website.assets_editor': [ - 'website_blog/static/src/js/systray_items/new_content.js', 'website_blog/static/src/js/tours/website_blog.js', ], 'web.assets_frontend': [ diff --git a/addons/website_blog/models/website_blog.py b/addons/website_blog/models/website_blog.py index 60e72c5e98f..01842c37a73 100644 --- a/addons/website_blog/models/website_blog.py +++ b/addons/website_blog/models/website_blog.py @@ -172,7 +172,7 @@ class BlogPost(models.Model): author_avatar = fields.Binary(related='author_id.image_128', string="Avatar", readonly=False) author_name = fields.Char(related='author_id.display_name', string="Author Name", readonly=False, store=True) active = fields.Boolean('Active', default=True) - blog_id = fields.Many2one('blog.blog', 'Blog', required=True, ondelete='cascade') + blog_id = fields.Many2one('blog.blog', 'Blog', required=True, ondelete='cascade', default=lambda self: self.env['blog.blog'].search([], limit=1)) tag_ids = fields.Many2many('blog.tag', string='Tags') content = fields.Html('Content', default=_default_content, translate=html_translate, sanitize=False) teaser = fields.Text('Teaser', compute='_compute_teaser', inverse='_set_teaser') diff --git a/addons/website_blog/static/src/js/systray_items/blog_post_add_form.js b/addons/website_blog/static/src/js/systray_items/blog_post_add_form.js new file mode 100644 index 00000000000..d1b53f6b043 --- /dev/null +++ b/addons/website_blog/static/src/js/systray_items/blog_post_add_form.js @@ -0,0 +1,13 @@ +/** @odoo-module **/ + +import {NewContentFormController} from '@website/js/new_content_form'; +import viewRegistry from 'web.view_registry'; +import FormView from 'web.FormView'; + +export const AddBlogFormView = FormView.extend({ + config: _.extend({}, FormView.prototype.config, { + Controller: NewContentFormController, + }), +}); + +viewRegistry.add('website_blog_add_form', AddBlogFormView); diff --git a/addons/website_blog/static/src/js/systray_items/new_content.js b/addons/website_blog/static/src/js/systray_items/new_content.js index a9c015f3522..08b73ca119b 100644 --- a/addons/website_blog/static/src/js/systray_items/new_content.js +++ b/addons/website_blog/static/src/js/systray_items/new_content.js @@ -12,5 +12,13 @@ patch(NewContentModal.prototype, 'website_blog_new_content', { newBlogElement.status = MODULE_STATUS.INSTALLED; }, - createNewBlogPost() {} + async createNewBlogPost() { + this.action.doAction('website_blog.blog_post_action_add', { + onClose: (data) => { + if (data) { + this.website.goToWebsite({path: data.path, edition: true}); + } + }, + }); + } }); diff --git a/addons/website_blog/views/blog_post_add.xml b/addons/website_blog/views/blog_post_add.xml new file mode 100644 index 00000000000..6e46719085f --- /dev/null +++ b/addons/website_blog/views/blog_post_add.xml @@ -0,0 +1,26 @@ + + + + + blog.post.view.form.add + blog.post + +
+ + + + + +
+
+
+ + + New Blog Post + blog.post + form + new + + + +
diff --git a/addons/website_event/__manifest__.py b/addons/website_event/__manifest__.py index 8d1f25dffdd..52998d71b26 100644 --- a/addons/website_event/__manifest__.py +++ b/addons/website_event/__manifest__.py @@ -34,6 +34,7 @@ 'views/website_event_menu_views.xml', 'views/website_visitor_views.xml', 'views/event_menus.xml', + 'views/event_event_add.xml', 'security/ir.model.access.csv', 'security/event_security.xml', ], @@ -60,14 +61,11 @@ 'website_event/static/src/js/website_event_ticket_details.js', 'website_event/static/src/snippets/options.js', ], - 'website.assets_editor': [ - 'website_event/static/src/js/systray_items/new_content.js', - ], 'website.assets_wysiwyg': [ '/website_event/static/src/snippets/s_events/options.js', ], 'web.assets_backend': [ - 'website_event/static/src/js/systray_items/new_content.js', + 'website_event/static/src/js/systray_items/*.js', ], }, 'license': 'LGPL-3', diff --git a/addons/website_event/static/src/js/systray_items/event_event_add_form.js b/addons/website_event/static/src/js/systray_items/event_event_add_form.js new file mode 100644 index 00000000000..f845d9d5bd6 --- /dev/null +++ b/addons/website_event/static/src/js/systray_items/event_event_add_form.js @@ -0,0 +1,13 @@ +/** @odoo-module **/ + +import {NewContentFormController} from '@website/js/new_content_form'; +import viewRegistry from 'web.view_registry'; +import FormView from 'web.FormView'; + +export const AddEventFormView = FormView.extend({ + config: _.extend({}, FormView.prototype.config, { + Controller: NewContentFormController, + }), +}); + +viewRegistry.add('event_event_add_form', AddEventFormView); diff --git a/addons/website_event/static/src/js/systray_items/new_content.js b/addons/website_event/static/src/js/systray_items/new_content.js index c05c1aa8270..34d47fdd3dc 100644 --- a/addons/website_event/static/src/js/systray_items/new_content.js +++ b/addons/website_event/static/src/js/systray_items/new_content.js @@ -12,5 +12,13 @@ patch(NewContentModal.prototype, 'website_event_new_content', { newEventElement.status = MODULE_STATUS.INSTALLED; }, - createNewEvent() {} + createNewEvent() { + this.action.doAction('website_event.event_event_action_add', { + onClose: (data) => { + if (data) { + this.website.goToWebsite({path: data.path, edition: true}); + } + }, + }); + } }); diff --git a/addons/website_event/views/event_event_add.xml b/addons/website_event/views/event_event_add.xml index 5119f8578ec..3bd8137a440 100644 --- a/addons/website_event/views/event_event_add.xml +++ b/addons/website_event/views/event_event_add.xml @@ -1,37 +1,34 @@ - - - -
-
- -
- + + + + + event.event.view.form.add + event.event + + + + + + + +
-
- -
- -
-
-
- -
- -
-

Please fill in this field

-
-
- -
- -
-

Please fill in this field

-
+ - - + + + + + New Event + event.event + form + new + + {'default_address_id': False} + + + diff --git a/addons/website_forum/__manifest__.py b/addons/website_forum/__manifest__.py index 676e7fe4da0..c079d80deb0 100644 --- a/addons/website_forum/__manifest__.py +++ b/addons/website_forum/__manifest__.py @@ -27,6 +27,7 @@ Ask questions, get answers, no distractions 'views/website_forum_profile.xml', 'views/ir_qweb.xml', 'views/snippets/snippets.xml', + 'views/forum_forum_add.xml', 'security/ir.model.access.csv', 'security/website_forum_security.xml', 'data/badges_question.xml', @@ -42,7 +43,6 @@ Ask questions, get answers, no distractions 'assets': { 'website.assets_editor': [ 'website_forum/static/src/js/tours/website_forum.js', - 'website_forum/static/src/js/systray_items/new_content.js', ], 'web.assets_tests': [ 'website_forum/static/tests/**/*', @@ -53,7 +53,7 @@ Ask questions, get answers, no distractions 'website_forum/static/src/js/website_forum.share.js', ], 'web.assets_backend': [ - 'website_forum/static/src/js/systray_items/new_content.js', + 'website_forum/static/src/js/systray_items/*.js', ], 'web.assets_qweb': [ 'website_forum/static/src/xml/*.xml', diff --git a/addons/website_forum/static/src/js/systray_items/forum_forum_add_form.js b/addons/website_forum/static/src/js/systray_items/forum_forum_add_form.js new file mode 100644 index 00000000000..b166ea16924 --- /dev/null +++ b/addons/website_forum/static/src/js/systray_items/forum_forum_add_form.js @@ -0,0 +1,27 @@ +/** @odoo-module **/ + +import {NewContentFormController} from '@website/js/new_content_form'; +import viewRegistry from 'web.view_registry'; +import FormView from 'web.FormView'; + +const AddForumFormController = NewContentFormController.extend({ + /** + * @override + */ + _getPath(state) { + return `/forum/${state.data.id}`; + }, +}); + +const AddForumFormView = FormView.extend({ + config: _.extend({}, FormView.prototype.config, { + Controller: AddForumFormController, + }), +}); + +viewRegistry.add('website_forum_add_form', AddForumFormView); + +export default { + AddForumFormController: AddForumFormController, + AddForumFormView: AddForumFormView, +}; diff --git a/addons/website_forum/static/src/js/systray_items/new_content.js b/addons/website_forum/static/src/js/systray_items/new_content.js index 532856fe8a8..ef1bf04dc71 100644 --- a/addons/website_forum/static/src/js/systray_items/new_content.js +++ b/addons/website_forum/static/src/js/systray_items/new_content.js @@ -12,5 +12,13 @@ patch(NewContentModal.prototype, 'website_forum_new_content', { newForumElement.status = MODULE_STATUS.INSTALLED; }, - createNewForum() {} + createNewForum() { + this.action.doAction('website_forum.forum_forum_action_add', { + onClose: (data) => { + if (data) { + this.website.goToWebsite({path: data.path}); + } + }, + }); + } }); diff --git a/addons/website_forum/views/forum_forum_add.xml b/addons/website_forum/views/forum_forum_add.xml index aedc6223079..9d7798482ff 100644 --- a/addons/website_forum/views/forum_forum_add.xml +++ b/addons/website_forum/views/forum_forum_add.xml @@ -1,53 +1,27 @@ - - - -
-
- -
- -
- - -
-
-
-
- -
-
- - -
-
- - -
-
-
-
- -
-
- - -
-
- - -
-
- - -
-
- -

Please fill in this field

-
-
-
+ + + + + forum.forum.view.form.add + forum.forum + + + + + + + + -
-
+ + + + + New Forum + forum.forum + form + new + + + + diff --git a/addons/website_livechat/__manifest__.py b/addons/website_livechat/__manifest__.py index dea83dfcf48..bd72bc35dbf 100644 --- a/addons/website_livechat/__manifest__.py +++ b/addons/website_livechat/__manifest__.py @@ -16,6 +16,7 @@ Allow website visitors to chat with the collaborators. This module also brings a 'views/im_livechat_chatbot_script_view.xml', 'views/website_livechat_view.xml', 'views/website_visitor_views.xml', + 'views/im_livechat_channel_add.xml', 'security/ir.model.access.csv', 'security/website_livechat.xml', 'data/website_livechat_data.xml', @@ -42,6 +43,7 @@ Allow website visitors to chat with the collaborators. This module also brings a 'website_livechat/static/src/components/*/*.scss', 'website_livechat/static/src/models/*.js', 'website_livechat/static/src/js/systray_items/new_content.js', + 'website_livechat/static/src/js/systray_items/*.js', ], 'web.assets_tests': [ 'website_livechat/static/tests/tours/**/*', diff --git a/addons/website_livechat/static/src/js/systray_items/im_livechat_channel_add_form.js b/addons/website_livechat/static/src/js/systray_items/im_livechat_channel_add_form.js new file mode 100644 index 00000000000..02cdfb7c9dc --- /dev/null +++ b/addons/website_livechat/static/src/js/systray_items/im_livechat_channel_add_form.js @@ -0,0 +1,13 @@ +/** @odoo-module **/ + +import {NewContentFormController} from '@website/js/new_content_form'; +import viewRegistry from 'web.view_registry'; +import FormView from 'web.FormView'; + +export const AddChannelFormView = FormView.extend({ + config: _.extend({}, FormView.prototype.config, { + Controller: NewContentFormController, + }), +}); + +viewRegistry.add('website_livechat_add_form', AddChannelFormView); diff --git a/addons/website_livechat/static/src/js/systray_items/new_content.js b/addons/website_livechat/static/src/js/systray_items/new_content.js index 46a2b933a97..e90f3364c48 100644 --- a/addons/website_livechat/static/src/js/systray_items/new_content.js +++ b/addons/website_livechat/static/src/js/systray_items/new_content.js @@ -12,5 +12,13 @@ patch(NewContentModal.prototype, 'website_livechat_new_content', { newChannelElement.status = MODULE_STATUS.INSTALLED; }, - createNewChannel() {} + createNewChannel() { + this.action.doAction('website_livechat.im_livechat_channel_action_add', { + onClose: (data) => { + if (data) { + this.website.goToWebsite({path: data.path}); + } + }, + }); + } }); diff --git a/addons/website_livechat/views/im_livechat_channel_add.xml b/addons/website_livechat/views/im_livechat_channel_add.xml new file mode 100644 index 00000000000..da0e966600e --- /dev/null +++ b/addons/website_livechat/views/im_livechat_channel_add.xml @@ -0,0 +1,25 @@ + + + + + im_livechat.channel.view.form.add + im_livechat.channel + +
+ + + + +
+
+
+ + + New Channel + im_livechat.channel + form + new + + + +
diff --git a/addons/website_sale/__manifest__.py b/addons/website_sale/__manifest__.py index fa0fa3fb868..b1851122509 100644 --- a/addons/website_sale/__manifest__.py +++ b/addons/website_sale/__manifest__.py @@ -29,7 +29,8 @@ 'views/res_config_settings_views.xml', 'views/digest_views.xml', 'views/website_sale_visitor_views.xml', - 'views/base_unit_view.xml' + 'views/base_unit_view.xml', + 'views/product_product_add.xml', ], 'demo': [ 'data/demo.xml', @@ -66,7 +67,7 @@ 'website_sale/static/src/scss/website_sale_dashboard.scss', 'website_sale/static/src/scss/website_sale_backend.scss', 'website_sale/static/src/js/tours/website_sale_shop_backend.js', - 'website_sale/static/src/js/systray_items/new_content.js', + 'website_sale/static/src/js/systray_items/*.js', ], 'website.assets_wysiwyg': [ 'website_sale/static/src/scss/website_sale.editor.scss', diff --git a/addons/website_sale/static/src/js/systray_items/new_content.js b/addons/website_sale/static/src/js/systray_items/new_content.js index f4754321856..32dbdca28ff 100644 --- a/addons/website_sale/static/src/js/systray_items/new_content.js +++ b/addons/website_sale/static/src/js/systray_items/new_content.js @@ -2,39 +2,6 @@ import { NewContentModal, MODULE_STATUS } from '@website/systray_items/new_content'; import { patch } from 'web.utils'; -import { WebsiteDialog } from '@website/components/dialog/dialog'; - -const { xml, useState } = owl; - -export class AddProductDialog extends WebsiteDialog { - setup() { - super.setup(); - - this.title = this.env._t("New Product"); - this.primaryTitle = this.env._t("Create"); - - this.state = useState({ - name: '', - }); - } - - async primaryClick() { - await this.props.addProduct(this.state.name); - this.close(); - } -} -AddProductDialog.bodyTemplate = xml` -
-
- -
- -
-
-
-`; patch(NewContentModal.prototype, 'website_sale_new_content', { setup() { @@ -46,12 +13,11 @@ patch(NewContentModal.prototype, 'website_sale_new_content', { }, createNewProduct() { - this.dialogs.add(AddProductDialog, { - addProduct: async (name) => { - const url = await this.rpc('/shop/add_product', { - name, - }); - this.website.goToWebsite({ path: url }); + this.action.doAction('website_sale.product_product_action_add', { + onClose: (data) => { + if (data) { + this.website.goToWebsite({path: data.path, edition: true}); + } }, }); } diff --git a/addons/website_sale/static/src/js/systray_items/product_product_add_form.js b/addons/website_sale/static/src/js/systray_items/product_product_add_form.js new file mode 100644 index 00000000000..c90f6f01ad8 --- /dev/null +++ b/addons/website_sale/static/src/js/systray_items/product_product_add_form.js @@ -0,0 +1,27 @@ +/** @odoo-module **/ + +import {NewContentFormController} from '@website/js/new_content_form'; +import viewRegistry from 'web.view_registry'; +import FormView from 'web.FormView'; + +const AddProductFormController = NewContentFormController.extend({ + /** + * @override + */ + _getPath(state) { + return state.data.website_url.split('#')[0]; + }, +}); + +const AddProductFormView = FormView.extend({ + config: _.extend({}, FormView.prototype.config, { + Controller: AddProductFormController, + }), +}); + +viewRegistry.add('product_product_add_form', AddProductFormView); + +export default { + AddProductFormController: AddProductFormController, + AddProductFormView: AddProductFormView, +}; diff --git a/addons/website_sale/views/product_product_add.xml b/addons/website_sale/views/product_product_add.xml new file mode 100644 index 00000000000..6c2cddea6f8 --- /dev/null +++ b/addons/website_sale/views/product_product_add.xml @@ -0,0 +1,25 @@ + + + + + product.product.view.form.add + product.product + +
+ + + + +
+
+
+ + + New Product + product.product + form + new + + + +
diff --git a/addons/website_sale_slides/__manifest__.py b/addons/website_sale_slides/__manifest__.py index 3ef082aca44..b3bd40e04d6 100644 --- a/addons/website_sale_slides/__manifest__.py +++ b/addons/website_sale_slides/__manifest__.py @@ -26,9 +26,6 @@ 'web.assets_frontend': [ 'website_sale_slides/static/src/js/**/*', ], - 'web.assets_qweb': [ - 'website_sale_slides/static/src/xml/website_slides_channel.xml', - ] }, 'license': 'LGPL-3', } diff --git a/addons/website_sale_slides/static/src/js/website_sale_slides_editor.js b/addons/website_sale_slides/static/src/js/website_sale_slides_editor.js deleted file mode 100644 index cd206976c5d..00000000000 --- a/addons/website_sale_slides/static/src/js/website_sale_slides_editor.js +++ /dev/null @@ -1,26 +0,0 @@ -/** @odoo-module **/ - -import {ChannelCreateDialog} from '@website_slides/js/systray_items/new_content'; - -ChannelCreateDialog.include({ - xmlDependencies: ChannelCreateDialog.prototype.xmlDependencies.concat( - ['/website_sale_slides/static/src/xml/website_slides_channel.xml'] - ), - - events: _.extend({}, ChannelCreateDialog.prototype.events, { - 'change input[name="enroll"]': '_onEnrollChanged', - }), - - willStart: async function () { - await this._super(); - - this.products = await this._rpc({route: '/slides/get_course_products'}); - }, - - /** - * @private - */ - _onEnrollChanged: function (ev) { - this.$('.o_wslides_course_products').toggleClass('d-none', ev.target.value !== 'payment'); - }, -}); diff --git a/addons/website_sale_slides/static/src/xml/website_slides_channel.xml b/addons/website_sale_slides/static/src/xml/website_slides_channel.xml deleted file mode 100644 index 1b03ebccf96..00000000000 --- a/addons/website_sale_slides/static/src/xml/website_slides_channel.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - -
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
- -
- -
-
-
-
diff --git a/addons/website_sale_slides/views/slide_channel_views.xml b/addons/website_sale_slides/views/slide_channel_views.xml index 4befb6d5a56..8724780df8e 100644 --- a/addons/website_sale_slides/views/slide_channel_views.xml +++ b/addons/website_sale_slides/views/slide_channel_views.xml @@ -49,4 +49,19 @@ + + + slide.channel.view.form.add.inherit.sale.slides + slide.channel + + + + + + + + + + diff --git a/addons/website_slides/__manifest__.py b/addons/website_slides/__manifest__.py index bfbf938b2ce..fd03d904421 100644 --- a/addons/website_slides/__manifest__.py +++ b/addons/website_slides/__manifest__.py @@ -47,6 +47,7 @@ Featuring 'views/website_slides_templates_lesson_embed.xml', 'views/website_slides_templates_profile.xml', 'views/website_slides_templates_utils.xml', + 'views/slide_channel_add.xml', 'wizard/slide_channel_invite_views.xml', 'data/gamification_data.xml', 'data/mail_data.xml', @@ -70,7 +71,7 @@ Featuring 'website_slides/static/src/js/slide_category_one2many.js', 'website_slides/static/src/js/rating_field_backend.js', 'website_slides/static/src/models/*.js', - 'website_slides/static/src/js/systray_items/new_content.js', + 'website_slides/static/src/js/systray_items/*.js', ], 'web.assets_frontend': [ 'website_slides/static/src/scss/website_slides.scss', @@ -100,9 +101,6 @@ Featuring 'web.assets_tests': [ 'website_slides/static/tests/tours/*.js', ], - 'website.assets_editor': [ - 'website_slides/static/src/js/systray_items/new_content.js', - ], 'website_slides.slide_embed_assets': [ ('include', 'web._assets_helpers'), 'web/static/lib/bootstrap/scss/_variables.scss', diff --git a/addons/website_slides/static/src/js/systray_items/new_content.js b/addons/website_slides/static/src/js/systray_items/new_content.js index c5ea11000bb..8b3159a0f3c 100644 --- a/addons/website_slides/static/src/js/systray_items/new_content.js +++ b/addons/website_slides/static/src/js/systray_items/new_content.js @@ -12,5 +12,13 @@ patch(NewContentModal.prototype, 'website_slides_new_content', { newSlidesChannelElement.status = MODULE_STATUS.INSTALLED; }, - createNewSlidesChannel() {} + createNewSlidesChannel() { + this.action.doAction('website_slides.slide_channel_action_add', { + onClose: (data) => { + if (data) { + this.website.goToWebsite({path: data.path}); + } + }, + }); + } }); diff --git a/addons/website_slides/static/src/js/systray_items/slide_channel_add_form.js b/addons/website_slides/static/src/js/systray_items/slide_channel_add_form.js new file mode 100644 index 00000000000..be7600df403 --- /dev/null +++ b/addons/website_slides/static/src/js/systray_items/slide_channel_add_form.js @@ -0,0 +1,27 @@ +/** @odoo-module **/ + +import {NewContentFormController} from '@website/js/new_content_form'; +import viewRegistry from 'web.view_registry'; +import FormView from 'web.FormView'; + +const AddCourseFormController = NewContentFormController.extend({ + /** + * @override + */ + _getPath(state) { + return `/slides/${state.data.id}`; + }, +}); + +const AddCourseFormView = FormView.extend({ + config: _.extend({}, FormView.prototype.config, { + Controller: AddCourseFormController, + }), +}); + +viewRegistry.add('website_slides_add_form', AddCourseFormView); + +export default { + AddCourseFormController: AddCourseFormController, + AddCourseFormView: AddCourseFormView, +}; diff --git a/addons/website_slides/views/slide_channel_add.xml b/addons/website_slides/views/slide_channel_add.xml index 1589cbc30ac..ec9c06d3eba 100644 --- a/addons/website_slides/views/slide_channel_add.xml +++ b/addons/website_slides/views/slide_channel_add.xml @@ -1,49 +1,33 @@ - + + - + + slide.channel.view.form.add + slide.channel + +
+ + + + + + + + + + + + +
+
+
- -
-
- -
- - -

Please fill in this field

-
-
- - -
- -
- - - - -
-
- -