[ADD] Content menu links splitted per modules
TODO: website.prompt() should be finished for Add a blog post link Added @id=editable_scripts_hook in layout template so modules can easly add *.editor.js files bzr revid: fme@openerp.com-20131113171438-3l0wo08ta5vsulq3
This commit is contained in:
parent
70d9e5a8aa
commit
7598bcdb98
|
@ -12,6 +12,16 @@
|
|||
website.ready().then(website.init_editor);
|
||||
}
|
||||
|
||||
$(document).on('click', 'a.js_link2post', function (ev) {
|
||||
ev.preventDefault();
|
||||
var form = document.createElement('form');
|
||||
form.action = this.pathname; // restrict to same origin
|
||||
form.method = 'POST';
|
||||
// TODO: support this.search as form input fields
|
||||
$(this).append(form);
|
||||
form.submit();
|
||||
});
|
||||
|
||||
$(document).on('hide.bs.dropdown', '.dropdown', function (ev) {
|
||||
// Prevent dropdown closing when a contenteditable children is focused
|
||||
if (ev.originalEvent
|
||||
|
@ -383,6 +393,7 @@
|
|||
'click button[data-action=edit]': 'edit',
|
||||
'click button[data-action=save]': 'save',
|
||||
'click button[data-action=cancel]': 'cancel',
|
||||
'click a[data-action=new_page]': 'new_page',
|
||||
},
|
||||
container: 'body',
|
||||
customize_setup: function() {
|
||||
|
@ -531,6 +542,12 @@
|
|||
cancel: function () {
|
||||
website.reload();
|
||||
},
|
||||
new_page: function (ev) {
|
||||
ev.preventDefault();
|
||||
website.prompt('Create a new page', 'Page name').then(function (val) {
|
||||
document.location = '/pagenew/' + encodeURI(val);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
var blocks_selector = _.keys(CKEDITOR.dtd.$block).join(',');
|
||||
|
|
|
@ -132,6 +132,42 @@
|
|||
$error.modal('show');
|
||||
};
|
||||
|
||||
website.prompt = function (window_title, field_name, field_type, on_init) {
|
||||
// A bootstraped version of javascript prompt albeit asynchronous
|
||||
// Built to handle only one field, for anything more complex, use editor.Dialog class
|
||||
// TODO: use option dict for parameters
|
||||
field_type = field_type || 'input';
|
||||
on_init = on_init || function() {};
|
||||
var def = $.Deferred();
|
||||
var dialog = $(openerp.qweb.render('website.prompt', {
|
||||
field_type: field_type,
|
||||
field_name: field_name,
|
||||
window_title: window_title,
|
||||
})).appendTo("body");
|
||||
var input = dialog.find(field_type).first();
|
||||
var init = on_init(input);
|
||||
$.when(init).then(function () {
|
||||
dialog.modal('show');
|
||||
input.focus();
|
||||
dialog.on('click', '.btn-primary', function () {
|
||||
def.resolve(input.val(), input);
|
||||
dialog.remove();
|
||||
});
|
||||
});
|
||||
dialog.on('hidden.bs.modal', function () {
|
||||
def.reject();
|
||||
dialog.remove();
|
||||
});
|
||||
if (input.is('input[type="text"]')) {
|
||||
input.keypress(function (e) {
|
||||
if (e.which == 13) {
|
||||
dialog.find('.btn-primary').trigger('click');
|
||||
}
|
||||
});
|
||||
}
|
||||
return def;
|
||||
};
|
||||
|
||||
dom_ready.then(function () {
|
||||
|
||||
/* ----- BOOTSTRAP STUFF ---- */
|
||||
|
|
|
@ -24,14 +24,10 @@
|
|||
<li><a data-action="promote-current-page" href="#"><span title="Promote page on the web">Promote</span></a></li>
|
||||
<li class="dropdown js_hide_on_translate">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Content <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<ul class="dropdown-menu oe_content_menu" role="menu">
|
||||
<li><a data-action="edit-structure" href="#"><span title="Edit Top Menu">Edit Menu</span></a></li>
|
||||
<li class="divider"> </li>
|
||||
<li><a href="">New Page</a></li> <!-- Todo: Implement with inheritancy in each module-->
|
||||
<li><a href="">New Blog Post</a></li>
|
||||
<li><a href="">New Event</a></li>
|
||||
<li><a href="">New Job Offer</a></li>
|
||||
<li><a href="">New Product</a></li>
|
||||
<li><a href="#" data-action="new_page">New Page</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown js_hide_on_translate">
|
||||
|
@ -100,4 +96,31 @@
|
|||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="website.prompt">
|
||||
<div class="modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 class="modal-title"><t t-esc="window_title"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<h4 class="list-group-item-heading">
|
||||
<label for="page-name" class="control-label">
|
||||
<t t-esc="field_name"/>
|
||||
</label>
|
||||
</h4>
|
||||
<!-- TODO: support other types -->
|
||||
<input type="text" class="form-control" required="required" t-att-placeholder="field_name"/>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
|
||||
<button type="button" class="btn btn-primary">Ok</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
<script type="text/javascript" src="/website/static/src/js/website.js"></script>
|
||||
<script t-if="not translatable" type="text/javascript" src="/website/static/src/js/website.snippets.animation.js"></script>
|
||||
|
||||
<t t-if="editable">
|
||||
<t t-if="editable" id="editable_scripts_hook">
|
||||
<script type="text/javascript" src="/website/static/lib/ckeditor/ckeditor.js"></script>
|
||||
<script type="text/javascript" src="/website/static/lib/ckeditor.sharedspace/plugin.js"></script>
|
||||
<script type="text/javascript" src="/website/static/lib/bootstrap-tour/bootstrap-tour.js"></script>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
(function() {
|
||||
"use strict";
|
||||
|
||||
var website = openerp.website;
|
||||
website.add_template_file('/website_blog/static/src/xml/website_blog.xml');
|
||||
})();
|
|
@ -0,0 +1,7 @@
|
|||
<templates id="template" xml:space="preserve">
|
||||
<t t-extend="website.editorbar">
|
||||
<t t-jquery="ul.oe_content_menu" t-operation="append">
|
||||
<li><a href="#" class="js_content_new_blog">New Blog Post</a></li>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
|
@ -1,6 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="website_blog_script" inherit_id="website.layout" name="Website Blog script">
|
||||
<xpath expr="//t[@id='editable_scripts_hook']" position="inside">
|
||||
<script type="text/javascript" src="/website_blog/static/src/js/website_blog.editor.js" t-ignore="true"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- Layout add nav and footer -->
|
||||
<template id="header_footer_custom" inherit_id="website.layout" name="Footer News Blog Link">
|
||||
<xpath expr="//footer//div[@name='info']/ul" position="inside">
|
||||
|
|
|
@ -29,7 +29,7 @@ from openerp.addons.website.controllers.main import Website as controllers
|
|||
controllers = controllers()
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from openerp import tools
|
||||
import urllib
|
||||
|
@ -240,3 +240,15 @@ class website_event(http.Controller):
|
|||
event.address_id.write({'website_published': True})
|
||||
|
||||
return controllers.publish(id, object)
|
||||
|
||||
@website.route('/event/add_event/', type='http', auth="user", multilang=True, methods=['POST'])
|
||||
def add_event(self, **kwargs):
|
||||
Event = request.registry.get('event.event')
|
||||
date_begin = datetime.today() + timedelta(days=(15)) # FIXME: better defaults
|
||||
event_id = Event.create(request.cr, request.uid, {
|
||||
'name': 'New Event',
|
||||
'date_begin': date_begin.strftime('%Y-%m-%d'),
|
||||
'date_end': (date_begin + timedelta(days=(1))).strftime('%Y-%m-%d'),
|
||||
}, context=request.context)
|
||||
|
||||
return request.redirect("/event/%s/?enable_editor=1" % event_id)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
(function() {
|
||||
"use strict";
|
||||
|
||||
var website = openerp.website;
|
||||
website.add_template_file('/website_event/static/src/xml/website_event.xml');
|
||||
})();
|
|
@ -0,0 +1,7 @@
|
|||
<templates id="template" xml:space="preserve">
|
||||
<t t-extend="website.editorbar">
|
||||
<t t-jquery="ul.oe_content_menu" t-operation="append">
|
||||
<li><a href="/event/add_event" class="js_link2post">New Event</a></li>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
|
@ -2,6 +2,12 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<template id="website_event_script" inherit_id="website.layout" name="Website Event script">
|
||||
<xpath expr="//t[@id='editable_scripts_hook']" position="inside">
|
||||
<script type="text/javascript" src="/website_event/static/src/js/website_event.editor.js" t-ignore="true"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- Layout add nav and footer -->
|
||||
<template id="header_footer_custom" inherit_id="website.layout" name="Footer Events Link">
|
||||
<xpath expr="//footer//ul[@name='products']" position="inside">
|
||||
|
|
|
@ -44,7 +44,7 @@ class website_hr_recruitment(http.Controller):
|
|||
})
|
||||
|
||||
@website.route(['/job/detail/<model("hr.job"):job>'], type='http', auth="public", multilang=True)
|
||||
def detail(self, job):
|
||||
def detail(self, job, **kwargs):
|
||||
values = {
|
||||
'job': job,
|
||||
'vals_date': job.write_date.split(' ')[0],
|
||||
|
@ -89,6 +89,15 @@ class website_hr_recruitment(http.Controller):
|
|||
return request.website.render("website_hr_recruitment.applyjobpost", { 'job': job })
|
||||
|
||||
@website.route('/job/publish', type='json', auth="admin", multilang=True)
|
||||
def publish (self, id, object):
|
||||
def publish(self, id, object):
|
||||
res = controllers.publish(id, object)
|
||||
return res
|
||||
|
||||
@website.route('/job/add_job_offer/', type='http', auth="user", multilang=True, methods=['POST'])
|
||||
def add_job_offer(self, **kwargs):
|
||||
Job = request.registry.get('hr.job')
|
||||
job_id = Job.create(request.cr, request.uid, {
|
||||
'name': 'New Job Offer',
|
||||
}, context=request.context)
|
||||
|
||||
return request.redirect("/job/detail/%s/?enable_editor=1" % job_id)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
(function() {
|
||||
"use strict";
|
||||
|
||||
var website = openerp.website;
|
||||
website.add_template_file('/website_hr_recruitment/static/src/xml/website_hr_recruitment.xml');
|
||||
})();
|
|
@ -0,0 +1,7 @@
|
|||
<templates id="template" xml:space="preserve">
|
||||
<t t-extend="website.editorbar">
|
||||
<t t-jquery="ul.oe_content_menu" t-operation="append">
|
||||
<li><a href="/job/add_job_offer/" class="js_link2post">New Job Offer</a></li>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
|
@ -7,6 +7,12 @@
|
|||
<field name="description">Job Posts on your website</field>
|
||||
</record>
|
||||
|
||||
<template id="website_hr_recruitment_script" inherit_id="website.layout" name="Website Hr Recruitment script">
|
||||
<xpath expr="//t[@id='editable_scripts_hook']" position="inside">
|
||||
<script type="text/javascript" src="/website_hr_recruitment/static/src/js/website_hr_recruitment.editor.js" t-ignore="true"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="job_footer_custom" inherit_id="website.layout" name="Footer Job Link">
|
||||
<xpath expr="//footer//div[@name='info']/ul" position="inside">
|
||||
<li><a href="/jobs">Jobs</a></li>
|
||||
|
|
|
@ -342,7 +342,7 @@ class Ecommerce(http.Controller):
|
|||
return request.website.render("website_sale.products", values)
|
||||
|
||||
@website.route(['/shop/product/<model("product.template"):product>/'], type='http', auth="public", multilang=True)
|
||||
def product(self, product, search='', category='', filter='', promo=None):
|
||||
def product(self, product, search='', category='', filter='', promo=None, **kwargs):
|
||||
|
||||
if promo:
|
||||
self.change_pricelist(promo)
|
||||
|
@ -372,11 +372,8 @@ class Ecommerce(http.Controller):
|
|||
}
|
||||
return request.website.render("website_sale.product", values)
|
||||
|
||||
@website.route(['/shop/add_product/', '/shop/category/<int:cat_id>/add_product/'], type='http', auth="public", multilang=True)
|
||||
@website.route(['/shop/add_product/', '/shop/category/<int:cat_id>/add_product/'], type='http', auth="user", multilang=True, methods=['POST'])
|
||||
def add_product(self, cat_id=0, **post):
|
||||
if request.httprequest.method != 'POST':
|
||||
return werkzeug.exceptions.MethodNotAllowed(valid_methods=['POST'])
|
||||
|
||||
Product = request.registry.get('product.product')
|
||||
product_id = Product.create(request.cr, request.uid, {
|
||||
'name': 'New Product', 'public_categ_id': cat_id
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
(function() {
|
||||
"use strict";
|
||||
|
||||
var website = openerp.website;
|
||||
website.add_template_file('/website_sale/static/src/xml/website_sale.xml');
|
||||
})();
|
|
@ -0,0 +1,7 @@
|
|||
<templates id="template" xml:space="preserve">
|
||||
<t t-extend="website.editorbar">
|
||||
<t t-jquery="ul.oe_content_menu" t-operation="append">
|
||||
<li><a href="/shop/add_product" class="js_link2post">New Product</a></li>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
|
@ -1,5 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="website_sale_script" inherit_id="website.layout" name="Website Sale script">
|
||||
<xpath expr="//t[@id='editable_scripts_hook']" position="inside">
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website_sale.editor.js" t-ignore="true"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="menu_shop" model="website.menu">
|
||||
|
|
Loading…
Reference in New Issue