Mashup Help

18 views
Skip to first unread message

Alan D

unread,
Dec 23, 2016, 11:02:09 AM12/23/16
to DevTargetProcess
I'm looking to add a mashup to the kanban board. I want to show the number of tasks a user is responsible for on a story. This way just by looking at a story the user can know they have something to do. Below is what I got to but I'm stuck here and not sure how to debug/move forward. Any help is appreciated. Thanks!

tau.mashups
.addDependency('jQuery')
.addDependency('Underscore')
.addDependency('tau/configurator')
.addDependency('tau/models/board.customize.units/const.entity.types.names')
.addDependency('tau/models/board.customize.units/const.card.sizes')
.addDependency('tau/models/board.customize.units/board.customize.units.base')
.addDependency('tau/models/board.customize.units/board.customize.units.interaction')
.addMashup(function ($, _, globalConfigurator, et, sz, helper, interactionUtils) {
    var openUnitEditor = interactionUtils.openUnitEditor.bind(interactionUtils);

    var sampleTasks = {
        tasks: [
            {
                id: 1,
                EntityState: {
                  Role: {
                    id: 1
                  }
                },
                Assignments: [
                  {
                    Role: {
                      id: 1
                    },
                    GeneralUser: {
                      id: 1
                    }
                  }
                ]
            },
            {
                id: 2,
                EntityState: {
                  Role: {
                    id: 1
                  }
                },
                Assignments: [
                  {
                    Role: {
                      id: 1
                    },
                    GeneralUser: {
                      id: 2
                    }
                  }
                ]
            }
        ],
        loggedInUserId: 1
    };

  function getCount(tasks, loggedInUser) {
      var countResponsible = 0;
      for (var i=0; i < data.tasks.length; i++) {
        var task = data.tasks[i];

        for (var j=0; j < task.Assignments.length; j++) {
          if (task.Assignments[j].Role.id == task.EntityState.Role.id) {
              if (loggedInUserId == task.Assignments[j].GeneralUser.Id) {
                countResponsible++;
              }
              break;
          }
        }
      }

      return countResponsible;
  }

  var units = [
      {
        id : 'custom_total_responsible_tasks',
        classId : 'tau-board-unit_type_total_responsible_tasks',
        name : 'Total Responsible Tasks',
        types : [et.STORY],
        sizes : [sz.XS, sz.S, sz.M, sz.L, sz.XL, sz.LIST],
        model : 'tasks:Tasks.Select({EntityState.Role.Id,Assignments.Select({Role.Id,GeneralUser.Id})}),loggedInUser:loggedUser.id',
        template: {
          customFunctions: {
            getCount: getCount
          },
          markup:[
            '<div class="tau-board-unit__value">',
            '<%= fn.getCount(this.data.tasks,this.data.loggedInUser) %>',
            '</div>'
          ]
        },
        sampleData : sampleTasks
    }
  ];

  function addUnits(configurator) {
    var registry = configurator.getUnitsRegistry();
    _.extend(registry.units, registry.register(units));
  }

  var appConfigurator;
  globalConfigurator.getGlobalBus().on('configurator.ready', function(e, configurator) {

      if (!appConfigurator && configurator._id && configurator._id.match(/board/)) {

          appConfigurator = configurator;
          addUnits(appConfigurator);

      }

  });

});



Alan D

unread,
Dec 23, 2016, 1:32:36 PM12/23/16
to DevTargetProcess
To update the issue seems to be with the loading of data. The kanban board shows stories and bugs. The error in the UI is "Invalid dataSelector." There are two api calls (both post requests) that are failing that return with this error:

http://ourtpinstance.com/slice/v1/matrix/cells

I also fixed the couple of variable bugs in the code above.

tsar...@targetprocess.com

unread,
Feb 20, 2017, 1:41:42 PM2/20/17
to DevTargetProcess
Sorry for late reply!
In case you still need the answer, try this:

tau.mashups
   
.addDependency('jQuery')
   
.addDependency('Underscore')
   
.addDependency('tau/configurator')
   
.addDependency('tau/models/board.customize.units/const.entity.types.names')
   
.addDependency('tau/models/board.customize.units/const.card.sizes')

   
.addMashup(function ($, _, globalConfigurator, et, sz) {
       
var sampleTasks = {
            myTasksCount
: 3
       
};

       
var template = function () {
           
return {

                markup
: [
                   
'<div class="tau-board-unit__value">',

                       
'Tasks #: <%= this.data.myTasksCount %>',
                   
'</div>'
               
]
           
};
       
};

       
var makeUnits = function (loggedUser) {
           
return [
               
{
                    id
: 'custom_total_responsible_tasks',
                    classId
: 'tau-board-unit_type_responsible-tasks',
                    hideIf
: function (data) {
                       
return !data.myTasksCount || data.myTasksCount === 0;
                   
},
                    name
: 'Total responsible tasks',

                    types
: [et.STORY],
                    sizes
: [sz.XS, sz.S, sz.M, sz.L, sz.XL, sz.LIST],

                    model
: 'myTasksCount:tasks.count(assigneduser.count(id==' + loggedUser.id + ')>0)',
                   
template : template(),
                    sampleData
: sampleTasks
               
}
           
];
       
};

       
var addUnits = function (configurator, loggedUser) {
           
var registry = configurator.getUnitsRegistry();
            _
.extend(registry.units, registry.register(makeUnits(loggedUser)));

       
};

       
var appConfigurator;
        globalConfigurator
.getGlobalBus().on('configurator.ready', function(e, configurator) {
           
if (!appConfigurator && configurator._id && configurator._id.match(/board/)) {
                appConfigurator
= configurator;


               
var loggedUser = appConfigurator.getLoggedUser();

                addUnits
(appConfigurator, loggedUser);
           
}
       
});
   
});

Reply all
Reply to author
Forward
0 new messages