From 92a20deca88dd925bb0d341543216bacc3ce689f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 21 Aug 2013 16:31:52 +0200 Subject: [PATCH] [ADD] simplified link dialog + link to existing pages dropdown TODO: better UI, create new page, correct selection when reopen dialog bzr revid: xmo@openerp.com-20130821143152-o3lawyupxcssuq2v --- addons/website/static/src/js/website.js | 47 +++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/addons/website/static/src/js/website.js b/addons/website/static/src/js/website.js index afe7cc53448..c7c80fd9b09 100644 --- a/addons/website/static/src/js/website.js +++ b/addons/website/static/src/js/website.js @@ -467,6 +467,53 @@ $(function(){ }.bind(this), 0); }); } + }, + link: function (definition) { + definition.removeContents('target'); + definition.removeContents('advanced'); + + var info = definition.getContents('info'); + info.remove('linkType'); + info.remove('anchorOptions'); + info.remove('emailOptions'); + + info.get('urlOptions').children[0].widths = [ '0%', '100%' ]; + info.get('protocol').style = 'display: none'; + // TODO: sync edition of url to website_pages? + info.add({ + type: 'select', + label: "Existing page", + id: 'website_pages', + items: [['']], + /** + * onload fetch all the pages existing in the website, then + * display that. + */ + onLoad: function () { + var field = this; + + return openerp.jsonRpc('/web/dataset/call_kw', 'call', { + model: 'website', + method: 'list_pages', + args: [], + kwargs: {} + }).then(function (results) { + _(results).each(function (result) { + field.add(result.name, result.url); + }); + }); + }, + onChange: function () { + var url = this.getValue(); + var url_field = this.getDialog().getContentElement('info', 'url'); + if (!url) { + url_field.setValue(''); + return; + } + + url_field.setValue(url); + } + }) } }; CKEDITOR.on('dialogDefinition', function (ev) {