From 86616ba88e4cd1278bda16c9b1c0349b068d77b4 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Wed, 31 May 2023 16:14:39 +0200 Subject: [PATCH] [IMP] runbot: add a widget to go to runbot frontend With this commit, a custom widget is added to go to the reunbot frontend from a Char field. This allows to go from the bundle backend page to the bundle frontend page wich is more useful in some situations. e.g.: when creating a custom trigger with the wizard, this allows to test the trigger with 2 clicks. --- runbot/static/src/js/fields.js | 23 +++++++++++++++++++++++ runbot/views/bundle_views.xml | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/runbot/static/src/js/fields.js b/runbot/static/src/js/fields.js index 322e0cbf..1696709f 100644 --- a/runbot/static/src/js/fields.js +++ b/runbot/static/src/js/fields.js @@ -36,6 +36,29 @@ var FieldJson = basic_fields.FieldChar.extend({ registry.add('jsonb', FieldJson) +var FieldCharFrontendUrl = basic_fields.FieldChar.extend({ + quickEditExclusion: [ + '.fa-external-link', + ], + init() { + this._super.apply(this, arguments); + if (this.model.startsWith('runbot.')) { + this.route = '/runbot/' + this.model.split('.')[1] + '/' + this.res_id; + } else { + this.route = false; + } + }, + _renderReadonly: function() { + this._super.apply(this, arguments); + var link= ''; + if (this.route) { + link = ' '; + this.$el.html('' + this.$el.html() + link + ''); + } + } +}); + +registry.add('char_frontend_url', FieldCharFrontendUrl) var FrontendUrl = relational_fields.FieldMany2One.extend({ isQuickEditable: false, diff --git a/runbot/views/bundle_views.xml b/runbot/views/bundle_views.xml index a0adf3d2..0cea8bd1 100644 --- a/runbot/views/bundle_views.xml +++ b/runbot/views/bundle_views.xml @@ -39,7 +39,7 @@
- + @@ -124,7 +124,7 @@ - +