diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index a6d8f2982f9..94a2e6fd01c 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -95,8 +95,15 @@ class Website(openerp.addons.web.controllers.main.Home): # Edit #------------------------------------------------------ @http.route('/website/add/', type='http', auth="user", website=True) - def pagenew(self, path, noredirect=False): + def pagenew(self, path, noredirect=False, add_menu=None): xml_id = request.registry['website'].new_page(request.cr, request.uid, path, context=request.context) + if add_menu: + model, id = request.registry["ir.model.data"].get_object_reference(request.cr, request.uid, 'website', 'main_menu') + request.registry['website.menu'].create(request.cr, request.uid, { + 'name': path, + 'url': path, + 'parent_id': id, + }, context=request.context) url = "/page/" + xml_id if noredirect: return werkzeug.wrappers.Response(url, mimetype='text/plain') diff --git a/addons/website/static/src/js/website.editor.newpage.js b/addons/website/static/src/js/website.editor.newpage.js index 8d3b3e9b6b5..dc990b316fc 100644 --- a/addons/website/static/src/js/website.editor.newpage.js +++ b/addons/website/static/src/js/website.editor.newpage.js @@ -19,10 +19,27 @@ website.prompt({ id: "editor_new_page", window_title: _t("New Page"), - input: "Page Title", - }).then(function (val) { + input: _t("Page Title"), + init: function () { + var $group = this.$dialog.find("div.form-group"); + $group.find("label").removeClass("col-sm-3").addClass("col-sm-4"); + $group.find("div").removeClass("col-sm-9").addClass("col-sm-8"); + $group.removeClass("mb0"); + + var $add = $( + '
'+ + ''+ + '
'+ + ' '+ + '
'+ + '
'); + $add.find('label').text(_t("Add page in menu")); + $group.after($add); + } + }).then(function (val, field, $dialog) { if (val) { - document.location = '/website/add/' + encodeURI(val); + console.log('/website/add/' + encodeURI(val) + "?add_menu=" + $dialog.find('input[type="checkbox"]').is(':checked')); + document.location = '/website/add/' + encodeURI(val) + "?add_menu=" + $dialog.find('input[type="checkbox"]').is(':checked'); } }); } diff --git a/addons/website/static/src/js/website.js b/addons/website/static/src/js/website.js index 6fde9495d36..b249fb7136f 100644 --- a/addons/website/static/src/js/website.js +++ b/addons/website/static/src/js/website.js @@ -206,6 +206,7 @@ var def = $.Deferred(); var dialog = $(openerp.qweb.render('website.prompt', options)).appendTo("body"); + options.$dialog = dialog; var field = dialog.find(options.field_type).first(); field.val(options.default); field.fillWith = function (data) { @@ -226,7 +227,7 @@ dialog.modal('show'); field.focus(); dialog.on('click', '.btn-primary', function () { - def.resolve(field.val(), field); + def.resolve(field.val(), field, dialog); dialog.remove(); }); });