On 02/10/2011 05:19 PM, Endi Sukma Dewata wrote:
On 2/10/2011 3:51 PM, Adam Young wrote:


Should we use one of these functions?
http://www.w3schools.com/jsref/jsref_tostring_date.asp
http://www.w3schools.com/jsref/jsref_tolocalestring.asp
http://www.w3schools.com/jsref/jsref_toutcstring.asp

Our dates are not conisdered valid dates, so we can't just use them.

This version fixes whitespace and jsl issue
From b61688e8916bcb9118ca2fc8e640c234b347141c Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Thu, 10 Feb 2011 16:48:17 -0500
Subject: [PATCH 2/2] column formatting
 Allow optional formatting for columns
 Provide Data formate for host modificaiton

https://fedorahosted.org/freeipa/ticket/781
---
 install/ui/host.js   |   26 +++++++++++++++++++++++++-
 install/ui/widget.js |    8 ++++++++
 2 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/install/ui/host.js b/install/ui/host.js
index 86a5b820aeaaea9e6819444d27dc1d8142e4a097..9a84f77a0b923d8a804aff67d9b712a9d78ff502 100644
--- a/install/ui/host.js
+++ b/install/ui/host.js
@@ -115,7 +115,31 @@ IPA.host_search_facet = function (spec) {
         that.create_column({name:'fqdn'});
         that.create_column({name:'description'});
         //TODO use the value of this field to set enrollment status
-        that.create_column({name:'krblastpwdchange', label:'Enrolled?'});
+        that.create_column({name:'krblastpwdchange', label:'Enrolled?',
+                            format: function(value){
+                                if (value.length  != "20101119025910Z".length){
+                                    return value;
+                                }
+
+                                
+
+                                var formated = //" 2010-11-19, 02:59:10";
+                                value.substring(0, 4)+
+                                    '-' +
+                                    value.substring(4, 6) +
+                                    '-' +
+                                    value.substring(6, 8) +
+                                    ', ' +
+                                    value.substring(8, 10) +
+                                    ':' +
+                                    value.substring(10, 12) +
+                                    ':' +
+                                    value.substring(12, 14) +
+                                    ' ' +
+                                    value.substring(14, 15)
+                                return  formated;
+                            }
+                           });
         that.create_column({name:'nshostlocation'});
 
         that.search_facet_init();
diff --git a/install/ui/widget.js b/install/ui/widget.js
index ec5010bab62ea796fb45e5dfb5727e81168d042a..f1b584c140c9c8d538300c36ee908b9c744c56d3 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -1007,6 +1007,9 @@ IPA.column = function (spec) {
 
     var that = {};
 
+    if (spec.format){
+        that.format = spec.format;
+    }
     that.name = spec.name;
     that.label = spec.label;
     that.primary_key = spec.primary_key;
@@ -1027,8 +1030,13 @@ IPA.column = function (spec) {
         container.empty();
 
         var value = record[that.name];
+        if (that.format && value){
+            value = that.format(value);
+        }
+
         value = value ? value.toString() : '';
 
+
         container.append(value);
     }
 
-- 
1.7.3.5

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to