[Fix] The new page is confusing: one user created a new page and then she don't figure out how to find it.
[IMP] website: add a checkbox on new page dialog to add page in menu. [IMP] website: add page: change default sequence and layout bzr revid: chm@openerp.com-20140214132602-ts8wcgdkospofg5f
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': "/page/" + xml_id,
|
||||
'parent_id': id,
|
||||
}, context=request.context)
|
||||
url = "/page/" + xml_id
|
||||
if noredirect:
|
||||
return werkzeug.wrappers.Response(url, mimetype='text/plain')
|
||||
|
||||
@@ -494,9 +494,14 @@ class website_menu(osv.osv):
|
||||
'parent_left': fields.integer('Parent Left', select=True),
|
||||
'parent_right': fields.integer('Parent Right', select=True),
|
||||
}
|
||||
|
||||
def __defaults_sequence(self, cr, uid, context):
|
||||
menu = self.search_read(cr, uid, [(1,"=",1)], ["sequence"], limit=1, order="sequence DESC", context=context)
|
||||
return menu and menu[0]["sequence"] or 0
|
||||
|
||||
_defaults = {
|
||||
'url': '',
|
||||
'sequence': 0,
|
||||
'sequence': __defaults_sequence,
|
||||
'new_window': False,
|
||||
}
|
||||
_parent_store = True
|
||||
|
||||
@@ -19,10 +19,24 @@
|
||||
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.removeClass("mb0");
|
||||
|
||||
var $add = $(
|
||||
'<div class="form-group mb0">'+
|
||||
'<label class="col-sm-offset-3 col-sm-9 text-left">'+
|
||||
' <input type="checkbox" checked="checked" required="required"/> '+
|
||||
'</label>'+
|
||||
'</div>');
|
||||
$add.find('label').append(_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