diff --git a/runbot/static/src/js/fields/fields.js b/runbot/static/src/js/fields/fields.js index 8b833bf3..302f6a5e 100644 --- a/runbot/static/src/js/fields/fields.js +++ b/runbot/static/src/js/fields/fields.js @@ -138,15 +138,19 @@ registry.category("fields").add("char_frontend_url", { // Pull Request URL Widget +const pullRequestRegex = /\/([a-zA-Z-_]+\/[a-zA-Z-_]+)\/pull\/(\d+)/; class PullRequestUrlField extends UrlField { static template = xml` - + `; static components = { UrlField } - setup() { - if (!this.props.readonly) { - throw new Error("This widget works only on readonly fields"); + get fieldProps() { + const props = {...this.props}; + const parts = pullRequestRegex.exec(this.props.record.data[props.name]) + if (parts) { + props.text = `${parts[1]}#${parts[2]}`; } + return props } }