changeset 8de5a74efe2a in sao:default
details: https://hg.tryton.org/sao?cmd=changeset;node=8de5a74efe2a
description:
        Update button state and title on Wizard

        issue8498
        review271841002
diffstat:

 src/model.js  |   3 +++
 src/screen.js |   1 +
 src/wizard.js |  24 ++++++++++++++++++++----
 3 files changed, 24 insertions(+), 4 deletions(-)

diffs (101 lines):

diff -r 8b56c436cf02 -r 8de5a74efe2a src/model.js
--- a/src/model.js      Sat Jul 20 21:56:22 2019 +0200
+++ b/src/model.js      Mon Jul 22 23:48:17 2019 +0200
@@ -228,6 +228,9 @@
             if (!this.parent) {
                 return jQuery.when.apply(jQuery,
                     this.screens.map(function(screen) {
+                        if (screen.group_changed_callback) {
+                            screen.group_changed_callback();
+                        }
                         return screen.display();
                     }));
             }
diff -r 8b56c436cf02 -r 8de5a74efe2a src/screen.js
--- a/src/screen.js     Sat Jul 20 21:56:22 2019 +0200
+++ b/src/screen.js     Mon Jul 22 23:48:17 2019 +0200
@@ -813,6 +813,7 @@
             this.tab = null;
             this.message_callback = null;
             this.switch_callback = null;
+            this.group_changed_callback = null;
             // count_tab_domain is called in Sao.Tab.Form.init after
             // switch_view to avoid unnecessary call to fields_view_get by
             // domain_parser.
diff -r 8b56c436cf02 -r 8de5a74efe2a src/wizard.js
--- a/src/wizard.js     Sat Jul 20 21:56:22 2019 +0200
+++ b/src/wizard.js     Mon Jul 22 23:48:17 2019 +0200
@@ -74,6 +74,7 @@
 
                         this.screen.new_(false).then(function() {
                             
this.screen.current_record.set_default(view.defaults);
+                            this.update_buttons();
                             this.screen.set_cursor();
                         }.bind(this));
 
@@ -151,6 +152,13 @@
             }
             return button;
         },
+        update_buttons: function() {
+            var record = this.screen.current_record;
+            for (var state in this.states) {
+                var button = this.states[state];
+                button.set_state(record);
+            }
+        },
         update: function(view, buttons) {
             buttons.forEach(function(button) {
                 this._get_button(button);
@@ -159,9 +167,11 @@
                     {mode: [], context: this.context});
             this.screen.add_view(view);
             this.screen.switch_view();
-            // TODO record-modified
-            // TODO title
-            // TODO toolbar
+            this.screen.group_changed_callback = 
this.update_buttons.bind(this);
+            this.header.append(jQuery('<h4/>', {
+                'class': 'model-title',
+                'title': this.name,
+            }).append(Sao.common.ellipsize(this.name, 20)));
             this.widget.append(this.screen.screen_container.el);
         }
     });
@@ -184,15 +194,19 @@
             this.tab = null;  // Filled by Sao.Tab.Wizard
             this.name = name || '';
 
+            this.header = jQuery('<div/>', {
+                'class': 'modal-header',
+            });
             this.form = jQuery('<div/>', {
                 'class': 'wizard-form',
-            }).append(this.widget);
+            }).append(this.header).append(this.widget);
             this.footer = jQuery('<div/>', {
                 'class': 'modal-footer'
             }).appendTo(this.form);
         },
         clean: function() {
             Sao.Wizard.Form._super.clean.call(this);
+            this.header.empty();
             this.footer.empty();
         },
         _get_button: function(definition) {
@@ -233,6 +247,7 @@
             Sao.Wizard.Dialog._super.init.call(this);
             var dialog = new Sao.Dialog(name, 'wizard-dialog', 'md', false);
             this.dialog = dialog.modal;
+            this.header = dialog.header;
             this.content = dialog.content;
             this.footer = dialog.footer;
             this.dialog.on('keydown', function(e) {
@@ -247,6 +262,7 @@
         },
         clean: function() {
             Sao.Wizard.Dialog._super.clean.call(this);
+            this.header.empty();
             this.footer.empty();
         },
         _get_button: function(definition) {

Reply via email to