Skip to content
New issue

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

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

Already on GitHub? # to your account

Add point picker for consumed/actual points #52

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion trelloscrum.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
padding-top: 5px;
}

.consumed.picker {
padding-top: 0;
}

.points-done-icon{
background-position: 0px 3px !important;
background-repeat: no-repeat !important;
Expand All @@ -65,6 +69,6 @@
display: none;
}

.badge-points.consumed{
.badge-points.consumed, .consumed .point-value{
opacity: 0.5;
}
39 changes: 31 additions & 8 deletions trelloscrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
** Samuel Gaus <https://github.com/gausie>
**
*/
/*global chrome */
/*jshint browser: true, jquery:true */

//default story point picker sequence
var _pointSeq = ['?', 0, .5, 1, 2, 3, 5, 8, 13, 21];
Expand Down Expand Up @@ -196,23 +198,44 @@ function ListCard(el, identifier){

//the story point picker
function showPointPicker() {
var i;
if($(this).find('.picker').length) return;
var $picker = $('<div class="picker">').appendTo('.card-detail-title .edit-controls');
for (var i in _pointSeq) $picker.append($('<span class="point-value">').text(_pointSeq[i]).click(function(){
var value = $(this).text();

var $controls = $('.card-detail-title .edit-controls');

var $estimated = $('<div class="picker first-picker"><span class="quiet">Estimated </span>').appendTo($controls);
for (i in _pointSeq) $estimated.append(createPointButton(_pointSeq[i], false));
var $consumed = $('<div class="consumed picker"><span class="quiet">Consumed </span>').appendTo($controls);
for (i in _pointSeq) $consumed.append(createPointButton(_pointSeq[i], true));
}

function createPointButton(points, isConsumed) {
var regex, value;
if (isConsumed) {
regex = regC;
value = ' [' + points + ']';
} else {
regex = reg;
value = '(' + points + ') ';
}

return $('<span class="point-value">').text(points).click(function(){
var $text = $('.card-detail-title .edit textarea');
var text = $text.val();

// replace our new
$text[0].value=text.match(reg)?text.replace(reg, '('+value+') '):'('+value+') ' + text;
if (text.match(regex)) {
$text[0].value = text.replace(regex, value);
} else {
$text[0].value = isConsumed ? text + value : value + text;
}

// then click our button so it all gets saved away
$(".card-detail-title .edit .js-save-edit").click();

return false
}))
};

return false;
});
}

//for export
var $excel_btn,$excel_dl;
Expand Down