mirror of https://github.com/OCA/web.git
[FIX]: Formal license and Travis LINT errors
[FIX]: Renaming files according to OCA standards [FIX]: Change internal persistance form char to float [FIX]: Reorder jquery plugin to lib directory [ADD]: Form field record defintion can override timepicker plugin optionspull/1520/head
parent
75d1cc434b
commit
55b9b1e4a2
|
@ -5,14 +5,14 @@
|
|||
Timepicker widget in form view
|
||||
==============================
|
||||
|
||||
This module defines a timepicker widget, to be used with either char fields
|
||||
or (function) fields of type character. Use ``widget='timepicker'`` in your form view
|
||||
definition.
|
||||
This module defines a timepicker widget, to be used with float fields
|
||||
or (function) fields. Use ``widget='timepicker'`` in your form view
|
||||
definition. It can be use as a replacement for the standard float_time widget.
|
||||
|
||||
If you use the widget with a character field, the input field has the following default
|
||||
If you use the widget with a field record, the input field has the following default
|
||||
timepicker options:
|
||||
|
||||
* By default direct input is disabled
|
||||
* By default direct user input is disabled
|
||||
* By default the possible selection is based on 15 minute interval
|
||||
* By default 24 hour mode with H:i format
|
||||
* Scroll selection defaults to current server time
|
||||
|
@ -27,17 +27,25 @@ This module defines a new widget type for form views input fileds.
|
|||
|
||||
Set the attribute ``widget=timepicker`` in a ``field`` tag in a form view.
|
||||
|
||||
You can pass all options through the "timepicker" field in the options::
|
||||
|
||||
...
|
||||
<field name="mytimefieldname" `widget=timepicker`` options="{'step': '15', 'disableTextInput': false}"/>
|
||||
...
|
||||
|
||||
See the available options at https://github.com/jonthornton/jquery-timepicker#timepicker-plugin-for-jquery
|
||||
|
||||
|
||||
ToDo
|
||||
====
|
||||
|
||||
Make timepicker options available in field defintion as additional attributes / options.
|
||||
Sanity check on options available in field defintion as override options for timepicker widget.
|
||||
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Jon Thornton (jquery.timepicker plugin)
|
||||
Jon Thornton (https://cdnjs.com/libraries/jquery-timepicker)
|
||||
jquery.timepicker plugin - This software is made available under the open source MIT License. © 2014 Jon Thornton and contributors
|
||||
|
||||
Odoo Community Association (OCA)
|
||||
|
|
|
@ -1,22 +1,2 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2015 BADEP (<http://www.badep.ma>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
@ -1,29 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2016 Michael Fried @ Vividlab (<http://www.vividlab.de>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# © 2016 Michael Fried @ Vividlab (<http://www.vividlab.de>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': '',
|
||||
'version': '0.1',
|
||||
'author': 'Vividlab, Odoo Community Association (OCA)',
|
||||
'name': 'Web Timepicker Widget',
|
||||
'version': '9.0.1.0.0',
|
||||
'author': 'Michael Fried@Vividlab, Odoo Community Association (OCA)',
|
||||
'license': 'AGPL-3',
|
||||
'category': 'Web',
|
||||
'website': 'https://github.com/OCA/Web',
|
||||
|
@ -32,18 +14,21 @@
|
|||
'depends': [
|
||||
'web'
|
||||
],
|
||||
|
||||
'css': [ 'static/src/css/jquery.timepicker.css',
|
||||
'static/src/css/timepicker.css',
|
||||
'css': [
|
||||
'static/src/lib/jquery.timerpicker/jquery.timepicker.css',
|
||||
'static/src/css/web_widget_timepicker.css'
|
||||
],
|
||||
'js': [ 'static/src/js/timepicker_widget.js',
|
||||
'static/src/js/jquery.timepicker.js',
|
||||
'js': [
|
||||
'static/src/lib/jquery.timerpicker/jquery.timepicker.js',
|
||||
'static/src/js/web_widget_timepicker.js',
|
||||
],
|
||||
'qweb' : [
|
||||
'static/src/xml/web_widget_timepicker.xml'
|
||||
],
|
||||
'qweb' : [ 'static/src/xml/time_picker.xml', ],
|
||||
|
||||
# always loaded
|
||||
'data': [
|
||||
'views/assets.xml',
|
||||
'views/web_widget_timepicker_assets.xml'
|
||||
],
|
||||
|
||||
#Installation options
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
.oe_form_editable .oe_form .oe_form_field_time input {
|
||||
width: 7em;
|
||||
width: 6em;
|
||||
}
|
|
@ -1,15 +1,14 @@
|
|||
odoo.define('timepicker.form_widgets', function (require) {
|
||||
|
||||
odoo.define('web_widget_timepicker.form_widgets', function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require('web.core');
|
||||
var formats = require('web.formats');
|
||||
var common = require('web.form_common');
|
||||
|
||||
var _t = core._t;
|
||||
|
||||
var TimePicker = common.AbstractField.extend(common.ReinitializeFieldMixin, {
|
||||
is_field_number: true,
|
||||
template: "TimePickerField",
|
||||
internal_format: 'float_time',
|
||||
widget_class: 'oe_form_field_time',
|
||||
events: {
|
||||
'change input': 'store_dom_value',
|
||||
|
@ -17,6 +16,8 @@ odoo.define('timepicker.form_widgets', function (require) {
|
|||
init: function (field_manager, node) {
|
||||
this._super(field_manager, node);
|
||||
|
||||
this.internal_set_value(0);
|
||||
|
||||
this.options = _.defaults( {}, {
|
||||
disableTextInput: true,
|
||||
forceRoundTime: true,
|
||||
|
@ -29,7 +30,38 @@ odoo.define('timepicker.form_widgets', function (require) {
|
|||
initialize_content: function() {
|
||||
if(!this.get("effective_readonly")) {
|
||||
this.$input = this.$el.find('input');
|
||||
this.$input.timepicker(this.options);
|
||||
|
||||
var effective_options = this.options;
|
||||
|
||||
if(typeof this.node.attrs.options !== 'undefined' && this.node.attrs.options.length > 0 ) {
|
||||
|
||||
var custom_options = eval('('+ this.node.attrs.options +')')
|
||||
|
||||
// for(var key in custom_options) {
|
||||
// console.log('attr key : ' + key);
|
||||
// console.log('attr value : ' + custom_options[key] );
|
||||
// }
|
||||
|
||||
// if(typeof effective_options === 'object') {
|
||||
// for(var key in effective_options) {
|
||||
// console.log('def key : ' + key);
|
||||
// console.log('def value : ' + effective_options[key] );
|
||||
// }
|
||||
// }
|
||||
|
||||
if(typeof custom_options === 'object') {
|
||||
effective_options = $.extend({}, this.options, custom_options );
|
||||
}
|
||||
|
||||
// if(typeof effective_options === 'object') {
|
||||
// for(var key in effective_options) {
|
||||
// console.log('merge key : ' + key);
|
||||
// console.log('merge value : ' + effective_options[key] );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
this.$input.timepicker(effective_options);
|
||||
this.setupFocus(this.$('input'));
|
||||
}
|
||||
},
|
||||
|
@ -62,14 +94,14 @@ odoo.define('timepicker.form_widgets', function (require) {
|
|||
if (!this.get('effective_readonly')) {
|
||||
this.internal_set_value(
|
||||
this.parse_value(
|
||||
this.$('input').val()));
|
||||
this.$('input').val(),''));
|
||||
}
|
||||
},
|
||||
parse_value: function(val, def) {
|
||||
return formats.parse_value(val, this, def);
|
||||
return formats.parse_value(val, {"widget": this.internal_format}, def);
|
||||
},
|
||||
format_value: function(val, def) {
|
||||
return formats.format_value(val, this, def);
|
||||
return formats.format_value(val, {"widget": this.internal_format}, def);
|
||||
},
|
||||
render_value: function() {
|
||||
var show_value = this.format_value(this.get('value'),'');
|
|
@ -1,5 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<templates id="template" xml:space="preserve">
|
||||
<t t-name="TimePickerField">
|
||||
<span t-att-class="'oe_form_field '+widget.widget_class" t-att-style="widget.node.attrs.style">
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="assets_backend" name="web_widget_timepicker assets" inherit_id="web.assets_backend">
|
||||
<template id="web_widget_timepicker_assets_backend" name="web_widget_timepicker assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/web_widget_timepicker/static/src/js/jquery.timepicker.js"></script>
|
||||
<script type="text/javascript" src="/web_widget_timepicker/static/src/js/timepicker_widget.js"></script>
|
||||
<link rel="stylesheet" href="/web_widget_timepicker/static/src/css/jquery.timepicker.css"/>
|
||||
<link rel="stylesheet" href="/web_widget_timepicker/static/src/css/timepicker.css"/>
|
||||
<script type="text/javascript" src="/web_widget_timepicker/static/src/lib/jquery.timepicker/jquery.timepicker.js"></script>
|
||||
<script type="text/javascript" src="/web_widget_timepicker/static/src/js/web_widget_timepicker.js"></script>
|
||||
<link rel="stylesheet" href="/web_widget_timepicker/static/src/lib/jquery.timepicker/jquery.timepicker.css"/>
|
||||
<link rel="stylesheet" href="/web_widget_timepicker/static/src/css/web_widget_timepicker.css"/>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
Loading…
Reference in New Issue