Mashup for preventing users from editing time after a bug is closed

25 views
Skip to first unread message

Anthony S

unread,
Jul 19, 2016, 7:01:05 AM7/19/16
to DevTargetProcess
We are trying to write a mashup which prevents users from editing the hours on any closed entities (user stories, tasks, etc); the only way they would be able to change hours is if the bug is not closed (or more specifically, if the bug is not marked as "Done").

To do this, we have two plans:

1) Disable the 'plus' sign on a specific entity's "Time" tab page if the entity is marked as "Done"



2) Disable the popup that appears on the "Time Sheets" page when clicking on a cell if the entity is marked as "Done".



I've tried my hand at the first one, but it seems the page is rendering too quickly (i.e. before the frame containing time information is available). Essentially, if I let the page load normally and then test my code in something like Chrome's developer console, it works, the button becomes disabled. However, if I try to integrate it into a mashup, it fails, predictably because the elements I'm looking for do not exist (yet).

The mashup I've written thus far is as follows (it's a bit hacky in terms of jQuery, but I couldn't find a better way to get the elements I wanted):

tau.mashups
  .addDependency('libs/jquery/jquery')
  .addMashup(function($, config) {

      var plusButton = $('[id^=entitygeneralinfo] > div > div.tau-container.tau-tabs > div.entity-tabs.entity-tabs_more_enable > div > div > div > span');
      var itemStatus = $('[id^=entityadditionalinfo] > div > div > div.state-selector > div > div.ui-collapsible-header.i-role-panel-entity-select-header.collapsed > div > span.state-selector__current-state');
      if (!plusButton.length || !itemStatus.length) {
        return;
      }
     
      if(itemStatus.text() === "Done") {
        plusButton.css('pointer-events', 'none');
      }
     
  });

Any help is appreciated.

Auto Generated Inline Image 1
Auto Generated Inline Image 2

Jesse Rosenberg

unread,
Jul 20, 2016, 12:51:15 PM7/20/16
to DevTargetProcess
Did you try putting the code inside a document.ready?

If that doesn't work and since we are OK with hacks 😉 you could put the code in an interval that checks for the elements existence and then cancel the interval once the elements have appeared. I had to do a similar workaround for one of my mashups.
Reply all
Reply to author
Forward
0 new messages