a[IMP]menu snippet
This commit is contained in:
parent
4b4e078745
commit
07d7f19efa
@ -82,8 +82,7 @@ class Website(Home):
|
||||
|
||||
@http.route(['/website/menu/render'], type='json', auth="user", website=True)
|
||||
def menu_render(self, **kwargs):
|
||||
menu = request.env['website.menu'].browse(
|
||||
int(kwargs['menu_id']))
|
||||
menu = request.env['website.menu'].browse(int(kwargs['menu_id']))
|
||||
value = {
|
||||
'menu': menu,
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class Website(models.Model):
|
||||
def _compute_menu(self):
|
||||
Menu = self.env['website.menu']
|
||||
for website in self:
|
||||
website.menu_id = Menu.search([('parent_id', '=', False), ('website_id', '=', website.id)], order='id', limit=1).id
|
||||
website.menu_id = Menu.search([('parent_id', '=', False), ('website_id', '=', website.id), ('menu_view', '!=', False)], order='id', limit=1).id
|
||||
|
||||
# cf. Wizard hack in website_views.xml
|
||||
def noop(self, *args, **kwargs):
|
||||
|
BIN
addons/website/static/src/img/blocks/menu-icon.png
Normal file
BIN
addons/website/static/src/img/blocks/menu-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
@ -5,6 +5,7 @@ var core = require('web.core');
|
||||
var Dialog = require('web.Dialog');
|
||||
var widgets = require('web_editor.widget');
|
||||
var options = require('web_editor.snippets.options');
|
||||
var sAnimation = require('website.content.snippets.animation');
|
||||
var ajax = require('web.ajax');
|
||||
|
||||
var _t = core._t;
|
||||
@ -937,21 +938,63 @@ options.registry.gallery_img = options.Class.extend({
|
||||
},
|
||||
});
|
||||
options.registry.js_menu = options.Class.extend({
|
||||
onBuilt: function(){
|
||||
var self = this;
|
||||
this._super.apply(this, arguments);
|
||||
if (!self.$target.data('snippet-view')) {
|
||||
this.$target.data("snippet-view", new sAnimation.registry.js_menu(this.$target));
|
||||
}
|
||||
},
|
||||
|
||||
cleanForSave:function(){
|
||||
if(this.$target.data('menu_template') && this.$target.data('menu_id')){
|
||||
this._super.apply(this, arguments);
|
||||
this.$target.empty();
|
||||
}
|
||||
},
|
||||
selected_menu: function (type,value){
|
||||
if(type != true)
|
||||
return
|
||||
if (type != true) return;
|
||||
var menu = eval(value);
|
||||
var section=this.$target.find('.menu_view');
|
||||
section.empty();
|
||||
console.info(section)
|
||||
ajax.jsonRpc('/website/menu/render', 'call', {'template': menu[1], 'menu_id':menu[0]}
|
||||
this.$target.attr("data-menu_template", menu[1]);
|
||||
this.$target.attr("data-menu_id", menu[0]);
|
||||
this.$target.data("snippet-view").redraw(true);
|
||||
},
|
||||
});
|
||||
|
||||
sAnimation.registry.js_menu = sAnimation.Class.extend({
|
||||
selector: ".s_menu",
|
||||
|
||||
start: function() {
|
||||
if(this.$target.data('menu_template') && this.$target.data('menu_id')){
|
||||
this.redraw();
|
||||
}
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
this.clean();
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
redraw: function(debug) {
|
||||
this.clean(debug);
|
||||
this.build(debug);
|
||||
},
|
||||
|
||||
clean: function(debug) {
|
||||
if(this.$target.data('menu_template') && this.$target.data('menu_id')){
|
||||
this.$target.empty();
|
||||
}
|
||||
},
|
||||
build: function(){
|
||||
var self = this;
|
||||
ajax.jsonRpc('/website/menu/render', 'call', {'template': this.$target.data('menu_template'), 'menu_id':this.$target.data('menu_id')}
|
||||
).then(function (result) {
|
||||
$(result).appendTo(section);
|
||||
$(result).appendTo(self.$target);
|
||||
}).fail(function () {
|
||||
self.$('.o_website_links_code_error').show();
|
||||
self.$('.o_website_links_code_error').html(
|
||||
"<div>ServerError</div><p>We are not able to render template.</p>");
|
||||
}) ;
|
||||
self.$('.o_website_links_code_error').show();
|
||||
self.$('.o_website_links_code_error').html(
|
||||
"<div>ServerError</div><p>We are not able to render template.</p>");
|
||||
}) ;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -17,8 +17,10 @@
|
||||
<template id="s_menu" name="Menu Snippets">
|
||||
<section class="s_menu">
|
||||
<div class="container">
|
||||
<div class="row menu_view">
|
||||
<h2 style="color: rgb(193, 191, 177);text-align: center;">Select Top Menu From Option</h2>
|
||||
<div class="row">
|
||||
<div class="menu_view">
|
||||
<h2 style="color: rgb(193, 191, 177);text-align: center;">Select Top Menu From Option</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@ -693,7 +695,7 @@
|
||||
<div class="o_panel_body">
|
||||
<t t-snippet="website.s_title" t-thumbnail="/website/static/src/img/blocks/block_title.png"/>
|
||||
<t t-snippet="website.s_cover" t-thumbnail="/website/static/src/img/blocks/block_banner.png"/>
|
||||
<t t-snippet="website.s_menu" t-thumbnail="/website/static/src/img/blocks/block_menu.png"/>
|
||||
<t t-snippet="website.s_menu" t-thumbnail="/website/static/src/img/blocks/menu-icon.png"/>
|
||||
<t t-snippet="website.s_text_image" t-thumbnail="/website/static/src/img/blocks/block_text_image.png"/>
|
||||
<t t-snippet="website.s_image_text" t-thumbnail="/website/static/src/img/blocks/block_image_text.png"/>
|
||||
<t t-snippet="website.s_big_message" t-thumbnail="/website/static/src/img/blocks/block_jumbotron.png"/>
|
||||
@ -774,6 +776,9 @@
|
||||
t-att-data-view="menu.menu_view.key"><a
|
||||
href="#"><span t-esc="menu.name"/></a></li>
|
||||
</t>
|
||||
<li t-if="not top_menu">
|
||||
<a href="#">None</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</div>
|
||||
|
@ -114,16 +114,6 @@
|
||||
</t>
|
||||
<t t-set="x_icon" t-value="'/web/image/website/%s/favicon/' % website.id"/>
|
||||
</xpath>
|
||||
<xpath expr="//header" position="before">
|
||||
<pre-header>
|
||||
<div id="pre-header" class="oe_structure oe_empty"/>
|
||||
</pre-header>
|
||||
</xpath>
|
||||
<xpath expr="//footer" position="after">
|
||||
<post-footer>
|
||||
<div id="post-footer" class="oe_structure oe_empty"/>
|
||||
</post-footer>
|
||||
</xpath>
|
||||
<xpath expr="//t[@t-set='head_website']" position="replace">
|
||||
<t t-set="head_website">
|
||||
<meta t-if="main_object and 'website_indexed' in main_object
|
||||
@ -217,12 +207,12 @@
|
||||
<template id="menu_snippets" name="Menu View">
|
||||
<nav>
|
||||
<div class="container">
|
||||
<div class="navbar-header"/>
|
||||
<ul id="nav_menu" class="nav navbar-nav navbar-right">
|
||||
<t t-foreach="menu.child_id" t-as="submenu">
|
||||
<t t-call="website.recursive_menu_snippets"/>
|
||||
</t>
|
||||
</ul>
|
||||
<div class="navbar-header"/>
|
||||
<ul id="nav_menu" class="nav navbar-nav navbar-right">
|
||||
<t t-foreach="menu.child_id" t-as="submenu">
|
||||
<t t-call="website.recursive_menu_snippets"/>
|
||||
</t>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
</template>
|
||||
|
@ -188,6 +188,7 @@
|
||||
<field name="website_id" options="{'no_create': True}"/>
|
||||
<field name="new_window"/>
|
||||
<field name="parent_id"/>
|
||||
<field name="menu_view"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user