[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
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
});
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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': [
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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);
|
||||
@@ -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});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="blog_post_view_form_add" model="ir.ui.view">
|
||||
<field name="name">blog.post.view.form.add</field>
|
||||
<field name="model">blog.post</field>
|
||||
<field name="arch" type="xml">
|
||||
<form js_class="website_blog_add_form">
|
||||
<group>
|
||||
<field name="website_url" invisible="1"/>
|
||||
<field name="blog_id" string="Select Blog"/>
|
||||
<field name="name" placeholder="Blog Post Title"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="blog_post_action_add" model="ir.actions.act_window">
|
||||
<field name="name">New Blog Post</field>
|
||||
<field name="res_model">blog.post</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="view_id" ref="blog_post_view_form_add"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
@@ -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});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,37 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="website_event.event_create_dialog">
|
||||
<form id="editor_new_event" style="overflow:visible;">
|
||||
<div class="form-group row" id="name">
|
||||
<label for="name" class="col-md-2 col-form-label">Event Name</label>
|
||||
<div class="col-md-10">
|
||||
<input type="text" name="name" class="form-control" required="required"/>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="event_event_view_form_add" model="ir.ui.view">
|
||||
<field name="name">event.event.view.form.add</field>
|
||||
<field name="model">event.event</field>
|
||||
<field name="arch" type="xml">
|
||||
<form js_class="event_event_add_form">
|
||||
<group>
|
||||
<field name="website_url" invisible="1"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="name" placeholder="e.g. Conference for Architects" string="Event Name"/>
|
||||
<field name="address_id" context="{'show_address': 1}" options='{"always_reload": True}'/>
|
||||
<label for="date_begin" string="Start → End"/>
|
||||
<div class="o_row w-100">
|
||||
<field name="date_begin" widget="daterange" nolabel="1" class="oe_inline" options="{'related_end_date': 'date_end'}"/>
|
||||
<i class="fa fa-long-arrow-right mx-2" aria-label="Arrow icon" title="Arrow"/>
|
||||
<field name="date_end" widget="daterange" nolabel="1" class="oe_inline" options="{'related_start_date': 'date_begin'}"/>
|
||||
</div>
|
||||
<p class="text-danger mt-1 mb-0 col-md-8 d-none">Please fill in this field</p>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-2" for="event_location">Location</label>
|
||||
<div class="col-md-10">
|
||||
<select class="form-control" id="event_location" name="event_location">
|
||||
<option value="online">Online</option>
|
||||
<option value="on_site">On Site</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row d-none show_visibility_address" id="address">
|
||||
<label class="col-form-label col-md-2" for="address_id">Venue</label>
|
||||
<div class="col-md-10">
|
||||
<input type="text" class="form-control o_wevent_js_address_id" name="address_id" placeholder="Select Venue"/>
|
||||
</div>
|
||||
<p class="text-danger mt-1 mb-0 col-md-8 d-none">Please fill in this field</p>
|
||||
</div>
|
||||
<div class="form-group row d-flex justify-content-between align-items-center" id="event_dates">
|
||||
<label class="col-form-label col-md-2" for="event_start_end">Start → End</label>
|
||||
<div class="col-md-10 s_website_form_datetime input-group date o_wevent_form_datetime" data-target-input="nearest">
|
||||
<input type="text" name="event_start_end" class="form-control daterange-input bg-transparent text-dark rounded-0 p-1"/>
|
||||
</div>
|
||||
<p class="text-danger mt-1 col-md-8 d-none">Please fill in this field</p>
|
||||
</div>
|
||||
</group>
|
||||
</form>
|
||||
</t>
|
||||
</templates>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="event_event_action_add" model="ir.actions.act_window">
|
||||
<field name="name">New Event</field>
|
||||
<field name="res_model">event.event</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="view_id" ref="event_event_view_form_add"/>
|
||||
<field name="context">{'default_address_id': False}</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
@@ -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});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,53 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="website_forum.add_new_forum">
|
||||
<form id="editor_new_forum">
|
||||
<div class="form-group row">
|
||||
<label for="page-name" class="col-md-4 col-form-label">Forum Name</label>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="forum_name" class="form-control" required="required"/>
|
||||
<div class="custom-control custom-checkbox mt-2">
|
||||
<input type="checkbox" class="custom-control-input" id="add_to_menu" required="required"/>
|
||||
<label class="custom-control-label" for="add_to_menu">Add to menu</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mt-2">
|
||||
<label class="col-md-4 col-form-label" data-toggle="tooltip" data-placement="bottom"
|
||||
title="Questions and Answers mode: only one answer allowed\n Discussions mode: multiple answers allowed">Forum Mode</label>
|
||||
<div class="col-md-8">
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio" id="questions" name="mode" class="custom-control-input" value="questions" checked="checked"/>
|
||||
<label class="custom-control-label" for="questions">Questions and Answers</label>
|
||||
</div>
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio" id="discussions" name="mode" class="custom-control-input" value="discussions"/>
|
||||
<label class="custom-control-label" for="discussions">Discussions</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mt-2">
|
||||
<label class="col-md-4 col-form-label" data-toggle="tooltip" data-placement="bottom"
|
||||
title="Public: Forum is public\nSigned In: Forum is visible for signed in users\nSome users: Forum and their content are hidden for non members of selected group">Privacy</label>
|
||||
<div class="col-md-8">
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio" id="public" name="privacy" class="custom-control-input" value="public" checked="checked"/>
|
||||
<label class="custom-control-label" for="public">Public</label>
|
||||
</div>
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio" id="connected" name="privacy" class="custom-control-input" value="connected"/>
|
||||
<label class="custom-control-label" for="connected">Signed In</label>
|
||||
</div>
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio" id="private" name="privacy" class="custom-control-input" value="private"/>
|
||||
<label class="custom-control-label" for="private">Some Users</label>
|
||||
</div>
|
||||
<div class="form-group show_visibility_group d-none">
|
||||
<input type="text" class="form-control" name="group_id" id="group_id" placeholder="Select Authorized Group"/>
|
||||
<p id="group-required" class="text-danger mt-1 mb-0 d-none">Please fill in this field</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="forum_forum_view_form_add" model="ir.ui.view">
|
||||
<field name="name">forum.forum.view.form.add</field>
|
||||
<field name="model">forum.forum</field>
|
||||
<field name="arch" type="xml">
|
||||
<form js_class="website_forum_add_form">
|
||||
<group>
|
||||
<field name="name" placeholder="e.g. Technical Assistance" string="Forum Name"/>
|
||||
<field name="mode" widget="radio" required="True" string="Forum Mode"/>
|
||||
<field name="privacy" widget="radio" attrs="{'required': True}"/>
|
||||
<field name="authorized_group_id" options="{'no_create': True}" attrs="{'invisible': [('privacy', '!=', 'private')], 'required': [('privacy', '=', 'private')]}"/>
|
||||
</group>
|
||||
</form>
|
||||
</t>
|
||||
</templates>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="forum_forum_action_add" model="ir.actions.act_window">
|
||||
<field name="name">New Forum</field>
|
||||
<field name="res_model">forum.forum</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="view_id" ref="forum_forum_view_form_add"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -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/**/*',
|
||||
|
||||
@@ -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);
|
||||
@@ -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});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="im_livechat_channel_view_form_add" model="ir.ui.view">
|
||||
<field name="name">im_livechat.channel.view.form.add</field>
|
||||
<field name="model">im_livechat.channel</field>
|
||||
<field name="arch" type="xml">
|
||||
<form js_class="website_livechat_add_form">
|
||||
<group>
|
||||
<field name="website_url" invisible="1"/>
|
||||
<field name="name" string="Channel Name"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="im_livechat_channel_action_add" model="ir.actions.act_window">
|
||||
<field name="name">New Channel</field>
|
||||
<field name="res_model">im_livechat.channel</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="view_id" ref="im_livechat_channel_view_form_add"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -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',
|
||||
|
||||
@@ -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`
|
||||
<div>
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-3">
|
||||
Product Name
|
||||
</label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" t-model="state.name" class="form-control" required="required"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
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});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="product_product_view_form_add" model="ir.ui.view">
|
||||
<field name="name">product.product.view.form.add</field>
|
||||
<field name="model">product.product</field>
|
||||
<field name="arch" type="xml">
|
||||
<form js_class="product_product_add_form">
|
||||
<group>
|
||||
<field name="website_url" invisible="1"/>
|
||||
<field name="name" placeholder="e.g. Cheese Burger" string="Product Name"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="product_product_action_add" model="ir.actions.act_window">
|
||||
<field name="name">New Product</field>
|
||||
<field name="res_model">product.product</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="view_id" ref="product_product_view_form_add"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -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',
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
},
|
||||
});
|
||||
@@ -1,52 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<templates>
|
||||
<t t-extend="website.slide.channel.create">
|
||||
<t t-jquery="form > div:last" t-operation="after">
|
||||
<label for="enroll">Enroll Policy</label>
|
||||
<div class="form-row" id="enroll_policies">
|
||||
<div class="form-group col-3">
|
||||
<div class="form-check mx-0">
|
||||
<input class="form-check-input"
|
||||
type="radio" name="enroll"
|
||||
id="enroll_public" value="public"
|
||||
checked="checked"/>
|
||||
<label class="form-check-label font-weight-normal"
|
||||
for="enroll_public">
|
||||
Public
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-3">
|
||||
<div class="form-check mx-0">
|
||||
<input class="form-check-input"
|
||||
type="radio" name="enroll"
|
||||
id="enroll_invitation" value="invite"/>
|
||||
<label class="form-check-label font-weight-normal"
|
||||
for="enroll_invitation">
|
||||
On Invitation
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-3">
|
||||
<div class="form-check mx-0">
|
||||
<input class="form-check-input"
|
||||
type="radio" name="enroll"
|
||||
id="enroll_payment" value="payment"/>
|
||||
<label class="form-check-label font-weight-normal"
|
||||
for="enroll_payment">
|
||||
On Payment
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<label class="o_wslides_course_products d-none">Product</label>
|
||||
<div class="form-group o_wslides_course_products d-none">
|
||||
<select class="form-control" name="product_id" id="product_id">
|
||||
<option t-foreach="widget.products" t-as="product"
|
||||
t-att-value="product.id" t-esc="product.name"/>
|
||||
</select>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
||||
@@ -49,4 +49,19 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="slide_channel_view_form_add_inherit_sale_slides" model="ir.ui.view">
|
||||
<field name="name">slide.channel.view.form.add.inherit.sale.slides</field>
|
||||
<field name="model">slide.channel</field>
|
||||
<field name="inherit_id" ref="website_slides.slide_channel_view_form_add"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[last()]" position="after">
|
||||
<group string="Enroll">
|
||||
<field name="enroll" widget="radio" options="{'horizontal': true}" string="Enroll Policy"/>
|
||||
<field name="product_id" attrs="{'invisible': [('enroll', '!=', 'payment')], 'required': [('enroll', '=', 'payment')]}"
|
||||
context="{'default_detailed_type': 'course', 'default_invoice_policy': 'order', 'default_purchase_ok': False, 'default_sale_ok': True, 'default_website_published': True}"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data></odoo>
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
@@ -1,49 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<templates xml:space="preserve">
|
||||
<record id="slide_channel_view_form_add" model="ir.ui.view">
|
||||
<field name="name">slide.channel.view.form.add</field>
|
||||
<field name="model">slide.channel</field>
|
||||
<field name="arch" type="xml">
|
||||
<form js_class="website_slides_add_form">
|
||||
<group>
|
||||
<field name="website_url" invisible="1"/>
|
||||
<field name="name" placeholder="e.g. Computer Science for kids" string="Course Title"/>
|
||||
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}" placeholder="Tags"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="channel_type" widget="radio" options="{'horizontal': true}" string="Choose a layout"/>
|
||||
<field name="description" widget="html" placeholder="Common tasks for a computer scientist is asking the right questions andanswering questions. In this course, you'll study those topics with activities about mathematics, science and logic." string="Description"/>
|
||||
</group>
|
||||
<group name="review">
|
||||
<field name="allow_comment"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<t t-name="website.slide.channel.create">
|
||||
<div>
|
||||
<form action="/slides/channel/add" method="POST" id="slide_channel_add_form">
|
||||
<input type="hidden" name="csrf_token" t-att-value="csrf_token"/>
|
||||
<div class="form-group">
|
||||
<label for="title" class="col-form-label">Title</label>
|
||||
<input type="text" class="form-control" autocomplete="off" name="name" id="title" placeholder='e.g. "Computer Science for kids"' required="1"/>
|
||||
<p id="title-required" class="text-danger mt-1 mb-0 d-none">Please fill in this field</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="tag_ids" class="col-form-label">Tags</label>
|
||||
<input type="text" class="form-control" name="tag_ids" id="tag_ids" placeholder="Tags"/>
|
||||
</div>
|
||||
<label for="channel_type">Choose a layout</label>
|
||||
<div class="d-flex flex-row justify-content-around">
|
||||
<input class="form-check-input d-none" type="radio" name="channel_type" id="channel_type1" value="training" checked="checked"/>
|
||||
<label for="channel_type1">
|
||||
<img src="/website_slides/static/src/img/channel-training-layout.png"
|
||||
alt="Training Layout"/>
|
||||
</label>
|
||||
<input class="form-check-input d-none" type="radio" name="channel_type" id="channel_type2" value="documentation"/>
|
||||
<label for="channel_type2">
|
||||
<img src="/website_slides/static/src/img/channel-documentation-layout.png"
|
||||
alt="Documentation Layout"/>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="title">Description</label>
|
||||
<textarea rows="2" class="form-control" name="description" id="description"
|
||||
placeholder="e.g. Common tasks for a computer scientist is asking the right questions. In this course, you will study those topics with activities about mathematics, science and logic."/>
|
||||
</div>
|
||||
<label id="communication-label">Review</label>
|
||||
<div class="form-group">
|
||||
<div class="o_wslide_channel_communication_type">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="allow_comment" name="allow_comment" checked="checked"/>
|
||||
<span class="form-check-label" for="allow_comment">Allow students to review your course</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</t>
|
||||
<record id="slide_channel_action_add" model="ir.actions.act_window">
|
||||
<field name="name">New Course</field>
|
||||
<field name="res_model">slide.channel</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="view_id" ref="slide_channel_view_form_add"/>
|
||||
</record>
|
||||
|
||||
</templates>
|
||||
</odoo>
|
||||
|
||||
@@ -72,17 +72,6 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- User Navbar -->
|
||||
<template id="user_navbar_inherit_website_slides" inherit_id="website.user_navbar">
|
||||
<xpath expr="//div[@id='o_new_content_menu_choices']//div[@name='module_website_slides']" position="attributes">
|
||||
<attribute name="name"/>
|
||||
<attribute name="t-att-data-module-id"/>
|
||||
<attribute name="t-att-data-module-shortdesc"/>
|
||||
<attribute name="t-if">env.user.has_group('website_slides.group_website_slides_officer')</attribute>
|
||||
<attribute name="t-cache"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="join_course_link" name="Join Course Link">
|
||||
<a class="o_wslides_js_course_join_link" href="#" t-att-data-channel-enroll="slide.channel_id.enroll"
|
||||
t-att-data-channel-id="slide.channel_id.id">
|
||||
|
||||
@@ -25,10 +25,5 @@
|
||||
'data/slide_channel_demo.xml',
|
||||
],
|
||||
'auto_install': True,
|
||||
'assets': {
|
||||
'web.assets_frontend': [
|
||||
'website_slides_forum/static/src/js/**/*',
|
||||
],
|
||||
},
|
||||
'license': 'LGPL-3',
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
odoo.define('website_slides_forum.editor', function (require) {
|
||||
"use strict";
|
||||
|
||||
var WebsiteNewMenu = require('website.newMenu');
|
||||
|
||||
WebsiteNewMenu.include({
|
||||
xmlDependencies: WebsiteNewMenu.prototype.xmlDependencies.concat(
|
||||
['/website_slides_forum/static/src/xml/website_slides_forum_channel.xml']
|
||||
),
|
||||
});
|
||||
});
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-extend="website.slide.channel.create">
|
||||
<t t-jquery="#communication-label" t-operation="replace">
|
||||
<label id="communication-label">Communication</label>
|
||||
</t>
|
||||
<t t-jquery=".o_wslide_channel_communication_type" t-operation="append">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="link_forum" name="link_forum"/>
|
||||
<span class="form-check-label" for="link_forum">Create a Forum</span>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
||||
@@ -19,4 +19,18 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="slide_channel_view_form_add_inherit_slides_forum" model="ir.ui.view">
|
||||
<field name="name">slide.channel.view.form.add.inherit.slides.forum</field>
|
||||
<field name="model">slide.channel</field>
|
||||
<field name="inherit_id" ref="website_slides.slide_channel_view_form_add"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[@name='review']" position="attributes">
|
||||
<attribute name="string">Communication</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='allow_comment']" position="after">
|
||||
<field name="forum_id" string="Forum"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user