bzr revid: nicolas.vanhoren@openerp.com-20110914155127-yc7nnjeo9nx4qdtu
This commit is contained in:
niv-openerp 2011-09-14 17:51:27 +02:00
commit 8d9285375d
4 changed files with 99 additions and 33 deletions

View File

@ -821,6 +821,7 @@ label.error {
} }
.openerp td.oe_form_frame_cell { .openerp td.oe_form_frame_cell {
padding: 2px; padding: 2px;
position: relative;
} }
.openerp td.oe_form_frame_cell.oe_form_group { .openerp td.oe_form_frame_cell.oe_form_group {
padding: 0; padding: 0;
@ -887,12 +888,19 @@ label.error {
position: relative; position: relative;
vertical-align: top; vertical-align: top;
} }
.openerp img.ui-datepicker-trigger { .openerp .oe_input_icon {
margin-left: -20px; position: absolute;
vertical-align: middle;
cursor: pointer; cursor: pointer;
position: relative; right: 5px;
top: -1px; top: 5px;
}
.openerp .oe_input_icon_disabled {
position: absolute;
cursor: default;
opacity: 0.5;
filter:alpha(opacity=50);
right: 5px;
top: 5px;
} }
.openerp img.oe_field_translate { .openerp img.oe_field_translate {
margin-left: -21px; margin-left: -21px;

View File

@ -1110,37 +1110,51 @@ openerp.web.form.FieldDatetime = openerp.web.form.Field.extend({
this.jqueryui_object = 'datetimepicker'; this.jqueryui_object = 'datetimepicker';
}, },
start: function() { start: function() {
var self = this;
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);
dateFormat: 'yy-mm-dd', this.picker({
timeFormat: 'hh:mm:ss', onSelect: this.on_picker_select,
showOn: 'button', changeMonth: true,
buttonImage: '/web/static/src/img/ui/field_calendar.png', changeYear: true,
buttonImageOnly: true, showWeek: true,
constrainInput: false showButtonPanel: false
});
this.$element.find('img.oe_datepicker_trigger').click(function() {
if (!self.readonly) {
self.picker('setDate', self.value || new Date());
self.$element.find('.oe_datepicker').toggle();
}
});
this.$element.find('.ui-datepicker-inline').removeClass('ui-widget-content ui-corner-all');
this.$element.find('button.oe_datepicker_close').click(function() {
self.$element.find('.oe_datepicker').hide();
}); });
}, },
picker: function() {
return $.fn[this.jqueryui_object].apply(this.$element.find('.oe_datepicker_container'), arguments);
},
on_picker_select: function(text, instance) {
var date = this.picker('getDate');
this.$element.find('input').val(date ? this.format_client(date) : '').change();
},
set_value: function(value) { set_value: function(value) {
this._super.apply(this, arguments); value = this.parse(value);
if (!value) { this._super(value);
this.$element.find('input').val(''); this.$element.find('input').val(value ? this.format_client(value) : '');
} else { },
this.$element.find('input').unbind('change'); get_value: function() {
// jQuery UI date picker wrongly call on_change event herebelow return this.format(this.value);
this.$element.find('input')[this.jqueryui_object]('setDate', this.parse(value));
this.$element.find('input').change(this.on_ui_change);
}
}, },
set_value_from_ui: function() { set_value_from_ui: function() {
this.value = this.$element.find('input')[this.jqueryui_object]('getDate') || false; var value = this.$element.find('input').val() || false;
if (this.value) { this.value = this.parse_client(value);
this.value = this.format(this.value);
}
this._super(); this._super();
}, },
update_dom: function() { update_dom: function() {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.$element.find('input').datepicker(this.readonly ? 'disable' : 'enable'); this.$element.find('input').attr('disabled', this.readonly);
this.$element.find('img.oe_datepicker_trigger').toggleClass('oe_input_icon_disabled', this.readonly);
}, },
validate: function() { validate: function() {
this.invalid = false; this.invalid = false;
@ -1148,15 +1162,26 @@ openerp.web.form.FieldDatetime = openerp.web.form.Field.extend({
if (value === "") { if (value === "") {
this.invalid = this.required; this.invalid = this.required;
} else { } else {
this.invalid = !this.$element.find('input')[this.jqueryui_object]('getDate'); try {
this.parse_client(value);
this.invalid = false;
} catch(e) {
this.invalid = true;
}
} }
}, },
focus: function() { focus: function() {
this.$element.find('input').focus(); this.$element.find('input').focus();
}, },
parse: openerp.web.auto_str_to_date, parse: openerp.web.auto_str_to_date,
parse_client: function(v) {
return openerp.web.parse_value(v, this.field);
},
format: function(val) { format: function(val) {
return openerp.web.auto_date_to_str(val, this.field.type); return openerp.web.auto_date_to_str(val, this.field.type);
},
format_client: function(v) {
return openerp.web.format_value(v, this.field);
} }
}); });
@ -1164,6 +1189,10 @@ openerp.web.form.FieldDate = openerp.web.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';
},
on_picker_select: function(text, instance) {
this._super(text, instance);
this.$element.find('.oe_datepicker').hide();
} }
}); });

