Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display the amount of questionmarks in totals #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 50 additions & 35 deletions trelloscrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var debounce = function (func, threshold, execAsap) {
function delayed () {
if (!execAsap)
func.apply(obj, args);
timeout = null;
timeout = null;
};

if (timeout)
Expand Down Expand Up @@ -91,7 +91,7 @@ if(typeof chrome !== 'undefined'){
scrumLogoUrl = self.options.scrumLogoUrl;
scrumLogo18Url = self.options.scrumLogo18Url;
}

// FIREFOX_BEGIN_REMOVE (will just remove this closing bracket).
} // FIREFOX_END_REMOVE

Expand Down Expand Up @@ -177,13 +177,13 @@ var recalcTotalsObserver = new CrossBrowser.MutationObserver(function(mutations)
}
}
});

if(doFullRefresh){
recalcListAndTotal();
} else if(refreshJustTotals){
calcListPoints();
}

// There appears to be a change to have the card-title always be a textarea. We'll allow for either way, to
// start (in case this is A/B testing, or they don't keep it). 20160409
$editControls = $(".card-detail-title .edit-controls"); // old selector
Expand Down Expand Up @@ -253,7 +253,7 @@ function showBurndown()
var windowHeaderUtils = $('<div/>', {class: 'window-header-utils dialog-close-button'}).append( $('<a/>', {class: 'icon-lg icon-close dark-hover js-close-window', href: '#', title:'Close this dialog window.'}) );
var iFrameWrapper = $('<div/>', {style: 'padding:10px; padding-top: 13px;'});
var flameIcon = $('<img/>', {style: 'position:absolute; margin-left: 20px; margin-top:15px;', src:flame18Url});

var actualIFrame = $('<iframe/>', {frameborder: '0',
style: 'width: 670px; height: 512px;',
id: 'burndownFrame',
Expand All @@ -270,7 +270,7 @@ function showBurndown()
$('.window-header-utils a.js-close-window').click(hideBurndown);
//$(window).bind('resize', repositionBurndown);
$('.window-overlay').bind('click', hideBurndown);

//repositionBurndown();
}

Expand All @@ -290,15 +290,15 @@ function showSettings()
// Load the current settings (with defaults in case Settings haven't been set).
var setting_link = S4T_SETTINGS[SETTING_NAME_LINK_STYLE];
var setting_estimateSeq = S4T_SETTINGS[SETTING_NAME_ESTIMATES];

var settingsDiv = $('<div/>', {style: "padding:0px 10px;font-family:'Helvetica Neue', Arial, Helvetica, sans-serif;"});
var iframeHeader = $('<h3/>', {style: 'text-align: center;'});
iframeHeader.text('Scrum for Trello');
var settingsHeader = $('<h3/>', {style: 'text-align: center;margin-bottom:0px'});
settingsHeader.text('Settings');
var settingsInstructions = $('<div/>', {style: 'margin-bottom:10px'}).html('These settings affect how Scrum for Trello appears to <em>you</em> on all boards. When you&apos;re done, remember to click "Save Settings" below.');
var settingsForm = $('<form/>', {id: 'scrumForTrelloForm'});

// How the 'Burndown Chart' link should appear (if at all).
var fieldset_burndownLink = $('<fieldset/>');
var legend_burndownLink = $('<legend/>');
Expand Down Expand Up @@ -328,19 +328,19 @@ function showSettings()
var label_none = $('<label/>', {for: 'link_none'});
label_none.text('Disable completely');
fieldset_burndownLink.append(burndownRadio_none).append(label_none).append("<br/>");

// Which estimate buttons should show up.
var fieldset_estimateButtons = $('<fieldset/>', {style: 'margin-top:5px'});
var legend_estimateButtons = $('<legend/>');
legend_estimateButtons.text("Estimate Buttons");
fieldset_estimateButtons.append(legend_estimateButtons);
var explanation = $('<div/>').text("List out the values you want to appear on the estimate buttons, separated by commas. They can be whole numbers, decimals, or a question mark.");
fieldset_estimateButtons.append(explanation);

var estimateFieldId = 'pointSequenceToUse';
var estimateField = $('<input/>', {id: estimateFieldId, size: 40, val: setting_estimateSeq});
fieldset_estimateButtons.append(estimateField);

var titleTextStr = "Original sequence is: " + _pointSeq.join();
var restoreDefaultsButton = $('<button/>')
.text('restore to original values')
Expand Down Expand Up @@ -375,7 +375,7 @@ function showSettings()
settingsForm.append(saveButton);
settingsForm.append(savedIndicator);
}

// Quick start instructions.
var quickStartDiv = $('<div>\
<h4 style="margin-top:0px;margin-bottom:0px">Getting started</h4>\
Expand Down Expand Up @@ -413,7 +413,7 @@ function showSettings()
iframeObj.contents().find('body').append(settingsDiv);
});
iframeObj.attr('src', "about:blank"); // need to set this AFTER the .load() has been registered.

