[IMP] website: add a checkbox on new page dialog to add page in menu. Fix: The new page is confusing: one user created a new page and then she don't figure out how to find it
bzr revid: chm@openerp.com-20140213152728-jj6j1hxae8ia5w4k
This commit is contained in:
@@ -95,8 +95,15 @@ class Website(openerp.addons.web.controllers.main.Home):
|
||||
# Edit
|
||||
#------------------------------------------------------
|
||||
@http.route('/website/add/<path:path>', 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')
|
||||
|
||||
@@ -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 = $(
|
||||
'<div class="form-group mb0">'+
|
||||
'<label for="page-name" class="col-sm-4 control-label"></label>'+
|
||||
'<div class="col-sm-8 text-left">'+
|
||||
' <input type="checkbox" class="form-control" style="width: 24px" checked="checked" required="required"/>'+
|
||||
'</div>'+
|
||||
'</div>');
|
||||
$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');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user