openerp-dev-web team mailing list archive
-
openerp-dev-web team
-
Mailing list archive
-
Message #05372
lp:~openerp-dev/openobject-client-web/6.0-embedded-url-action-rco into lp:openobject-client-web/6.0
Raphael Collet (OpenERP) has proposed merging lp:~openerp-dev/openobject-client-web/6.0-embedded-url-action-rco into lp:openobject-client-web/6.0.
Requested reviews:
OpenERP SA's Web Client R&D (openerp-dev-web)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-embedded-url-action-rco/+merge/57294
open url actions with target='current' inside an iframe
--
https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-embedded-url-action-rco/+merge/57294
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-client-web/6.0-embedded-url-action-rco.
=== modified file 'addons/openerp/controllers/actions.py'
--- addons/openerp/controllers/actions.py 2011-03-25 07:20:33 +0000
+++ addons/openerp/controllers/actions.py 2011-04-12 09:50:16 +0000
@@ -390,19 +390,14 @@
if not ('://' in url or url.startswith('/')):
raise common.message(_('Relative URLs are not supported'))
- # Unknown URL required to open in new window/tab.
- if data['target'] != 'self' or url.startswith('http://') or url.startswith('http://'):
- cherrypy.response.headers['X-Target'] = 'popup'
- cherrypy.response.headers['Location'] = url
- return """<script type="text/javascript">
- window.open('%s')
- </script>
- """ % (url)
- else:
- return """<script type="text/javascript">
- openLink('%s')
- </script>
- """ % (url)
+ # determine target for openAction()
+ openActionMap = {'new': 'popup', 'current': 'iframe'}
+ target = openActionMap.get(data['target'], 'iframe')
+
+ return """<script type="text/javascript">
+ openAction('%s', '%s')
+ </script>
+ """ % (url, target)
def get_action_type(act_id):
=== modified file 'addons/openerp/static/javascript/openerp/openerp.base.js'
--- addons/openerp/static/javascript/openerp/openerp.base.js 2011-02-18 12:55:05 +0000
+++ addons/openerp/static/javascript/openerp/openerp.base.js 2011-04-12 09:50:16 +0000
@@ -31,6 +31,18 @@
}
window.location.assign(url);
}
+
+/**
+ * Opens the provided URL inside the application content section.
+ *
+ * @param url the URL to GET and insert into #appContent
+ */
+function openLinkFrame(url) {
+ var app = jQuery('#appContent');
+ var data = '<iframe src="' + url + '" width="100%" height="100%"></iframe>'
+ jQuery(app[0]).html(data);
+}
+
/**
* Displays a fancybox containing the error display
* @param xhr the received XMLHttpResponse
@@ -174,6 +186,9 @@
case 'popup':
window.open(action_url);
break;
+ case 'iframe':
+ openLinkFrame(action_url);
+ break;
case 'current':
default:
openLink(action_url);
Follow ups