[ADD] Changed notification. Added notification on form invalid.
bzr revid: fme@openerp.com-20110405173512-82k1uonpvrdflz4a
This commit is contained in:
@@ -54,6 +54,9 @@ body.openerp {
|
||||
z-index: 1001;
|
||||
display: none;
|
||||
}
|
||||
.openerp .oe_notification * {
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Login */
|
||||
.openerp .login {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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;">
|
||||
|
||||
Reference in New Issue
Block a user