Revision: a30c74a08539
Author:   Janne Härkönen <[email protected]>
Date:     Tue Jun 21 01:25:23 2011
Log:      handle parent name formatting with a function
http://code.google.com/p/robotframework/source/detail?r=a30c74a08539

Modified:
 /src/robot/webcontent/model.js
 /src/robot/webcontent/report.html
 /src/robot/webcontent/util.js
 /utest/webcontent/spec/StatisticsSpec.js

=======================================
--- /src/robot/webcontent/model.js      Tue Jun 21 00:56:46 2011
+++ /src/robot/webcontent/model.js      Tue Jun 21 01:25:23 2011
@@ -121,10 +121,8 @@

     function Test(data) {
         var test = createModelObject(data);
- test.fullName = data.parent.fullName + "." + test.name; // TODO: is this used?, could be function also
-        test.parentName = function () {
- return data.parent.fullName.replace(/\./g, ' . ') + ' . '; // TODO: duplicate
-        };
+        test.fullName = data.parent.fullName + "." + test.name;
+ test.formatParentName = function () { return util.formatParentName(test); };
         test.timeout = data.timeout;
         test.populateKeywords = createIterablePopulator("Keyword");
         test.children = function () {
@@ -313,8 +311,8 @@

     function suiteStatElem(data) {
         var stat = statElem(data);
- stat.parentName = stat.label.slice(0, stat.label.length-stat.name.length);
-        stat.parentName = stat.parentName.replace(/\./g, ' . ');
+        stat.fullName = stat.label;
+ stat.formatParentName = function () { return util.formatParentName(stat); };
         // compatibility with RF 2.5 outputs
         if (!stat.name)
             stat.name = stat.label.split('.').pop();
=======================================
--- /src/robot/webcontent/report.html   Tue Jun 21 00:56:46 2011
+++ /src/robot/webcontent/report.html   Tue Jun 21 01:25:23 2011
@@ -330,7 +330,7 @@
   <tr>
     <td class="col_stat_name">
       <div class="stat_name">
- <a href="#suite_${label}" onclick="suiteDetailSelected('${label}');" title="${label}"><span class="parent_name">${parentName}</span>${name}</a> + <a href="#suite_${label}" onclick="suiteDetailSelected('${label}');" title="${label}"><span class="parent_name">${formatParentName}</span>${name}</a>
       </div>
     </td>
     {{tmpl($data) 'stat_columns'}}
@@ -477,9 +477,9 @@
 <script type="text/x-jquery-tmpl" id="testDetailsTableRowTemplate">
   <tr class="test_row">
     {{if $item.logURL}}
- <td class="col_name"><a href="${$item.logURL}#test_${fullName}" id="test_${fullName}" title="${fullName}"><span class="parent_name">${parentName}</span>${name}</a></td> + <td class="col_name"><a href="${$item.logURL}#test_${fullName}" id="test_${fullName}" title="${fullName}"><span class="parent_name">${formatParentName}</span>${name}</a></td>
     {{else}}
- <td class="col_name"><span class="parent_name">${parentName}</span>${name}</td> + <td class="col_name"><span class="parent_name">${formatParentName}</span>${name}</td>
     {{/if}}
     <td class="col_doc">{{html doc}}</td>
     <td class="col_tags">${tags.join(', ')}</td>
=======================================
--- /src/robot/webcontent/util.js       Thu Jun 16 02:18:37 2011
+++ /src/robot/webcontent/util.js       Tue Jun 21 01:25:23 2011
@@ -57,6 +57,11 @@
             matches: function (string) { return regexp.test(string); }
         }
     }
+
+    function formatParentName(item) {
+ var parentName = item.fullName.slice(0, item.fullName.length - item.name.length);
+        return parentName.replace(/\./g, ' . ');
+    }

     function createGeneratedAgoString(generatedAgoMillis) {
         function timeString(time, shortUnit) {
@@ -105,6 +110,7 @@
         contains: contains,
         normalize: normalize,
         Matcher: Matcher,
+        formatParentName: formatParentName,
         createGeneratedAgoString: createGeneratedAgoString
     };
 }();
=======================================
--- /utest/webcontent/spec/StatisticsSpec.js    Tue Jun 21 00:48:43 2011
+++ /utest/webcontent/spec/StatisticsSpec.js    Tue Jun 21 01:25:23 2011
@@ -44,7 +44,7 @@

     function verifySuiteStatNames(stat, name, parentName) {
         expect(stat.name).toEqual(name);
-        expect(stat.parentName).toEqual(parentName);
+        expect(stat.formatParentName()).toEqual(parentName);
     }

     it("should contain critical stats", function () {

Reply via email to