View File

@ -776,6 +776,31 @@ openerp.web.ListView.List = openerp.web.Class.extend( /** @lends openerp.web.Lis
this.$current.empty().append( this.$current.empty().append(
QWeb.render('ListView.rows', _.extend({ QWeb.render('ListView.rows', _.extend({
render_cell: openerp.web.format_cell}, this))); render_cell: openerp.web.format_cell}, this)));
this.pad_table_to(5);
},
pad_table_to: function (count) {
if (this.records.length >= count ||
_(this.columns).any(function(column) { return column.meta; })) {
return;
}
var cells = [];
if (this.options.selectable) {
cells.push('<td title="selection"></td>');
}
_(this.columns).each(function(column) {
if (column.invisible !== '1') {
cells.push('<td title="' + column.string + '">&nbsp;</td>');
}
});
if (this.options.deletable) {
cells.push('<td><button type="button" style="visibility: hidden"> </button></td>');
}
cells.unshift('<tr>');
cells.push('</tr>');
var row = cells.join('');
this.$current.append(new Array(count - this.records.length + 1).join(row));
this.refresh_zebra(this.records.length);
}, },
/** /**
* Gets the ids of all currently selected records, if any * Gets the ids of all currently selected records, if any
@ -1138,12 +1163,14 @@ openerp.web.ListView.Groups = openerp.web.Class.extend( /** @lends openerp.web.L
} }
// ondrop, move relevant record & fix sequences // ondrop, move relevant record & fix sequences
list.$current.sortable({ list.$current.sortable({
axis: 'y',
items: '> tr[data-id]',
stop: function (event, ui) { stop: function (event, ui) {
var to_move = list.records.get(ui.item.data('id')), var to_move = list.records.get(ui.item.data('id')),
target_id = ui.item.prev().data('id'); target_id = ui.item.prev().data('id');
list.records.remove(to_move); list.records.remove(to_move);
var to = target_id ? list.records.indexOf(list.records.get(target_id)) : 0; var to = target_id ? list.records.indexOf(list.records.get(target_id)) + 1 : 0;
list.records.add(to_move, { at: to }); list.records.add(to_move, { at: to });
// resequencing time! // resequencing time!

View File

@ -810,11 +810,13 @@
<img class="oe_field_translate" t-if="widget.field.translate" src="/web/static/src/img/icons/terp-translate.png" width="16" height="16" border="0"/> <img class="oe_field_translate" t-if="widget.field.translate" src="/web/static/src/img/icons/terp-translate.png" width="16" height="16" border="0"/>
</t> </t>
<t t-name="FieldDate"> <t t-name="FieldDate">
<input type="text" size="1" style="width: 100%" <t t-call="FieldChar"/>
t-att-name="widget.name" <img class="oe_input_icon oe_datepicker_trigger" src="/web/static/src/img/ui/field_calendar.png"
t-att-id="widget.element_id + '_field'" title="Select date" width="16" height="16" border="0"/>
t-att-class="'field_' + widget.type" <div class="oe_datepicker ui-widget-content ui-corner-all" style="display: none; position: absolute; z-index: 1;">
/> <div class="oe_datepicker_container"/>
<button type="button" class="oe_datepicker_close ui-state-default ui-priority-primary ui-corner-all" style="float: right;">Done</button>
</div>
</t> </t>
<t t-name="FieldSelection"> <t t-name="FieldSelection">
<select <select