[IMP] Improved dates widgets
bzr revid: fme@openerp.com-20110630121008-qt4yr12z6sk70yua
This commit is contained in:
parent
0c3109c29d
commit
f84f7f5729
|
@ -773,13 +773,14 @@ background: linear-gradient(top, #ffffff 0%,#d8d8d8 11%,#afafaf 86%,#333333 91%,
|
||||||
position: relative;
|
position: relative;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
.openerp input.field_date, .openerp input.field_datetime {
|
.openerp img.ui-datepicker-trigger, .openerp img.ui-datepicker-trigger {
|
||||||
background: #fff url('../img/ui/field_calendar.png') no-repeat right center;
|
margin-left: -20px;
|
||||||
background-origin: content-box;
|
vertical-align: middle;
|
||||||
-moz-background-origin: content;
|
cursor: pointer;
|
||||||
-moz-background-origin: content-box;
|
position: relative;
|
||||||
-webkit-background-origin: content-box;
|
top: -1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* http://www.quirksmode.org/dom/inputfile.html
|
/* http://www.quirksmode.org/dom/inputfile.html
|
||||||
* http://stackoverflow.com/questions/2855589/replace-input-type-file-by-an-image
|
* http://stackoverflow.com/questions/2855589/replace-input-type-file-by-an-image
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -879,12 +879,17 @@ openerp.base.form.FieldDatetime = openerp.base.form.Field.extend({
|
||||||
this._super(view, node);
|
this._super(view, node);
|
||||||
this.template = "FieldDate";
|
this.template = "FieldDate";
|
||||||
this.jqueryui_object = 'datetimepicker';
|
this.jqueryui_object = 'datetimepicker';
|
||||||
|
this.validation_regex = /^\d+-\d+-\d+( \d+:\d+(:\d+)?)?$/;
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
this.$element.find('input').change(this.on_ui_change)[this.jqueryui_object]({
|
this.$element.find('input').change(this.on_ui_change)[this.jqueryui_object]({
|
||||||
dateFormat: 'yy-mm-dd',
|
dateFormat: 'yy-mm-dd',
|
||||||
timeFormat: 'hh:mm:ss'
|
timeFormat: 'hh:mm:ss',
|
||||||
|
showOn: 'button',
|
||||||
|
buttonImage: '/base/static/src/img/ui/field_calendar.png',
|
||||||
|
buttonImageOnly: true,
|
||||||
|
constrainInput: false
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
set_value: function(value) {
|
set_value: function(value) {
|
||||||
|
@ -909,7 +914,15 @@ openerp.base.form.FieldDatetime = openerp.base.form.Field.extend({
|
||||||
this.$element.find('input').attr('disabled', this.readonly);
|
this.$element.find('input').attr('disabled', this.readonly);
|
||||||
},
|
},
|
||||||
validate: function() {
|
validate: function() {
|
||||||
this.invalid = this.required && !this.$element.find('input')[this.jqueryui_object]('getDate');
|
this.invalid = false;
|
||||||
|
var value = this.$element.find('input').val();
|
||||||
|
if (value === "") {
|
||||||
|
this.invalid = this.required;
|
||||||
|
} else if (this.validation_regex) {
|
||||||
|
this.invalid = !this.validation_regex.test(value);
|
||||||
|
} else {
|
||||||
|
this.invalid = !this.$element.find('input')[this.jqueryui_object]('getDate');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
focus: function() {
|
focus: function() {
|
||||||
this.$element.find('input').focus();
|
this.$element.find('input').focus();
|
||||||
|
@ -922,6 +935,7 @@ openerp.base.form.FieldDate = openerp.base.form.FieldDatetime.extend({
|
||||||
init: function(view, node) {
|
init: function(view, node) {
|
||||||
this._super(view, node);
|
this._super(view, node);
|
||||||
this.jqueryui_object = 'datepicker';
|
this.jqueryui_object = 'datepicker';
|
||||||
|
this.validation_regex = /^\d+-\d+-\d+$/;
|
||||||
},
|
},
|
||||||
parse: openerp.base.parse_date,
|
parse: openerp.base.parse_date,
|
||||||
format: openerp.base.format_date
|
format: openerp.base.format_date
|
||||||
|
|
Loading…
Reference in New Issue