[Kimchi-devel] [Wok][PATCH v2 4/7] Multi-Culture support : Format datetime as per locale in wok.list.js

Aline Manera alinefm at linux.vnet.ibm.com
Tue May 10 15:10:07 UTC 2016



On 05/10/2016 12:07 PM, Archana Singh wrote:
>
>
> On 5/10/2016 7:13 PM, Aline Manera wrote:
>>
>>
>> On 05/10/2016 03:43 AM, Archana Singh wrote:
>>>
>>>
>>> On 5/9/2016 6:51 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 as per locale
>>>>> in wok-list widget.
>>>>>
>>>>> Signed-off-by: Pooja Kulkarni <pkulkark at linux.vnet.ibm.com>
>>>>> ---
>>>>>   ui/js/src/wok.list.js | 6 +++++-
>>>>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/ui/js/src/wok.list.js b/ui/js/src/wok.list.js
>>>>> index f40b2e2..8f02fde 100644
>>>>> --- a/ui/js/src/wok.list.js
>>>>> +++ b/ui/js/src/wok.list.js
>>>>> @@ -123,6 +123,10 @@ wok.widget.List.prototype = (function() {
>>>>>                   var checkboxName = $('ul', 
>>>>> container).parent().parent().parent().attr('id') + '-check' || 
>>>>> $(container).parent().parent().parent().attr('id') + '-check';
>>>>>                   $.each(fields, function(fi, field) {
>>>>>                       var value = getValue(field.name, row);
>>>>
>>>>> +                    if (field.name === 'time') {
>>>>> +                       var dte = new 
>>>>> Date(value.substr(0,10)+'T'+value.substr(11))
>>>>> +                       value = 
>>>>> dte.toLocaleString(wok.lang.get_locale())
>>>>> +
>>>>
>>>> wok.list.js is a generic widget, ie, it will only display the data 
>>>> in a given visual format. Any data logic should be done prior to it.
>>>> wok.list.js will not be aware about which data to do the 
>>>> conversion. Assuming the field will have a 'name' as 'time' is 
>>>> dangerous IMO. We can have different fields for datetime which does 
>>>> not have a name=time on it.
>>>
>>> I will propose to have check for type(type=='datetime') instead of 
>>> name(name=='time'). what do you think?
>>> And in debug report have the field type as datetime which has 
>>> datetime in it?
>>>
>>
>> The conversion must be done outside the widget. The widget should 
>> only receive a bunch of data to display in a visual way.
>
> I have tried adding converters define for list widget as below:
>
>
>
>
> And then use it as below in ui/js/src/gingerbase.host-dashboard.js
>
>
>
> ya the function used here for format can be moved to util.js.
>
> So you think  this is better approach?
>

yeap! i think we can go on that way and do similar for bootgrid.

>>
>>>>
>>>>>                      }
>>>>>                       if (field.type === 'status' && field.name 
>>>>> === 'enabled') {
>>>>>                           styleClass = (value === true ? '' : ' 
>>>>> disabled');
>>>>>                           state = [
>>>>> @@ -299,4 +303,4 @@ wok.widget.List.prototype = (function() {
>>>>>           reload: reload,
>>>>>           showMessage: showMessage
>>>>>       };
>>>>> -})();
>>>>> \ No newline at end of file
>>>>> +})();
>>>>
>>>> _______________________________________________
>>>> 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/a47a5001/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 152344 bytes
Desc: not available
URL: <http://lists.ovirt.org/pipermail/kimchi-devel/attachments/20160510/a47a5001/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 129400 bytes
Desc: not available
URL: <http://lists.ovirt.org/pipermail/kimchi-devel/attachments/20160510/a47a5001/attachment-0001.png>


More information about the Kimchi-devel mailing list