Mashup for Task Board doesn't get called when user changes

108 views
Skip to first unread message

Aliaksei Parasiatsyeu

unread,
May 21, 2012, 10:27:56 AM5/21/12
to DevTargetProcess, ni...@epayworldwide.com
I have written a mashup for the Task board, but when I change users
the mashup does not run. It looks like the board is updated via ajax
because the page does not post back. How do write my mashup in a way
that it get's called each time the board is updated? Is it even
possible?

Thanks!

the code:
tau.mashups
.addDependency('libs/jquery/jquery')
.addMashup(function ($, config) {
$('td.userStories.tau-target-box').each(function (i, el) {
var userStoryId = $(this).find('a.tau-entity-id.tau-target-
link').text();
var url = "/api/v1/UserStories/" + userStoryId.toString() +
"/?&format=json&append=[Bugs-Count,Tasks-Count]";

$.getJSON(url, function (data) {
$.each(data.CustomFields, function (i, v) {

if (v.Name == "Expected Completion Date" && v.Value !
= null) {
var date = new Date(parseInt(v.Value.substr(6)));

$(el).find('div:last').after("<div style='font-
size: 14px; color: red; line-height: 18px;'>Expected Completion Date:
" + date.format("m/d/y") + "</div>");

return false; // break loop
}

});

if (data['Tasks-Count'] == 0) {
$(el).css("background-color", "pink");
}

});

});

});

Vladimir Petriko

unread,
May 22, 2012, 4:40:47 AM5/22/12
to devtarge...@googlegroups.com, ni...@epayworldwide.com
Hi,

Task board is using UpdatePanel component thus you can use ASP.NET client-side API. In particular try to subscribe to PageRequestManager's "pageLoaded" event.

See the updated code below:

tau.mashups
 .addDependency('libs/jquery/jquery')
 .addMashup(function ($, config) {
   var fn = function() {
     $('td.userStories.tau-target-box').each(function (i, el) {
       var userStoryId = $(this).find('a.tau-entity-id.tau-target-link').text();
       var url = "/targetprocess/api/v1/UserStories/" + userStoryId.toString() + "/?&format=json&append=[Bugs-Count,Tasks-Count]";

       $.getJSON(url, function (data) {
         $.each(data.CustomFields, function (i, v) {
           if (v.Name == "Expected Completion Date" && v.Value != null) {
             var date = new Date(parseInt(v.Value.substr(6)));
             $(el).find('div:last')
                  .after("<div style='font-size: 14px; color: red; line-height: 18px;'>Expected Completion Date:" + date.format("m/d/y") + "</div>");
             return false; // break loop
           }
         });

         if (data['Tasks-Count'] == 0) {
           $(el).css("background-color", "pink");
         }
       });
     });
   };

   $(document).ready(fn);
   Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(fn);

});

Let us know if you have any other questions.

Best regards,
Vladimir
-------------------
TP Dev Team



2012/5/21 Aliaksei Parasiatsyeu <otry...@gmail.com>

Nick

unread,
May 22, 2012, 8:21:32 AM5/22/12
to DevTargetProcess
Thanks Vladimir. Your updates did the trick. The only thing I had to
change was the url for the rest API. I had to remove the '/
targetprocess' off the front of the concatenated string. Once I did
that everything worked as I expected it to.

Alex Fomin

unread,
May 22, 2012, 8:23:50 AM5/22/12
to devtarge...@googlegroups.com
It is better ti use :

url: appHostAndPath+'/api/v1/...

for urls -  appHostAndPath is a global variable containing path to TP.

Vladimir Petriko

unread,
May 22, 2012, 10:09:12 AM5/22/12
to devtarge...@googlegroups.com
You are welcome Nick! Thanks for your interest to TargetProcess mashups.

2012/5/22 Nick <j.nic...@gmail.com>
Reply all
Reply to author
Forward
0 new messages