Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
titleHide fields depending on project
// Enter your fieldnames here:
var firstItemName = 'OnCall';
var secondItemName = 'Remote';
var projectKey = 'ITSD';

// Don't change the code below this line
var tempoList = '.tempoStaticList';
var hideItemOne = '#popup_' + firstItemName + '_';
var hideItemTwo = '#popup_' + secondItemName + '_';

AJS.$(document).ready(function() {
    AJS.$('#time-popup').live('focus', function() {
        if (AJS.$('#tempo-issue-picker-popup').val()[0].indexOf(projectKey) == -1 || AJS.$('input[name="preSelectedIssue"]').val().indexOf(projectKey) == -1) {
            AJS.$(hideItemOne).parent().hide();
            AJS.$(hideItemTwo).parent().hide();
        }
    });
    AJS.$('#tempo-issue-picker-popup').live('change', function() {
        if (AJS.$('#tempo-issue-picker-popup').val()[0].indexOf(projectKey) == -1) {
            AJS.$(hideItemOne).parent().hide();
            AJS.$(hideItemTwo).parent().hide();
        } else {
            AJS.$(hideItemOne).parent().show();
            AJS.$(hideItemTwo).parent().show();
        }
    });
});

In newer Tempo Timesheets versions, you can use this script.

Code Block
// Enter your fieldnames here:
var firstItemName = 'OnCall';
var secondItemName = 'Remote';
var projectKey = 'ITSD';
 
// Don't change the code below this line
var hideItemOne = '#_' + firstItemName + '_';
var hideItemTwo = '#_' + secondItemName + '_';
 
AJS.$(document).ready(function() {
  setInterval(function() {
    if (AJS.$('#issuePickerInput').prev().prev().attr("name").indexOf(projectKey) == -1) {
      AJS.$(hideItemOne).parent().parent().hide();
      AJS.$(hideItemTwo).parent().parent().hide();
    } else {
      AJS.$(hideItemOne).parent().parent().show();
      AJS.$(hideItemTwo).parent().parent().hide();
    }
  }, 500);
});