* Refactor ui of testtask::result.

This commit is contained in:
liumengyi
2023-07-06 16:40:57 +08:00
parent 12d6fe0483
commit c97fc4a4f3
8 changed files with 491 additions and 5 deletions
+86
View File
@@ -64,3 +64,89 @@ function suitEndDate()
endDate = $.zui.formatDate(convertStringToDate(beginDate).addDays(1), 'yyyy-MM-dd');
$('#end').val(endDate);
}
/**
* Create bug from fail case.
*
* @param event $event
* @access public
* @return void
*/
function createBug(event)
{
var $form = $(event.target).closest('form');
var stepIdList = '';
$form.find('.step .step-id input[type="checkbox"]:checked').each(function()
{
if($(this).prop('checked')) stepIdList += $(this).val() + '_';
});
$form.attr('action', $.createLink('bug', 'create', bugCreateParams + ',stepIdList=' + stepIdList));
}
/**
* Toggle results show or hide.
*
* @param event $event
* @access public
* @return void
*/
function toggleShowResults(event)
{
var $target = $(event.target).closest('tr');
if($target.data('status') == 'running') return;
$target.toggleClass('show-detail');
var show = $target.hasClass('show-detail');
$target.next('.result-detail').toggleClass('hidden', !show);
$target.find('.collapse-handle').toggleClass('icon-angle-down', !show).toggleClass('icon-angle-top', show);;
}
/**
* Toggle check all.
*
* @param event $event
* @access public
* @return void
*/
function toggleCheckAll(event)
{
var $checkAll = $(event.target).closest('td').find("input[type='checkbox']");
var isChecked = !$checkAll.prop('checked');
$checkAll.prop('checked', isChecked);
$checkAll.closest('tbody').children('tr').find('input[type=checkbox]').prop('checked', isChecked);
}
/**
* Toggle child item check status.
*
* @param event $event
* @access public
* @return void
*/
function toggleCheckChildItem(event)
{
var $target = $(event.target).closest('td').find("input[type='checkbox']");
var isChecked = !$target.prop('checked');
$target.prop('checked', isChecked);
var $next = $target.closest('tr').next();
while($target.closest('tr').hasClass('step-group') && $next.length && $next.hasClass('step-item'))
{
$next.find("input[type='checkbox']").prop('checked', isChecked);
$next = $next.next();
}
if($target.closest('tr').hasClass('step-item'))
{
var parentStepKey = $target.closest('tr').data('parent');
var allSiblings = $target.closest('tbody').find('.step-item.group-' + parentStepKey).length
var checkedSiblings = $target.closest('tbody').find('.step-item.group-' + parentStepKey + ' input[type=checkbox]:checked').length
$target.closest('tr').prevAll('.step-group').first().find('input[type=checkbox]').prop('checked', allSiblings == checkedSiblings);
}
var $tbody = $target.closest('tbody');
$tbody.find('.check-all input[type=checkbox]').prop('checked', $tbody.find('.check-item input[type=checkbox]').length == $tbody.find('.check-item input[type=checkbox]:checked').length);
}
+34
View File
@@ -0,0 +1,34 @@
$(function()
{
if($('tr').length == 0) return false;
if($('tr').first().data('status') == 'ready')
{
$('tr').first().trigger('click');
}
else
{
var times = 0;
var id = $('tr').first().data('id')
var link = $.createLink('testtask', 'ajaxGetResult', 'resultID=' + id);
var resultInterval = setInterval(() => {
times++;
if(times > 600)
{
clearInterval(resultInterval);
}
$.get(link, function(task)
{
task = JSON.parse(task);
task = task.data;
if(task.ZTFResult != '')
{
clearInterval(resultInterval);
loadPage();
}
});
}, 1000);
}
});