$('.window-header-utils a.js-close-window').click(hideBurndown);
//$(window).bind('resize', repositionBurndown);
$('.window-overlay').bind('click', hideBurndown);
Expand Down Expand Up @@ -457,18 +457,26 @@ function computeTotal(){
var $total = $title.children('.list-total').empty();
if ($total.length == 0)
$total = $('<span/>', {class: "list-total"}).appendTo($title);

for (var i in _pointsAttr){
var score = 0,
attr = _pointsAttr[i];
$('#board .list-total .'+attr).each(function(){
score+=parseFloat(this.textContent)||0;
});
var scoreSpan = $('<span/>', {class: attr}).text(round(score)||'');
$total.append(scoreSpan);
}

updateBurndownLink(); // the burndown link and the total are on the same bar... so now they'll be in sync as to whether they're both there or not.
var attr = _pointsAttr[i],
score = 0,
qm = 0;
$('#board .list-total .'+attr).each(function(){
var split = this.textContent.split(' + ');
if(split.length > 1) {
qm += parseFloat(split[1].replace('?',''));
}
score += parseFloat(split[0]) || 0;
});
score = round(score);
if(qm > 0) {
score += ' + '+qm+'?';
}
var scoreSpan = $('<span/>', {class: attr}).text(score!=0?score:'');
$total.append(scoreSpan);
}

updateBurndownLink(); // the burndown link and the total are on the same bar... so now they'll be in sync as to whether they're both there or not.
});
};

Expand Down Expand Up @@ -520,7 +528,8 @@ function List(el){
$total.empty().appendTo($list.find('.list-title,.list-header'));
for (var i in _pointsAttr){
var score=0,
attr = _pointsAttr[i];
attr = _pointsAttr[i],
qm = 0;
$list.find('.list-card:not(.placeholder)').each(function(){
if(!this.listCard) return;
if(!isNaN(Number(this.listCard[attr].points))){
Expand All @@ -529,15 +538,21 @@ function List(el){
score+=Number(this.listCard[attr].points);
}
}
else if(this.listCard[attr].points == '?') {
qm++;
}
});
var scoreTruncated = round(score);
var scoreSpan = $('<span/>', {class: attr}).text( (scoreTruncated>0) ? scoreTruncated : '' );
score = round(score);
if(qm > 0) {
score += ' + '+qm+'?';
}
var scoreSpan = $('<span/>', {class: attr}).text(score!=0?score:'');
$total.append(scoreSpan);
computeTotal();
}
});
};

this.refreshList = debounce(function(){
readCard($list.find('.list-card:not(.placeholder)'));
this.calc(); // readCard will call this.calc() if any of the cards get refreshed.
Expand All @@ -550,7 +565,7 @@ function List(el){
// infinite recursion).
$.each(mutations, function(index, mutation){
var $target = $(mutation.target);

// Ignore a bunch of known elements that send mutation events.
if(! ($target.hasClass('list-total')
|| $target.hasClass('list-title')
Expand Down Expand Up @@ -622,9 +637,9 @@ function ListCard(el, identifier){
// This expression gets the right value whether Trello has the card-number span in the DOM or not (they recently removed it and added it back).
var titleTextContent = (($title[0].childNodes.length > 1) ? $title[0].childNodes[$title[0].childNodes.length-1].textContent : $title[0].textContent);
if(titleTextContent) el._title = titleTextContent;

// Get the stripped-down (parsed) version without the estimates, that was stored after the last change.
var parsedTitle = $title.data('parsed-title');
var parsedTitle = $title.data('parsed-title');

if(titleTextContent != parsedTitle){
// New card title, so we have to parse this new info to find the new amount of points.
Expand Down Expand Up @@ -710,7 +725,7 @@ function ListCard(el, identifier){
//the story point picker
function showPointPicker(location) {
if($(location).find('.picker').length) return;

// Try to allow this to work with old card style (with save button) or new style (where title is always a textarea).
var $elementToAddPickerTo = $('.card-detail-title .edit-controls');
if($elementToAddPickerTo.length == 0){
Expand All @@ -719,7 +734,7 @@ function showPointPicker(location) {

var $picker = $('<div/>', {class: "picker"}).appendTo($elementToAddPickerTo.get(0));
$picker.append($('<span>', {class: "picker-title"}).text("Estimated Points"));

var estimateSequence = (S4T_SETTINGS[SETTING_NAME_ESTIMATES].replace(/ /g, '')).split(',');
for (var i in estimateSequence) $picker.append($('<span>', {class: "point-value"}).text(estimateSequence[i]).click(function(){
var value = $(this).text();
Expand All @@ -740,7 +755,7 @@ function showPointPicker(location) {

return false;
}));

if($(location).find('.picker-consumed').length) return;
var $pickerConsumed = $('<div/>', {class: "picker-consumed"}).appendTo($elementToAddPickerTo.get(0));
$pickerConsumed.append($('<span>', {class: "picker-title"}).text("Consumed Points"));
Expand Down Expand Up @@ -914,7 +929,7 @@ function refreshSettings(){
function onSettingsUpdated(){
// Temporary indication to the user that the settings were saved (might not always be on screen, but that's not a problem).
$('#'+settingsFrameId).contents().find('#s4tSaved').show().fadeOut(2000, "linear");

// Refresh the links because link-settings may have changed.
$('.s4tLink').remove();
updateBurndownLink();
Expand Down