changeset 58244352f6cf in sao:6.4
details: https://hg.tryton.org/sao?cmd=changeset&node=58244352f6cf
description:
        Use local date format as default and use context date format as fallback

        issue11728
        review427801003
        (grafted from 9f95f2077dad49a75c7039805537487f37381787)
diffstat:

 src/common.js    |   2 +-
 src/view/form.js |  11 +++++------
 2 files changed, 6 insertions(+), 7 deletions(-)

diffs (66 lines):

diff -r f17bdc95a7a0 -r 58244352f6cf src/common.js
--- a/src/common.js     Thu Sep 15 21:36:56 2022 +0200
+++ b/src/common.js     Sat Oct 01 14:15:05 2022 +0200
@@ -223,7 +223,7 @@
 
     Sao.common.date_format = function(format) {
         if (jQuery.isEmptyObject(format)) {
-            format = '%Y-%m-%d';
+            format = '%x';
             if (Sao.Session.current_session) {
                 var context = Sao.Session.current_session.context;
                 if (context.locale && context.locale.date) {
diff -r f17bdc95a7a0 -r 58244352f6cf src/view/form.js
--- a/src/view/form.js  Thu Sep 15 21:36:56 2022 +0200
+++ b/src/view/form.js  Sat Oct 01 14:15:05 2022 +0200
@@ -1655,7 +1655,6 @@
         _input_format: '%Y-%m-%d',
         _format: Sao.common.format_date,
         _parse: Sao.common.parse_date,
-        _default_format: '%x',
         init: function(view, attributes) {
             Sao.View.Form.Date._super.init.call(this, view, attributes);
             this.el = jQuery('<div/>', {
@@ -1736,7 +1735,8 @@
             if (this.field && this.record) {
                 return this.field.date_format(this.record);
             } else {
-                return this._default_format;
+                return Sao.common.date_format(
+                    this.view.screen.context.date_format);
             }
         },
         get_value: function() {
@@ -1793,13 +1793,13 @@
         _input_format: '%Y-%m-%dT%H:%M:%S',
         _format: Sao.common.format_datetime,
         _parse: Sao.common.parse_datetime,
-        _default_format: '%x %X',
         get_format: function() {
             if (this.field && this.record) {
                 return (this.field.date_format(this.record) + ' ' +
                     this.field.time_format(this.record));
             } else {
-                return this._default_format;
+                return (Sao.common.date_format(
+                    this.view.screen.context.date_format) + ' %X');
             }
         },
         cast: function(value){
@@ -1814,7 +1814,6 @@
         _input_format: '%H:%M:%S',
         _format: Sao.common.format_time,
         _parse: Sao.common.parse_time,
-        _default_format: '%X',
         init: function(view, attributes) {
             Sao.View.Form.Time._super.init.call(this, view, attributes);
             if (~navigator.userAgent.indexOf("Firefox")) {
@@ -1826,7 +1825,7 @@
             if (this.field && this.record) {
                 return this.field.time_format(this.record);
             } else {
-                return this._default_format;
+                return '%X';
             }
         },
         cast: function(value){

Reply via email to