def page_exists(self, cr, uid, ids, name, module='website', context=None):
try:
- return self.pool["ir.model.data"].get_object_reference(cr, uid, module, name)
+ name = (name or "").replace("/page/website.", "").replace("/page/", "")
+ if not name:
+ return False
+ return self.pool["ir.model.data"].get_object_reference(cr, uid, module, name)
except:
return False
yield page
def search_pages(self, cr, uid, ids, needle=None, limit=None, context=None):
- return list(itertools.islice(
- self.enumerate_pages(cr, uid, ids, query_string=needle, context=context),
- limit))
+ name = (needle or "").replace("/page/website.", "").replace("/page/", "")
+ res = []
+ for page in self.enumerate_pages(cr, uid, ids, query_string=name, context=context):
+ if needle in page['loc']:
+ res.append(page)
+ if len(res) == limit:
+ break
+ return res
def kanban(self, cr, uid, ids, model, domain, column, template, step=None, scope=None, orderby=None, context=None):
step = step and int(step) or 10
make_link: function (url, new_window, label, classes) {
},
bind_data: function () {
+ var self = this;
var href = this.element && (this.element.data( 'cke-saved-href')
|| this.element.getAttribute('href'));
var new_window = this.element
: false;
var text = this.element ? this.element.getText() : '';
if (!text.length) {
- var selection = this.editor.getSelection();
- text = selection.getSelectedText();
+ if (this.editor) {
+ text = this.editor.getSelection().getSelectedText();
+ } else {
+ text = this.data.name;
+ href = this.data.url;
+ new_window = this.data.new_window;
+ }
}
this.$('input#link-text').val(text);
this.$('input.email-address').val(match[1]).change();
}
if (href && !$control) {
- this.$('input.url').val(href).change();
- this.$('input.window-new').closest("div").show();
+ this.page_exists(href).then(function (exist) {
+ if (exist) {
+ self.$('#link-page').select2('data', {'id': href, 'text': href});
+ } else {
+ self.$('input.url').val(href).change();
+ self.$('input.window-new').closest("div").show();
+ }
+ });
}
this.preview();
},