[Kimchi-devel] [Wok][PATCH v2 7/7] Multi-Culture support : Format datetime in user activity log as per locale

Aline Manera alinefm at linux.vnet.ibm.com
Tue May 10 13:50:33 UTC 2016



On 05/10/2016 04:01 AM, Chandra Shekhar Reddy Potula wrote:
>
>
> On 5/10/16 11:06 AM, Archana Singh wrote:
>>
>>
>> On 5/9/2016 6:55 PM, Aline Manera wrote:
>>>
>>>
>>> On 05/05/2016 04:02 AM, pkulkark at linux.vnet.ibm.com wrote:
>>>> From: Pooja Kulkarni <pkulkark at linux.vnet.ibm.com>
>>>>
>>>> co-authored by: Archana Singh <archus at linux.vnet.ibm.com>
>>>>
>>>> v2:
>>>> Modified call to fetch locale
>>>>
>>>> v1:
>>>> This patch formats the datetime fields
>>>> in user activity log as per locale by
>>>> using suitable formatters.
>>>>
>>>> Signed-off-by: Pooja Kulkarni <pkulkark at linux.vnet.ibm.com>
>>>> ---
>>>>   ui/js/wok.bootgrid.js | 10 +++++++++-
>>>>   ui/js/wok.user-log.js |  3 ++-
>>>>   2 files changed, 11 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/ui/js/wok.bootgrid.js b/ui/js/wok.bootgrid.js
>>>> index 1312fe5..e3b0b16 100644
>>>> --- a/ui/js/wok.bootgrid.js
>>>> +++ b/ui/js/wok.bootgrid.js
>>>> @@ -72,6 +72,14 @@ wok.createBootgrid = function(opts) {
>>>>         },
>>>>         "settings-user-log-message": function(column, row) {
>>>>           return '<span class="trim" data-toggle="tooltip" 
>>>> data-placement="auto bottom" title="'+row.message+'">' 
>>>> +row.message+ '</span> ';
>>>> +      },

>>>> +      "settings-user-log-date": function(column, row) {
>>>> +        var dte = new Date(row.date);
>>>> +        return dte.toLocaleDateString(wok.lang.get_locale());
>>>> +      },
>>>> +      "settings-user-log-time": function(column, row) {
>>>> +        var dte = new Date(row.date);
>>>> +        return dte.toLocaleTimeString(wok.lang.get_locale());
>>>>         }
>>>

Look at this code!
You are adding specific configuration from a Wok page into a common 
widget! It will not be accepted!

Any conversion must be done prior to call the widget creation. The 
widget does not know which data to convert, it only displays the data 
into a visual format.

>>> The same I commented about wok.list.js.
>>> wok.bootgrid.js is a generic widget which only display data in a 
>>> visual format. It should not deal with data formatting, instead of 
>>> that it should only receive the data to be displayed.
>>
>> The data from backend if return and should be shown in UI depending 
>> upon the locale selected in UI by user while login.
>> I agree that this is common widget and hence the format has to be 
>> done at common place to ensure that data & time are formatted as per 
>> locale selected by user in common way(thinking of plugin using this 
>> widget).
>> So I think having common formatter will help us keeping the format 
>> consistent across plugins also.
>>
>>
> I will not agree with your opinion that bootgrid should display only 
> the data in a visual form as it is. Bootgrid documentation clearly 
> says " Formatters are perfect to manipulate the visualization of data 
> cells."
>
> http://www.jquery-bootgrid.com/documentation
>
> And in any means this is kind of not enforcement to all the fields. 
> Field which has some formatting requirements can use the right 
> formatter defined in the generic implementation.
>>>
>>>>       },
>>>>       css: {
>>>> @@ -138,4 +146,4 @@ wok.showBootgridData = function(opts) {
>>>>
>>>>   wok.hideBootgridData = function(opts) {
>>>>     $("#" + opts['gridId'] + " tbody").hide();
>>>> -};
>>>> \ No newline at end of file
>>>> +};
>>>> diff --git a/ui/js/wok.user-log.js b/ui/js/wok.user-log.js
>>>> index 8c2b4a7..1bdbd31 100644
>>>> --- a/ui/js/wok.user-log.js
>>>> +++ b/ui/js/wok.user-log.js
>>>> @@ -94,6 +94,7 @@ wok.listUserLogConfig = function() {
>>>>         "title": i18n['WOKSETT0004M']
>>>>       }, {
>>>>         "column-id": 'time',
>>>
>>>> +      "formatter": "settings-user-log-time",
>>>>         "converter": 'string',
>>>
>>> The data conversion should be done here and only pass the right data 
>>> to the displayed on UI to wok.bootgrid.js
>> Same as above, I think using common formatter define above keep 
>> formatting consistent across.
>>>
>>>>         "order": 'desc',
>>>>         "title": i18n['WOKSETT0005M']
>>>> @@ -243,4 +244,4 @@ wok.initUserLogWindow = function() {
>>>>         });
>>>>         $('#form-advanced-search').submit();
>>>>     });
>>>> -};
>>>> \ No newline at end of file
>>>> +};
>>>
>>> _______________________________________________
>>> Kimchi-devel mailing list
>>> Kimchi-devel at ovirt.org
>>> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>>>
>>
>> _______________________________________________
>> Kimchi-devel mailing list
>> Kimchi-devel at ovirt.org
>> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>>
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>




More information about the Kimchi-devel mailing list