5

1

I'd like the case history text that is generated when I add a subcase to include a hyperlink to the subcase.

Example text:

Created subcase 1234.

Edit: it would also be really nice to have a link to the subcase included in any notification emails that are generated as a result of adding a subcase.

Fog Creek Case FC1853842

flag

3 Answers

5

Here's the BugMonkey script I created to achieve this functionality:

$("div.changes").each(function () {
  if ($(this).text().toLowerCase().indexOf("subcase") >= 0) {
    var words = $(this).text().split(' ');
    for (var i = 0; i < words.length; i++)
    {
      if (words[i].toLowerCase() == "subcase") {
        $(this).wrapInner('<a href="default.asp?' + words[i+1].replace('.','') + '"></a>');
        break;
      }
    }
  }
});
link|flag
2

A similar BugMonkey script that achieves the "link on the bugview page" part:

$("div.changes:contains(ase)").each(function(){
   $(this).html(
      $.map($(this).html().split(/<br.*?>/), function(sLine) {
         return /^((Added|Removed|Created) subcases?|Parent changed)/.test(sLine) ? 
                sLine.replace(
                   /(subcase |case |)(\d+)/gi, 
                   '<a href="?$2" onmouseover="b1($2,this)">$1$2</a>') :
                sLine;
      }).join("<br />")
   );
});

... it also handles the case where you've added/removed multiple subcases, and also provides a link when you change the parent case. (It also shows the case info popup when you hover over the subcase link)

link|flag
+1 Win! This is exactly what I was looking for. It's a shame I can't vote it up. :( – CADbloke May 18 2011 at 1:17
1

Mine's way shorter. I assume this means that I did something wrong ;)

Update: It links any "subcase xyz" or "case xyz" in changelines. Also added hover box

name:          Sub-case / parent-case changeline links
description:   Linkifies "added subcase xyz" or "parent case changed from case 123 to case 567" in bugevent change-lines
author:        Adam Wishneusky
version:       1.1.0.0

js:

$("div.bugevent > div.changes").each(function(index) {
    $(this).html($(this).html().replace(/((sub)?case) (\d+)/ig,"<a href=\"/?$3\" onmouseover=\"b1($3, this);\">$1 $3</a>"));
})
link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.