diff --git a/module/execution/css/storyestimate.ui.css b/module/execution/css/storyestimate.ui.css new file mode 100644 index 0000000000..837af60338 --- /dev/null +++ b/module/execution/css/storyestimate.ui.css @@ -0,0 +1,2 @@ +#storyEstimateTable input[disabled] {filter: none;} +#storyEstimateTable > * > tr {border-bottom-width: 0;} diff --git a/module/execution/js/storyestimate.ui.js b/module/execution/js/storyestimate.ui.js new file mode 100644 index 0000000000..33a7f054b3 --- /dev/null +++ b/module/execution/js/storyestimate.ui.js @@ -0,0 +1,28 @@ +window.updateAverage = function() +{ + const $estimates = $('.story-estimate'); + if($('.new-estimate').length > 0) $estimates = $('.new-estimate'); + + var summary = 0; + var count = 0; + var average = 0; + $estimates.each(function() + { + var value = $(this).val(); + if(value) + { + value = parseFloat(value); + if(isNaN(value)) value = 0; + summary += value; + count += 1; + } + }) + + if(count) average = summary / count; + $('#average').val(average.toFixed(2)); +} + +window.selectRound = function(loadUrl) +{ + loadModal(loadUrl.replace('%s', $('input[name="round"]').val()), 'current'); +} diff --git a/module/execution/ui/storyestimate.html.php b/module/execution/ui/storyestimate.html.php new file mode 100644 index 0000000000..e3e2f034a1 --- /dev/null +++ b/module/execution/ui/storyestimate.html.php @@ -0,0 +1,163 @@ + + * @package execution + * @link https://www.zentao.net + */ +namespace zin; + +modalHeader +( + set::title($lang->execution->storyEstimate), + set::entityText($story->title), + set::entityID($story->id) +); + +if(empty($team)) +{ + div + ( + setClass('h-60 flex items-center justify-center'), + p + ( + setClass('text-gray-400'), + span($lang->execution->noTeam) + ) + ); +} +else +{ + if(!empty($rounds)) + { + $loadUrl = inLink('storyEstimate', "executionID={$executionID}&storyID={$storyID}&round=%s"); + + div + ( + setClass('flex items-center ml-2'), + span($lang->execution->selectRound), + picker + ( + setClass('w-40 mx-3 my-1'), + set::name('round'), + set::items($rounds), + set::value($round), + set::required(true), + on::change("selectRound('{$loadUrl}')"), + ), + btn + ( + set::type('primary'), + on::click('$(".new-estimate, .form-actions > .btn").removeClass("hidden")'), + $lang->execution->reestimate + ) + ); + } + + $tableRows = array(); + foreach($team as $user) + { + $estimate = isset($estimateInfo->estimate->{$user->account}) ? $estimateInfo->estimate->{$user->account}->estimate : ''; + + $tableRows[] = h::tr + ( + h::td + ( + input + ( + setClass('form-control'), + set::value(zget($users, $user->account)), + set::disabled(true) + ), + input + ( + set::type('hidden'), + set::name('account[]'), + set::value($user->account) + ) + ), + h::td + ( + input + ( + setClass('form-control story-estimate'), + empty($estimateInfo->estimate) ? set::name('estimate[]') : null, + set::disabled(!empty($estimateInfo->estimate)), + set::value($estimate), + on::input('updateAverage()') + ), + ), + !empty($estimateInfo->estimate) ? h::td + ( + setClass('new-estimate hidden'), + input + ( + setClass('form-control'), + set::name('estimate[]'), + set::value($estimate), + on::input('updateAverage()') + ), + ) : null, + ); + } + + formBase + ( + h::table + ( + setID('storyEstimateTable'), + setClass('table condensed'), + h::tbody + ( + h::tr + ( + h::th($lang->execution->team), + h::th($lang->story->estimate), + !empty($estimateInfo->estimate) ? h::th(setClass('new-estimate hidden'), $lang->execution->newEstimate) : null + ), + $tableRows, + h::tr + ( + h::td + ( + input + ( + setClass('form-control text-primary'), + set::value($lang->execution->average), + set::disabled(true) + ) + ), + h::td + ( + input + ( + setClass('form-control text-primary'), + empty($estimateInfo->estimate) ? set::name('average') : null, + set::readonly(true), + set::value(!empty($estimateInfo->estimate) ? $estimateInfo->average : '') + ), + ), + !empty($estimateInfo->estimate) ? h::td + ( + setClass('new-estimate hidden'), + input + ( + set::name('average'), + setClass('form-control text-primary'), + set::readonly(true), + set::value($estimateInfo->average) + ), + ) : null, + ) + ) + ), + set::actions(array(array( + 'text' => $lang->save, + 'type' => empty($estimateInfo->estimate) ? 'primary' : 'primary hidden', + 'btnType' => 'submit', + ))) + ); +}