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

Archana Singh archus at linux.vnet.ibm.com
Tue May 10 06:56:46 UTC 2016



On 5/10/2016 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());
>>>         }
>>
>> 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.

So I mean here that having formatter define at one place and using same 
across (where ever required), which makes it consistent.
Also there is no way to define formatter after bootgrid creation, it has 
to be define at time of bootgrid creation.

>
>
>>
>>>       },
>>>       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
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/kimchi-devel/attachments/20160510/383d2c9c/attachment.html>


More information about the Kimchi-devel mailing list