diff options
| author | Fabien Meghazi <fme@openerp.com> | 2011-04-05 19:35:12 +0200 |
|---|---|---|
| committer | Fabien Meghazi <fme@openerp.com> | 2011-04-05 19:35:12 +0200 |
| commit | 37206e0078419dfec5c02f20d23677920acaed8a (patch) | |
| tree | dd2f02e3a784f8d0d7688a658d3ee3508884868b /addons/base/static/src | |
| parent | 53dc9f7218cec34e376c28ccb109901068267a15 (diff) | |
[ADD] Changed notification. Added notification on form invalid.
bzr revid: fme@openerp.com-20110405173512-82k1uonpvrdflz4a
Diffstat (limited to 'addons/base/static/src')
| -rw-r--r-- | addons/base/static/src/css/base.css | 3 | ||||
| -rw-r--r-- | addons/base/static/src/js/chrome.js | 12 | ||||
| -rw-r--r-- | addons/base/static/src/js/form.js | 36 | ||||
| -rw-r--r-- | addons/base/static/src/xml/base.xml | 6 |
4 files changed, 42 insertions, 15 deletions
diff --git a/addons/base/static/src/css/base.css b/addons/base/static/src/css/base.css index 075150f6ca6..f3b83e66ae0 100644 --- a/addons/base/static/src/css/base.css +++ b/addons/base/static/src/css/base.css @@ -54,6 +54,9 @@ body.openerp { z-index: 1001; display: none; } +.openerp .oe_notification * { + color: white; +} /* Login */ .openerp .login { diff --git a/addons/base/static/src/js/chrome.js b/addons/base/static/src/js/chrome.js index 439d34e4ad2..fd28a92a30a 100644 --- a/addons/base/static/src/js/chrome.js +++ b/addons/base/static/src/js/chrome.js @@ -503,8 +503,14 @@ openerp.base.Notification = openerp.base.Controller.extend({ speed: 500 }); }, - add: function(title, text) { - this.$element.notify("create", { + default: function(title, text) { + this.$element.notify('create', { + title: title, + text: text + }); + }, + alert: function(title, text) { + this.$element.notify('create', 'oe_notification_alert', { title: title, text: text }); @@ -690,7 +696,7 @@ openerp.base.WebClient = openerp.base.Controller.extend({ this.header.start(); this.login.start(); this.menu.start(); - this.notification.add("OpenERP Client", "The openerp client has been initialized."); + this.notification.default("OpenERP Client", "The openerp client has been initialized."); }, on_logged: function() { this.action = new openerp.base.ActionManager(this.session, "oe_app"); diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index 9c2c7004c1e..1b6fcb15328 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -145,14 +145,21 @@ openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base switch_editable: function() { }, on_invalid: function() { - console.info("Form invalid"); + var msg = "<ul>"; + _.each(this.fields, function(f) { + if (f.invalid) { + msg += "<li>" + f.string + "</li>"; + } + }); + msg += "</ul>"; + this.notification.alert("The following fields are invalid :", msg); }, on_saved: function(r) { if (!r.result) { this.log("Record was not saved"); } else { // Check response for exceptions, display error - this.notification.add("Record saved", "The record #" + this.datarecord.id + " has been saved."); + this.notification.default("Record saved", "The record #" + this.datarecord.id + " has been saved."); } }, do_search: function (domains, contexts, groupbys) { @@ -413,7 +420,6 @@ openerp.base.form.Field = openerp.base.form.Widget.extend({ this.$element.toggleClass('invalid', this.invalid); }, on_ui_change: function() { - this.view.on_form_changed(this); this.touched = true; } }); @@ -437,9 +443,10 @@ openerp.base.form.FieldChar = openerp.base.form.Field.extend({ this.$element.find('input').attr('disabled', this.readonly); }, on_ui_change: function() { + this._super.apply(this, arguments); this.value = this.$element.find('input').val(); this.invalid = this.required && this.value == ""; - this._super.apply(this, arguments); + this.view.on_form_changed(this); } }); @@ -456,9 +463,10 @@ openerp.base.form.FieldFloat = openerp.base.form.FieldChar.extend({ this.$element.find('input').val(value); }, on_ui_change: function() { - this.value = parseFloat(this.$element.find('input').val()); // TODO: do it well - this.invalid = this.required && this.value == ""; this._super.apply(this, arguments); + this.value = this.$element.find('input').val().replace(/,/g, '.'); + this.invalid = (this.required && this.value == "") || !this.value.match(/^\d(\.\d)?$/) ; + this.view.on_form_changed(this); } }); @@ -479,9 +487,10 @@ openerp.base.form.FieldDate = openerp.base.form.FieldChar.extend({ this.$element.find('input').val(show_value); }, on_ui_change: function() { + this._super.apply(this, arguments); this.value = this.$element.find('input').val(); this.invalid = this.required && this.value == ""; - this._super.apply(this, arguments); + this.view.on_form_changed(this); } }); @@ -503,9 +512,10 @@ openerp.base.form.FieldDatetime = openerp.base.form.FieldChar.extend({ this.$element.find('input').val(show_value); }, on_ui_change: function() { + this._super.apply(this, arguments); this.value = this.$element.find('input').val(); this.invalid = this.required && this.value == ""; - this._super.apply(this, arguments); + this.view.on_form_changed(this); } }); @@ -528,9 +538,10 @@ openerp.base.form.FieldText = openerp.base.form.Field.extend({ this.$element.find('textarea').attr('disabled', this.readonly); }, on_ui_change: function() { + this._super.apply(this, arguments); this.value = this.$element.find('textarea').val(); this.invalid = this.required && this.value == ""; - this._super.apply(this, arguments); + this.view.on_form_changed(this); } }); @@ -557,9 +568,10 @@ openerp.base.form.FieldBoolean = openerp.base.form.Field.extend({ this.$element.find('textarea').attr('disabled', this.readonly); }, on_ui_change: function() { + this._super.apply(this, arguments); this.value = this.$element.find('input').is(':checked'); this.invalid = this.required && !this.value; - this._super.apply(this, arguments); + this.view.on_form_changed(this); } }); @@ -589,9 +601,10 @@ openerp.base.form.FieldSelection = openerp.base.form.Field.extend({ this.$element.find('select').attr('disabled', this.readonly); }, on_ui_change: function() { + this._super.apply(this, arguments); this.value = this.$element.find('select').val(); this.invalid = this.required && this.value == ""; - this._super.apply(this, arguments); + this.view.on_form_changed(this); } }); @@ -646,7 +659,6 @@ openerp.base.form.FieldOne2Many = openerp.base.form.Field.extend({ this.$element.toggleClass('required', this.required); }, on_ui_change: function() { - this.view.on_form_changed(this); } }); diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml index b26c481327a..47913f8cb55 100644 --- a/addons/base/static/src/xml/base.xml +++ b/addons/base/static/src/xml/base.xml @@ -10,6 +10,12 @@ <h1>#{title}</h1> <p>#{text}</p> </div> + <div id="oe_notification_alert" class="ui-state-error"> + <a class="ui-notify-cross ui-notify-close" href="#">x</a> + <span style="float:left; margin:2px 5px 0 0;" class="ui-icon ui-icon-alert"></span> + <h1>#{title}</h1> + <p>#{text}</p> + </div> </div> <div id="oe_login" class="login"></div> <div style="position: absolute; right: 2px; top: 38px;"> |
