[REF] web, *: update bootstrap-datetimepicker to tempusdominus
* website_form, debian Our old library for datetimepicker for bootstrap 3 is deprecated and an updated version is developed by the same team under the new name "tempusdominus", for bootstrap 4. The lib is imported by taking the *unminified build* JS and the *src* scss. Odoo is also bundling the lib better by putting the scss file in both backend and frontend assets instead of only in common (so that the scss is compiled differently for the frontend and the backend). Note: the lib also needed to be patched inline to solve a bug at one line.
This commit is contained in:
-2646
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016 Tempus Dominus
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
File diff suppressed because it is too large
Load Diff
+18
-28
@@ -1,15 +1,10 @@
|
||||
/*!
|
||||
* Datetimepicker for Bootstrap 3
|
||||
* ! version : 4.17.42
|
||||
* https://github.com/Eonasdan/bootstrap-datetimepicker/
|
||||
*/
|
||||
$bs-datetimepicker-timepicker-font-size: 1.2em !default;
|
||||
$bs-datetimepicker-active-bg: $btn-primary-bg !default;
|
||||
$bs-datetimepicker-active-color: $btn-primary-color !default;
|
||||
$bs-datetimepicker-border-radius: $border-radius-base !default;
|
||||
$bs-datetimepicker-btn-hover-bg: $gray-lighter !default;
|
||||
$bs-datetimepicker-disabled-color: $gray-light !default;
|
||||
$bs-datetimepicker-alternate-color: $gray-light !default;
|
||||
$bs-datetimepicker-active-bg: $blue !default;
|
||||
$bs-datetimepicker-active-color: $white !default;
|
||||
$bs-datetimepicker-border-radius: $border-radius !default;
|
||||
$bs-datetimepicker-btn-hover-bg: $gray-200 !default;
|
||||
$bs-datetimepicker-disabled-color: $gray-600 !default;
|
||||
$bs-datetimepicker-alternate-color: $gray-600 !default;
|
||||
$bs-datetimepicker-secondary-border-color: #ccc !default;
|
||||
$bs-datetimepicker-secondary-border-color-rgba: rgba(0, 0, 0, 0.2) !default;
|
||||
$bs-datetimepicker-primary-border-color: white !default;
|
||||
@@ -19,20 +14,21 @@ $bs-datetimepicker-text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25) !default;
|
||||
list-style: none;
|
||||
|
||||
&.dropdown-menu {
|
||||
display: block;
|
||||
margin: 2px 0;
|
||||
padding: 4px;
|
||||
width: 19em;
|
||||
width: 14rem;
|
||||
|
||||
&.timepicker-sbs {
|
||||
@media (min-width: $screen-sm-min) {
|
||||
@media (min-width: map-get($grid-breakpoints, 'sm')) {
|
||||
width: 38em;
|
||||
}
|
||||
|
||||
@media (min-width: $screen-md-min) {
|
||||
@media (min-width: map-get($grid-breakpoints, 'md')) {
|
||||
width: 38em;
|
||||
}
|
||||
|
||||
@media (min-width: $screen-lg-min) {
|
||||
@media (min-width: map-get($grid-breakpoints, 'lg')) {
|
||||
width: 38em;
|
||||
}
|
||||
}
|
||||
@@ -81,7 +77,7 @@ $bs-datetimepicker-text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25) !default;
|
||||
}
|
||||
}
|
||||
|
||||
&.pull-right {
|
||||
&.float-right {
|
||||
&:before {
|
||||
left: auto;
|
||||
right: 6px;
|
||||
@@ -92,6 +88,10 @@ $bs-datetimepicker-text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25) !default;
|
||||
right: 7px;
|
||||
}
|
||||
}
|
||||
|
||||
&.wider {
|
||||
width: 16rem;
|
||||
}
|
||||
}
|
||||
|
||||
.list-unstyled {
|
||||
@@ -335,18 +335,8 @@ $bs-datetimepicker-text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25) !default;
|
||||
line-height: 27px;
|
||||
}
|
||||
}
|
||||
|
||||
&.wider {
|
||||
width: 21em;
|
||||
}
|
||||
|
||||
& .datepicker-decades .decade {
|
||||
line-height: 1.8em !important;
|
||||
}
|
||||
}
|
||||
|
||||
.input-group.date {
|
||||
& .input-group-addon {
|
||||
cursor: pointer;
|
||||
}
|
||||
.input-group [data-toggle="datetimepicker"] {
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -1,69 +1,74 @@
|
||||
odoo.define('web.datepicker', function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require('web.core');
|
||||
var field_utils = require('web.field_utils');
|
||||
var time = require('web.time');
|
||||
var Widget = require('web.Widget');
|
||||
|
||||
var _t = core._t;
|
||||
|
||||
var DateWidget = Widget.extend({
|
||||
template: "web.datepicker",
|
||||
type_of_date: "date",
|
||||
events: {
|
||||
'dp.change': 'changeDatetime',
|
||||
'dp.show': '_onShow',
|
||||
'change.datetimepicker': 'changeDatetime',
|
||||
'show.datetimepicker': '_onShow',
|
||||
'click input.o_datepicker_input': '_onClick',
|
||||
'change .o_datepicker_input': 'changeDatetime',
|
||||
'input input': '_onInput',
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
init: function(parent, options) {
|
||||
init: function (parent, options) {
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
var l10n = _t.database.parameters;
|
||||
|
||||
this.name = parent.name;
|
||||
this.options = _.defaults(options || {}, {
|
||||
this.options = _.extend({
|
||||
format : this.type_of_date === 'datetime' ? time.getLangDatetimeFormat() : time.getLangDateFormat(),
|
||||
minDate: moment({ y: 1900 }),
|
||||
maxDate: moment().add(200, "y"),
|
||||
calendarWeeks: true,
|
||||
useCurrent: false,
|
||||
icons: {
|
||||
time: 'fa fa-clock-o',
|
||||
date: 'fa fa-calendar',
|
||||
next: 'fa fa-chevron-right',
|
||||
previous: 'fa fa-chevron-left',
|
||||
up: 'fa fa-chevron-up',
|
||||
down: 'fa fa-chevron-down',
|
||||
close: 'fa fa-times',
|
||||
previous: 'fa fa-chevron-left',
|
||||
next: 'fa fa-chevron-right',
|
||||
today: 'fa fa-calendar-check-o',
|
||||
clear: 'fa fa-delete',
|
||||
close: 'fa fa-times'
|
||||
},
|
||||
calendarWeeks: true,
|
||||
buttons: {
|
||||
showToday: false,
|
||||
showClear: false,
|
||||
showClose: false,
|
||||
},
|
||||
locale : moment.locale(),
|
||||
allowInputToggle: true,
|
||||
keyBinds: null,
|
||||
widgetParent: 'body',
|
||||
useCurrent: false,
|
||||
});
|
||||
keyBinds: null,
|
||||
allowInputToggle: true,
|
||||
}, options || {});
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
start: function() {
|
||||
start: function () {
|
||||
this.$input = this.$('input.o_datepicker_input');
|
||||
this.$input.focus(function(e) {
|
||||
this.$input.focus(function (e) {
|
||||
e.stopImmediatePropagation();
|
||||
});
|
||||
this.__libInput = true;
|
||||
this.$input.datetimepicker(this.options);
|
||||
this.picker = this.$input.data('DateTimePicker');
|
||||
this.$input.click(this.picker.toggle.bind(this.picker));
|
||||
this.__libInput = false;
|
||||
this._setReadonly(false);
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
destroy: function() {
|
||||
this.picker.destroy();
|
||||
destroy: function () {
|
||||
this.__libInput = true;
|
||||
this.$input.datetimepicker('destroy');
|
||||
this.__libInput = false;
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
@@ -82,7 +87,7 @@ var DateWidget = Widget.extend({
|
||||
var hasChanged = !oldValue !== !newValue;
|
||||
if (oldValue && newValue) {
|
||||
var formattedOldValue = oldValue.format(time.getLangDatetimeFormat());
|
||||
var formattedNewValue = newValue.format(time.getLangDatetimeFormat())
|
||||
var formattedNewValue = newValue.format(time.getLangDatetimeFormat());
|
||||
if (formattedNewValue !== formattedOldValue) {
|
||||
hasChanged = true;
|
||||
}
|
||||
@@ -106,13 +111,13 @@ var DateWidget = Widget.extend({
|
||||
*/
|
||||
isValid: function () {
|
||||
var value = this.$input.val();
|
||||
if(value === "") {
|
||||
if (value === "") {
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
this._parseClient(value);
|
||||
return true;
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -124,9 +129,9 @@ var DateWidget = Widget.extend({
|
||||
this.set({'value': value});
|
||||
var formatted_value = value ? this._formatClient(value) : null;
|
||||
this.$input.val(formatted_value);
|
||||
if (this.picker) {
|
||||
this.picker.date(value || null);
|
||||
}
|
||||
this.__libInput = true;
|
||||
this.$input.datetimepicker('date', value || null);
|
||||
this.__libInput = false;
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -162,7 +167,7 @@ var DateWidget = Widget.extend({
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_setValueFromUi: function() {
|
||||
_setValueFromUi: function () {
|
||||
var value = this.$input.val() || false;
|
||||
this.setValue(this._parseClient(value));
|
||||
},
|
||||
@@ -171,6 +176,23 @@ var DateWidget = Widget.extend({
|
||||
// Handlers
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_onClick: function () {
|
||||
this.__libInput = true;
|
||||
this.$input.datetimepicker('toggle');
|
||||
this.__libInput = false;
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @param {Event} ev
|
||||
*/
|
||||
_onInput: function (ev) {
|
||||
if (this.__libInput) {
|
||||
ev.stopImmediatePropagation();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* set the date of the picker by the current date or the today date
|
||||
*
|
||||
@@ -179,9 +201,11 @@ var DateWidget = Widget.extend({
|
||||
_onShow: function () {
|
||||
//when opening datetimepicker the date and time by default should be the one from
|
||||
//the input field if any or the current day otherwise
|
||||
if(this.$input.val().length !== 0 && this.isValid()) {
|
||||
if (this.$input.val().length !== 0 && this.isValid()) {
|
||||
var value = this._parseClient(this.$input.val());
|
||||
this.picker.date(value);
|
||||
this.__libInput = true;
|
||||
this.$input.datetimepicker('date', value);
|
||||
this.__libInput = false;
|
||||
this.$input.select();
|
||||
}
|
||||
},
|
||||
@@ -189,11 +213,14 @@ var DateWidget = Widget.extend({
|
||||
|
||||
var DateTimeWidget = DateWidget.extend({
|
||||
type_of_date: "datetime",
|
||||
init: function() {
|
||||
this._super.apply(this, arguments);
|
||||
this.options = _.defaults(this.options, {
|
||||
showClose: true,
|
||||
});
|
||||
init: function (parent, options) {
|
||||
this._super(parent, _.extend({
|
||||
buttons: {
|
||||
showToday: false,
|
||||
showClear: false,
|
||||
showClose: true,
|
||||
},
|
||||
}, options || {}));
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -27,11 +27,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Need to put datetimepicker widget above everything else
|
||||
// The '.dropdown-menu' part is needed to override default bootstrap rule as
|
||||
|
||||
// The 'div.dropdown-menu' part is needed to override default bootstrap rule as
|
||||
// this file is unfortunately placed in common assets.
|
||||
.bootstrap-datetimepicker-widget.dropdown-menu {
|
||||
div.dropdown-menu.bootstrap-datetimepicker-widget{
|
||||
// Need to put datetimepicker widget above everything else
|
||||
z-index: $zindex-modal + 1;
|
||||
|
||||
// Also fix the dropdown width
|
||||
width: auto;
|
||||
min-width: 15rem;
|
||||
}
|
||||
|
||||
.datepicker {
|
||||
|
||||
@@ -2430,7 +2430,7 @@ QUnit.module('basic_fields', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('datetime field in form view', function (assert) {
|
||||
QUnit.test('datetime field in form view 2', function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
this.data.partner.fields.datetime.default = "2017-08-02 12:00:05";
|
||||
@@ -2449,8 +2449,7 @@ QUnit.module('basic_fields', {
|
||||
});
|
||||
testUtils.patch(basicFields.FieldDate, {
|
||||
_setValue: function () {
|
||||
throw "The time format of the language must be taken into account."
|
||||
return this._super.apply(this, arguments);
|
||||
throw "The time format of the language must be taken into account.";
|
||||
},
|
||||
});
|
||||
form.$buttons.find('.o_form_button_create').click();
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/web/static/lib/jquery.ui/jquery-ui.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="/web/static/lib/fontawesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" type="text/scss" href="/web/static/lib/bootstrap-datetimepicker/src/scss/_bootstrap-datetimepicker.scss"/>
|
||||
<link rel="stylesheet" type="text/css" href="/web/static/lib/select2/select2.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="/web/static/lib/select2-bootstrap-css/select2-bootstrap.css"/>
|
||||
|
||||
@@ -85,7 +84,7 @@
|
||||
<script type="text/javascript" src="/web/static/lib/bootstrap/js/scrollspy.js"></script>
|
||||
<script type="text/javascript" src="/web/static/lib/bootstrap/js/tab.js"></script>
|
||||
|
||||
<script type="text/javascript" src="/web/static/lib/bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js"></script>
|
||||
<script type="text/javascript" src="/web/static/lib/tempusdominus/tempusdominus.js"/>
|
||||
<script type="text/javascript" src="/web/static/lib/select2/select2.js"></script>
|
||||
<script type="text/javascript" src="/web/static/lib/clipboard/clipboard.js"></script>
|
||||
|
||||
@@ -130,6 +129,7 @@
|
||||
<t t-call="web._assets_backend_helpers"/>
|
||||
|
||||
<link rel="stylesheet" type="text/scss" href="/web/static/src/scss/import_bootstrap.scss"/>
|
||||
<link rel="stylesheet" type="text/scss" href="/web/static/lib/tempusdominus/tempusdominus.scss"/>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/base/static/src/css/modules.css"/>
|
||||
|
||||
@@ -296,6 +296,7 @@
|
||||
<t t-call="web._assets_frontend_helpers"/>
|
||||
|
||||
<link rel="stylesheet" type="text/scss" href="/web/static/src/scss/import_bootstrap.scss"/>
|
||||
<link rel="stylesheet" type="text/scss" href="/web/static/lib/tempusdominus/tempusdominus.scss"/>
|
||||
|
||||
<script type="text/javascript" src="/web/static/src/js/services/session.js"></script>
|
||||
</template>
|
||||
|
||||
@@ -15,7 +15,7 @@ odoo.define('website_form.animation', function (require) {
|
||||
willStart: function () {
|
||||
var def;
|
||||
if (!$.fn.datetimepicker) {
|
||||
def = ajax.loadJS("/web/static/lib/bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js");
|
||||
def = ajax.loadJS("/web/static/lib/tempusdominus/tempusdominus.js");
|
||||
}
|
||||
return $.when(this._super.apply(this, arguments), def);
|
||||
},
|
||||
|
||||
Vendored
+6
-6
@@ -47,7 +47,7 @@ Copyright: (C) 2011 Brandon Aaron (http://brandonaaron.net)
|
||||
License: MIT
|
||||
|
||||
Files: addons/web_diagram/static/lib/js/raphael.js
|
||||
Copyright: Copyright © 2008-2012 Dmitry Baranovskiy (http://raphaeljs.com)
|
||||
Copyright: Copyright © 2008-2012 Dmitry Baranovskiy (http://raphaeljs.com)
|
||||
Copyright © 2008-2012 Sencha Labs (http://sencha.com)
|
||||
License: MIT
|
||||
|
||||
@@ -67,8 +67,8 @@ Files: addons/web/static/lib/fuzzy-master/fuzzy.js
|
||||
Copyright: Copyright (c) 2012 Matt York
|
||||
License: MIT
|
||||
|
||||
Files: addons/web/static/lib/bootstrap-datetimepicker/*
|
||||
Copyright: Copyright (c) 2015 Jonathan Peterson
|
||||
Files: addons/web/static/lib/tempusdominus/*
|
||||
Copyright: Copyright (c) 2016 Jonathan Peterson
|
||||
License: MIT
|
||||
|
||||
Files: addons/web/static/lib/es5-shim/*
|
||||
@@ -167,7 +167,7 @@ Copyright: Copyright JS Foundation and other contributors <https://js.foundation
|
||||
License: MIT
|
||||
Comment: Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||
Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
|
||||
|
||||
Files: addons/web/static/lib/benchmarkjs/benchmark.js
|
||||
Copyright: Copyright 2010-2016 Mathias Bynens <https://mths.be/
|
||||
License: MIT
|
||||
@@ -261,7 +261,7 @@ License: OFL-1.1
|
||||
.
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
@@ -333,7 +333,7 @@ License: OFL-1.1
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
|
||||
License: LGPL-3
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
||||
Reference in New Issue
Block a user