From 6239ce291a2edd0b36e8e875da372ab3e4fbebb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 13 Apr 2020 12:21:55 +0200 Subject: [PATCH] Add link button issue9051 review280841002 --- CHANGELOG | 1 + src/board.js | 7 ++- src/model.js | 2 + src/sao.less | 3 + src/tab.js | 1 + src/view/form.js | 155 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 168 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index c2c3d86adc..e4b434314f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Support link button on form * Add URL for the current export * Add option to export listed records * Set treeview header sticky on top diff --git a/src/board.js b/src/board.js index d0ddcc3d83..b8d2680869 100644 --- a/src/board.js +++ b/src/board.js @@ -34,6 +34,7 @@ this.context = context; this.actions = []; + this.state_widgets = []; this.el = jQuery('
', { 'class': 'board' }); @@ -46,9 +47,13 @@ this.actions_prms = jQuery.when.apply(jQuery, actions_prms); }, reload: function() { - for (var i = 0; i < this.actions.length; i++) { + var i; + for (i = 0; i < this.actions.length; i++) { this.actions[i].display(); } + for (i = 0; i < this.state_widgets.length; i++) { + this.state_widgets[i].set_state(null); + } } }); diff --git a/src/model.js b/src/model.js index 5daa1be319..0077da3975 100644 --- a/src/model.js +++ b/src/model.js @@ -544,6 +544,7 @@ this._timestamp = null; this.resources = null; this.button_clicks = {}; + this.links_counts = {}; this.state_attrs = {}; this.autocompletion = {}; this.exception = false; @@ -1242,6 +1243,7 @@ this._changed = {}; this._timestamp = null; this.button_clicks = {}; + this.links_counts = {}; }, _check_load: function(fields) { if (!this.get_loaded(fields)) { diff --git a/src/sao.less b/src/sao.less index e5e9d89b03..ade93dd2b3 100644 --- a/src/sao.less +++ b/src/sao.less @@ -621,6 +621,9 @@ input.column-boolean { text-align: left; text-align: start; } + .form-link { + display: none; + } } @media screen and (max-width: @screen-xs-max) { diff --git a/src/tab.js b/src/tab.js index f81be05a45..7452142ab5 100644 --- a/src/tab.js +++ b/src/tab.js @@ -1351,6 +1351,7 @@ action = this.board.actions[i]; action.screen.tab = this; } + this.board.reload(); }.bind(this)); this.content.append(this.board.el); }.bind(this)); diff --git a/src/view/form.js b/src/view/form.js index 4330748e11..525a57cec8 100644 --- a/src/view/form.js +++ b/src/view/form.js @@ -95,6 +95,11 @@ function eval_pyson(value){ this.view.state_widgets.push(button); this.container.add(button, attributes); }, + _parse_link: function(node, attributes) { + var link = new Sao.View.Form.Link(attributes); + this.view.state_widgets.push(link); + this.container.add(link, attributes); + }, _parse_image: function(node, attributes) { var image = new Sao.View.Form.Image_(attributes); this.view.state_widgets.push(image); @@ -884,6 +889,156 @@ function eval_pyson(value){ } }); + Sao.View.Form.Link = Sao.class_(Sao.View.Form.StateWidget, { + class_: 'form-link', + init: function(attributes) { + Sao.View.Form.Link._super.init.call(this, attributes); + this.el = jQuery('