Browse Source

[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 options
pull/1248/head
docmfried 9 years ago
committed by Dennis Sluijk
parent
commit
6149564392
  1. 24
      web_widget_timepicker/README.rst
  2. 22
      web_widget_timepicker/__init__.py
  3. 51
      web_widget_timepicker/__openerp__.py
  4. 2
      web_widget_timepicker/static/src/css/web_widget_timepicker.css
  5. 52
      web_widget_timepicker/static/src/js/web_widget_timepicker.js
  6. 0
      web_widget_timepicker/static/src/lib/jquery.timepicker/jquery.timepicker.css
  7. 0
      web_widget_timepicker/static/src/lib/jquery.timepicker/jquery.timepicker.js
  8. 3
      web_widget_timepicker/static/src/xml/web_widget_timepicker.xml
  9. 12
      web_widget_timepicker/views/web_widget_timepicker_assets.xml

24
web_widget_timepicker/README.rst

@ -5,19 +5,19 @@
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
The widget uses the jquery.timepicker plugin by Jon Thornton
The widget uses the jquery.timepicker plugin by Jon Thornton
Usage
@ -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)

22
web_widget_timepicker/__init__.py

@ -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).

51
web_widget_timepicker/__openerp__.py

@ -1,49 +1,34 @@
# -*- 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',
# any module necessary for this one to work correctly
'depends': [
'web'
'web'
],
'css': [
'static/src/lib/jquery.timerpicker/jquery.timepicker.css',
'static/src/css/web_widget_timepicker.css'
],
'js': [
'static/src/lib/jquery.timerpicker/jquery.timepicker.js',
'static/src/js/web_widget_timepicker.js',
],
'qweb' : [
'static/src/xml/web_widget_timepicker.xml'
],
'css': [ 'static/src/css/jquery.timepicker.css',
'static/src/css/timepicker.css',
],
'js': [ 'static/src/js/timepicker_widget.js',
'static/src/js/jquery.timepicker.js',
],
'qweb' : [ 'static/src/xml/time_picker.xml', ],
# always loaded
'data': [
'views/assets.xml',
'views/web_widget_timepicker_assets.xml'
],
#Installation options

2
web_widget_timepicker/static/src/css/timepicker.css → web_widget_timepicker/static/src/css/web_widget_timepicker.css

@ -1,3 +1,3 @@
.oe_form_editable .oe_form .oe_form_field_time input {
width: 7em;
width: 6em;
}

52
web_widget_timepicker/static/src/js/timepicker_widget.js → web_widget_timepicker/static/src/js/web_widget_timepicker.js

@ -1,21 +1,22 @@
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',
},
init: function (field_manager, node) {
this._super(field_manager, node);
this.internal_set_value(0);
this.options = _.defaults( {}, {
disableTextInput: true,
@ -29,14 +30,45 @@ 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'));
}
},
is_syntax_valid: function() {
if (!this.get("effective_readonly") && this.$("input").size() > 0) {
try {
this.parse_value(this.$('input').val(), '');
this.parse_value(this.$('input').val(),'');
return true;
} catch(e) {
return false;
@ -62,17 +94,17 @@ 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'), '');
var show_value = this.format_value(this.get('value'),'');
if (!this.get("effective_readonly")) {
this.$input = this.$el.find('input');

0
web_widget_timepicker/static/src/css/jquery.timepicker.css → web_widget_timepicker/static/src/lib/jquery.timepicker/jquery.timepicker.css

0
web_widget_timepicker/static/src/js/jquery.timepicker.js → web_widget_timepicker/static/src/lib/jquery.timepicker/jquery.timepicker.js

3
web_widget_timepicker/static/src/xml/time_picker.xml → web_widget_timepicker/static/src/xml/web_widget_timepicker.xml

@ -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">
@ -18,4 +17,4 @@
</t>
</span>
</t>
</templates>
</templates>

12
web_widget_timepicker/views/assets.xml → web_widget_timepicker/views/web_widget_timepicker_assets.xml

@ -2,13 +2,13 @@
<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>
</openerp>
</openerp>
Loading…
Cancel
Save