[FIX] website.editor: must display link information in linkdialox box. Remove /page/ and /page/website. from the needle to search page and apply real url as filter after the search

This commit is contained in:
Christophe Matthieu 2014-08-19 18:26:12 +02:00
parent 37c4bd96c1
commit c3d2540477
2 changed files with 28 additions and 8 deletions

View File

@ -220,7 +220,10 @@ class website(osv.osv):
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
@ -394,9 +397,14 @@ class website(osv.osv):
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

View File

@ -1046,6 +1046,7 @@
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
@ -1053,8 +1054,13 @@
: 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);
@ -1075,8 +1081,14 @@
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();
},