diff --git a/addons/web_editor/static/src/less/web_editor.variables.less b/addons/web_editor/static/src/less/web_editor.variables.less index c735967af86..9cd72eabae0 100644 --- a/addons/web_editor/static/src/less/web_editor.variables.less +++ b/addons/web_editor/static/src/less/web_editor.variables.less @@ -155,6 +155,12 @@ border-radius: 0; } + .has-error { + .form-control { + border-color: @state-danger-text; + } + } + select.form-control { .o-appearance(none); background: url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPScxLjEnIHhtbG5zPSdodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZycgeG1 sbnM6eGxpbms9J2h0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsnIHdpZHRoPScyNCcgaGVpZ2 h0PScyNCcgdmlld0JveD0nMCAwIDI0IDI0Jz48cGF0aCBpZD0nc3ZnXzEnIGQ9J203LjQwNiw3L jgyOGw0LjU5NCw0LjU5NGw0LjU5NCwtNC41OTRsMC40MDYsMS40MDZsLTUsNC43NjZsLTUsLTQu NzY2bDAuNDA2LC0xLjQwNnonIGZpbGw9JyM4ODgnLz48L3N2Zz4='); diff --git a/addons/website/static/src/js/menu/content.js b/addons/website/static/src/js/menu/content.js index 2221eba4024..a4145c41241 100644 --- a/addons/website/static/src/js/menu/content.js +++ b/addons/website/static/src/js/menu/content.js @@ -147,7 +147,7 @@ var PagePropertiesDialog = widget.Dialog.extend({ }, }; if (self.page.date_publish) { - datepickersOptions.defaultDate = self.page.date_publish; + datepickersOptions.defaultDate = time.str_to_datetime(self.page.date_publish); } this.$("#date_publish_container").datetimepicker(datepickersOptions); @@ -174,9 +174,15 @@ var PagePropertiesDialog = widget.Dialog.extend({ var context = weContext.get(); var url = $(".o_page_management_info #page_url").val(); - var date_publish = $(".o_page_management_info #date_publish").val(); + var $date_publish = $(".o_page_management_info #date_publish"); + $date_publish.closest(".form-group").removeClass('has-error'); + var date_publish = $date_publish.val(); if (date_publish != "") { - date_publish = time.datetime_to_str(new Date(date_publish)); + date_publish = this._parse_date(date_publish); + if (!date_publish) { + $date_publish.closest(".form-group").addClass('has-error'); + return; + } } var params = { id: self.page.id, @@ -271,6 +277,28 @@ var PagePropertiesDialog = widget.Dialog.extend({ id: m[2] | 0, }; }, + /** + * Converts a string representing the browser datetime + * (exemple: Albanian: '2018-Qer-22 15.12.35.') + * to a string representing UTC in Odoo's datetime string format + * (exemple: '2018-04-22 13:12:35'). + * + * The time zone of the datetime string is assumed to be the one of the + * browser and it will be converted to UTC (standard for Odoo). + * + * @private + * @param {String} value A string representing a datetime. + * @returns {String|false} A string representing an UTC datetime if the given value is valid, false otherwise. + */ + _parse_date: function (value) { + var datetime = moment(value, time.getLangDatetimeFormat(), true); + if (datetime.isValid()) { + return time.datetime_to_str(datetime.toDate()); + } + else { + return false; + } + }, //-------------------------------------------------------------------------- // Handlers