Skip to content

Instantly share code, notes, and snippets.

@ChristianPeters
Created November 24, 2016 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChristianPeters/5d8fac692c927238099664088b8e21ac to your computer and use it in GitHub Desktop.
Save ChristianPeters/5d8fac692c927238099664088b8e21ac to your computer and use it in GitHub Desktop.
TargetProcess buttons to convert Iteration print view to documentation for contracts
$(function() {
addPerformModificationsButton = function(mode, showComplexity) {
var button;
button = $('<a class="button-box x-button user-action button small ui-print__controls__print" role="button"></a>');
var withComplexity;
withComplexity = showComplexity ? '(mit Komplexität) ' : '';
if (mode == 'planning') {
button.append('<span class="">Zu Planungsdokumentation ' + withComplexity + 'konvertieren</span>');
} else if (mode == 'review')
button.append('<span class="">Zu Abnahmedokumentation ' + withComplexity + 'konvertieren</span>');
$('body').prepend(button);
button.click(function() {
applyModifications(mode, showComplexity);
});
}
tableHeaderTemplate = function(showComplexity) {
var html;
html = '<th class="tau-list__table__cell-id">ID</th>';
html += '<th class="tau-list__table__cell-name">Titel</th>';
if (showComplexity)
html += '<th class="tau-list__table__cell-effort">Komplexität</th>';
return html;
}
applyModifications = function(mode, showComplexity) {
var effort;
effort = $('.ui-additionalinfo__value .effort').text();
effort = effort.replace(/pt/, 'SP');
effort = effort.replace('.', ',');
// Header
//-------
// Title
$('.tau-entity-icon--iteration').remove();
$('.view-header__wrap .entity-id').remove();
var title;
title = $('.view-header__entity-title');
if (mode == 'planning') {
document.title = 'Liste geplanter User Stories ' + title.text();
title.prepend('Geplante User Stories ');
} else if (mode == 'review') {
document.title = 'Liste abgenommener User Stories ' + title.text();
title.prepend('Abgenommene User Stories ');
}
// Follow Link
$('.view-header__link').remove();
// Iteration Description
$('.general-info .ui-label:contains("Description")').parent().parent().remove();
// Using or removing "User Stories"
var label;
label = $('.ui-label:contains("User Stories")');
if (showComplexity) {
// Converting "User Stories" to "Summe: 35,5 SP"
label.css('padding-bottom', 0);
label.css('font-size', '14px');
label.css('float', 'right');
label.css('margin-right', '4px');
label.text('Summe: ' + effort);
} else {
label.remove();
}
// Content
//--------
$('.tau-list__table__cell-dragdrop').remove();
$('.tau-list__table__row_isfinalstate_true .tau-list__table__cell-id').css('opacity', '1.0').css('color', 'black');
$('.tau-list__table__row_isfinalstate_true .tau-list__table__cell-name').css('opacity', '1.0').css('color', 'black');
$('.tau-list__content .tau-list__table').first().prepend(tableHeaderTemplate(showComplexity)); // NOTE: It's a list and each li has a table
$('.tau-list__table__cell-state').remove();
$('.tau-list__table__cell-priority').remove();
$('.tau-list__table__cell-assignments').remove();
if (showComplexity) {
$('.tau-list__table__cell-effort').css('width', '75px');
$('.tau-list__table__cell-effort').each(function() {
entryText = $(this).text();
entryText = entryText.replace(/pt/, ' SP');
entryText = entryText.replace('.', ',');
$(this).text(entryText);
});
} else {
$('.tau-list__table__cell-effort').remove();
}
$('.tau-list__table__cell-progress').remove();
$('.tau-action-link').removeClass('tau-action-link');
// Sidebar and buttons
//--------------------
$('.additional-info').remove();
$('.button').remove();
}
if(document.URL.match(/iteration\/\d*\/print/) || document.URL.match(/feature\/\d*\/print/) ) {
$(document).ready(function() {
// reversed order because of prepend
addPerformModificationsButton('review', true);
addPerformModificationsButton('review');
addPerformModificationsButton('planning', true);
addPerformModificationsButton('planning');
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment