From fbef44671a281d6bcf774fe8f070cf69bd72b7d2 Mon Sep 17 00:00:00 2001 From: wangyuting Date: Mon, 26 Jun 2023 13:18:20 +0800 Subject: [PATCH] * Finish bug create page. --- module/bug/js/common.ui.js | 96 +++++++++++++++++++- module/bug/js/create.ui.js | 18 ++++ module/bug/lang/de.php | 3 +- module/bug/lang/en.php | 3 +- module/bug/lang/fr.php | 3 +- module/bug/lang/vi.php | 3 +- module/bug/lang/zh-cn.php | 3 +- module/bug/ui/create.html.php | 165 +++++++++++++++++++++++----------- module/bug/ui/edit.html.php | 6 +- module/bug/zen.php | 1 + module/tree/control.php | 2 +- 11 files changed, 236 insertions(+), 67 deletions(-) diff --git a/module/bug/js/common.ui.js b/module/bug/js/common.ui.js index 37b6f96084..6f8da321b8 100644 --- a/module/bug/js/common.ui.js +++ b/module/bug/js/common.ui.js @@ -99,12 +99,46 @@ function changeModule(event) loadProductStories(productID, storyID, executionID, moduleID); } -function clickRefresh(event) +function changeRegion(event) +{ + const regionID = $(event.target).val(); + const url = $.createLink('kanban', 'ajaxGetLanes', 'regionID=' + regionID + '&type=bug&field=lane'); + $.get(url, function(lane) + { + if(!lane) lane = ""; + $('#lane').replaceWith(lane); + }); +} + +function changeContact(event) +{ + const contactID = $(event.target).val(); + setMailto(contactID); +} + +function refreshModule(event) { const productID = $('#product').val(); loadProductModules(productID); } +function refreshContact(event) +{ + loadContacts(); +} + +function refreshProductBuild(event) +{ + const productID = $('#product').val(); + loadProductBuilds(productID); +} + +function refreshExecutionBuild(event) +{ + const executionID = $('#execution').val(); + loadExecutionBuilds(executionID); +} + function loadProductBranches(productID) { $('#branch').remove(); @@ -295,6 +329,7 @@ function loadProductBuilds(productID, type = 'normal', buildBox = 'all') $.get(link, function(data) { $('#openedBuild').replaceWith(data); + loadBuildActions(); }) } } @@ -328,6 +363,7 @@ function loadExecutionBuilds(executionID, num) let branch = $('#branch' + num).val(); let productID = $('#product' + num).val(); const oldOpenedBuild = $('#openedBuild' + num).val() ? $('#openedBuild' + num).val() : 0; + if(typeof(branch) == 'undefined') branch = 0; if(typeof(productID) == 'undefined') productID = 0; @@ -338,6 +374,7 @@ function loadExecutionBuilds(executionID, num) { $('#openedBuild').replaceWith(data); $('#openedBuild').val(oldOpenedBuild); + loadBuildActions(); }) } else @@ -558,3 +595,60 @@ function setBranchRelated(event) $.ajaxSettings.async = true; } } + +function loadBuildActions() +{ + if(config.currentMethod == 'edit') return; + $('#buildBoxActions').empty().hide(); + let itemCount = $('#openedBuild').find('option').length; + if($('#openedBuild').attr('data-items') != undefined) itemCount = $('#openedBuild').attr('data-items'); + if(itemCount <= 1) + { + let html = ''; + if($('#execution').length == 0 || $('#execution').val() == 0) + { + let branch = $('#branch').val(); + let projectID = $('#project').val(); + + if(typeof(branch) == 'undefined') branch = 0; + if(typeof(projectID) == 'undefined') projectID = 0; + + let link = $.createLink('release', 'create', 'productID=' + $('#product').val() + '&branch=' + branch); + if(projectID > 0) link = $.createLink('projectrelease', 'create', 'projectID=' + projectID); + + html += '' + createRelease + ' '; + html += '' + refresh + ''; + } + else + { + const executionID = $('#execution').val(); + const productID = $('#product').val(); + const projectID = $('#project').val(); + let link = $.createLink('build', 'create','executionID=' + executionID + '&productID=' + productID + '&projectID=' + projectID); + link += link.indexOf('?') >= 0 ? '&onlybody=yes' : '?onlybody=yes'; + html += '' + createBuild + ' '; + html += '' + refresh + ''; + } + $('#buildBoxActions').html(html).show(); + } +} + +function loadContacts() +{ + const link = $.createLink('user', 'ajaxGetContactList', 'dropdownName=mailto'); + $.get(link, function(contacts) + { + if(!contacts) return false; + $('#contactBox').html(contacts) + }); +} + +function setMailto(contactID) +{ + const oldUsers = $('#mailto').val(); + const link = $.createLink('user', 'ajaxGetContactUsers', 'listID=' + contactID + '&dropdownName=mailto&oldUsers=' + oldUsers); + $.get(link, function(users) + { + $('#mailto').replaceWith(users); + }); +} diff --git a/module/bug/js/create.ui.js b/module/bug/js/create.ui.js index 2801dd8c96..2fdab4c73c 100644 --- a/module/bug/js/create.ui.js +++ b/module/bug/js/create.ui.js @@ -1,4 +1,22 @@ $(function() { changeProductConfirmed = true; + if(parseInt($('#execution').val())) + { + changeExecution(); + } + else if(parseInt($('#project').val())) + { + const projectID = $('#project').val() + loadProjectBuilds(projectID); + loadAssignedToByProject(projectID); + } + else + { + const productID = $('#product').val(); + const moduleID = $('#module').val(); + const assignedTo = $('#assignedTo').val(); + if(!assignedTo) setTimeout(function(){loadAssignedToByModule(moduleID, productID)}, 500); + } + loadBuildActions(); }); diff --git a/module/bug/lang/de.php b/module/bug/lang/de.php index 45723f3645..842504747a 100644 --- a/module/bug/lang/de.php +++ b/module/bug/lang/de.php @@ -178,8 +178,7 @@ $lang->bug->lblAssignedTo = 'Bearbeiter'; $lang->bug->lblMailto = 'Mail an'; $lang->bug->lblLastEdited = 'Letzte Bearbeitung'; $lang->bug->lblResolved = 'Gelöst von'; -$lang->bug->allUsers = 'Alle Benutzer laden'; -$lang->bug->allBuilds = 'Alle'; +$lang->bug->loadAll = 'Load All'; $lang->bug->createBuild = 'Neu'; global $config; diff --git a/module/bug/lang/en.php b/module/bug/lang/en.php index 1b7a868f19..922a1b450a 100644 --- a/module/bug/lang/en.php +++ b/module/bug/lang/en.php @@ -178,8 +178,7 @@ $lang->bug->lblAssignedTo = 'AssignTo'; $lang->bug->lblMailto = 'Mailto'; $lang->bug->lblLastEdited = 'EditedBy'; $lang->bug->lblResolved = 'ResolvedBy'; -$lang->bug->allUsers = 'Load All Users'; -$lang->bug->allBuilds = 'All Builds'; +$lang->bug->loadAll = 'Load All'; $lang->bug->createBuild = 'New'; global $config; diff --git a/module/bug/lang/fr.php b/module/bug/lang/fr.php index 4142121c06..737e7763f4 100644 --- a/module/bug/lang/fr.php +++ b/module/bug/lang/fr.php @@ -178,8 +178,7 @@ $lang->bug->lblAssignedTo = 'Affecté à'; $lang->bug->lblMailto = 'Mailto'; $lang->bug->lblLastEdited = 'Edité par'; $lang->bug->lblResolved = 'Résolu par'; -$lang->bug->allUsers = 'Charger Tous'; -$lang->bug->allBuilds = 'Tous les Builds'; +$lang->bug->loadAll = 'Load All'; $lang->bug->createBuild = 'Nouveau'; global $config; diff --git a/module/bug/lang/vi.php b/module/bug/lang/vi.php index cbfdf1e542..cce373e088 100644 --- a/module/bug/lang/vi.php +++ b/module/bug/lang/vi.php @@ -157,8 +157,7 @@ $lang->bug->lblAssignedTo = 'Giao cho'; $lang->bug->lblMailto = 'Mail tới'; $lang->bug->lblLastEdited = 'Sửa cuối'; $lang->bug->lblResolved = 'Người giải quyết'; -$lang->bug->allUsers = 'Nạp tất cả người dùng'; -$lang->bug->allBuilds = 'Tất cả bản dựng'; +$lang->bug->loadAll = 'Load All'; $lang->bug->createBuild = 'Mới'; /* Legend list。*/ diff --git a/module/bug/lang/zh-cn.php b/module/bug/lang/zh-cn.php index 1c99c9897f..54a45c2ce9 100644 --- a/module/bug/lang/zh-cn.php +++ b/module/bug/lang/zh-cn.php @@ -178,8 +178,7 @@ $lang->bug->lblAssignedTo = '当前指派'; $lang->bug->lblMailto = '抄送给'; $lang->bug->lblLastEdited = '最后修改'; $lang->bug->lblResolved = '由谁解决'; -$lang->bug->allUsers = '加载所有用户'; -$lang->bug->allBuilds = '所有'; +$lang->bug->loadAll = '加载所有'; $lang->bug->createBuild = '创建'; global $config; diff --git a/module/bug/ui/create.html.php b/module/bug/ui/create.html.php index 50b07846d3..2925f38ff1 100644 --- a/module/bug/ui/create.html.php +++ b/module/bug/ui/create.html.php @@ -11,9 +11,11 @@ declare(strict_types=1); */ namespace zin; -jsVar('bug', $bug); -jsVar('moduleID', $bug->moduleID); -jsVar('tab', $this->app->tab); +jsVar('bug', $bug); +jsVar('moduleID', $bug->moduleID); +jsVar('tab', $this->app->tab); +jsVar('createRelease', $lang->release->create); +jsVar('refresh', $lang->refreshIcon); foreach(explode(',', $config->bug->create->requiredFields) as $field) { @@ -34,14 +36,20 @@ $showKeywords = strpos(",$showFields,", ',keywords,') !== false; formPanel ( - on::change('#product', 'changeProduct'), - on::change('#branch', 'changeBranch'), - on::change('#project', 'changeProject'), - on::change('#execution', 'changeExecution'), - on::change('#module', 'changeModule'), - on::click('#refresh', 'clickRefresh'), - on::click('#allBuilds', 'loadAllBuilds'), - on::click('#allUsers', 'loadAllUsers'), + on::change('#product', 'changeProduct'), + on::change('#branch', 'changeBranch'), + on::change('#project', 'changeProject'), + on::change('#execution', 'changeExecution'), + on::change('#module', 'changeModule'), + on::change('#region', 'changeRegion'), + on::change('#contactListMenu', 'changeContact'), + on::click('#allBuilds', 'loadAllBuilds'), + on::click('#allUsers', 'loadAllUsers'), + on::click('#refreshModule', 'refreshModule'), + on::click('#refreshMailto', 'refreshContact'), + on::click('#refreshExecutionBuild', 'refreshExecutionBuild'), + on::click('#refreshProductBuild', 'refreshProductBuild'), + set::title($lang->bug->create), to::headingActions(icon('cog-outline')), formRow ( @@ -147,17 +155,24 @@ formPanel ( set::multiple(true), set::name('openedBuild[]'), + set('data-items', count($builds)), set::items($builds), set::value(empty($bug->buildID) ? '' : $bug->buildID) ), span + ( + set('id', 'buildBoxActions'), + set('class', 'input-group-addon'), + set('style', array('display' => 'none')) + ), + span ( set('class', 'input-group-addon'), a ( set('id', 'allBuilds'), set('href', 'javascript:;'), - $lang->bug->allBuilds + $lang->bug->loadAll ) ) ) @@ -181,44 +196,62 @@ formPanel ( set('id', 'allUsers'), set('href', 'javascript:;'), - $lang->bug->allUsers + $lang->bug->loadAll ) ) ) ) ), - formRow + (!empty($executionType) && $executionType == 'kanban') ? formRow ( formGroup ( set::width('1/2'), - set::class($showDeadline ? '' : 'hidden'), + set::label($lang->kanbancard->region), + set::control('select'), + set::name('region'), + set::items($regionPairs), + set::value($regionID) + ), + formGroup + ( + set::width('1/2'), + set::label($lang->kanbancard->lane), + set::control('select'), + set::name('lane'), + set::items($lanePairs), + set::value($laneID) + ), + ) : null, + ($showDeadline || $showNoticefeedbackBy) ? formRow + ( + $showDeadline ? formGroup + ( + set::width('1/2'), set::label($lang->bug->deadline), datePicker ( set::name('deadline'), set::value($bug->deadline) ) - ), - formGroup + ) : null, + $showNoticefeedbackBy ? formGroup ( set::width('1/2'), - set::class($showNoticefeedbackBy ? '' : 'hidden'), set::label($lang->bug->feedbackBy), set::name('feedbackBy'), set::value(isset($bug->feedbackBy) ? $bug->feedbackBy : '') - ) - ), + ) : null, + ) : null, formRow ( - formGroup + $showNoticefeedbackBy ? formGroup ( set::width('1/2'), - set::class($showNoticefeedbackBy ? '' : 'hidden'), set::label($lang->bug->notifyEmail), set::name('notifyEmail'), set::value($bug->notifyEmail) - ), + ) : null, formGroup ( set::width('1/2'), @@ -230,24 +263,22 @@ formPanel ), formRow ( - formGroup + $showOS ? formGroup ( set::width('1/2'), - set::class($showOS ? '' : 'hidden'), set::label($lang->bug->os), set::control(array('type' => 'select', 'items' => $lang->bug->osList, 'multiple' => true)), set::name('os[]'), set::value($bug->os) - ), - formGroup + ) : null, + $showBrowser ? formGroup ( set::width('1/2'), - set::class($showOS ? '' : 'hidden'), set::label($lang->bug->browser), set::control(array('type' => 'select', 'items' => $lang->bug->browserList)), set::name('browser'), set::value($bug->browser) - ) + ) : null ), formRow ( @@ -260,21 +291,19 @@ formPanel formGroup ( set::width('180px'), - set::class($showSeverity ? '' : 'hidden'), set::label($lang->bug->severity), set::control(array('type' => 'select', 'items' => $lang->bug->severityList)), set::name('severity'), set::value($bug->severity) ), - formGroup + $showPri ? formGroup ( set::width('180px'), - set::class($showPri ? '' : 'hidden'), set::label($lang->bug->pri), set::control(array('type' => 'select', 'items' => $lang->bug->priList)), set::name('pri'), set::value($bug->pri) - ) + ) : null ), formRow ( @@ -288,12 +317,11 @@ formPanel ) ), ), - formRow + ($showStory || $showTask) ? formRow ( - formGroup + $showStory ? formGroup ( set::width('1/2'), - set::class($showStory ? '' : 'hidden'), set::label($lang->bug->story), inputGroup ( @@ -305,37 +333,70 @@ formPanel set::value($bug->storyID) ) ) - ), - formGroup + ) : null, + $showTask ? formGroup ( set::width('1/2'), - set::class($showTask ? '' : 'hidden'), set::label($lang->bug->task), set::control(array('type' => 'select', 'items' => '')), set::name('task'), set::value($bug->taskID) - ) - ), - formRow + ) : null + ) : null, + ($showMailto || $showKeywords) ? formRow ( - formGroup + $showMailto ? formGroup ( set::width('1/2'), - set::class($showMailto ? '' : 'hidden'), set::label($lang->bug->lblMailto), - set::control(array('type' => 'select', 'items' => $users, 'multiple' => true)), - set::name('mailto[]'), - set::value($bug->mailto ? str_replace(' ', '', $bug->mailto) : '') - ), - formGroup + inputGroup + ( + select + ( + set::multiple(true), + set::name('mailto[]'), + set::items($users), + set::value($bug->mailto ? str_replace(' ', '', $bug->mailto) : '') + ), + span + ( + set('id', 'contactBox'), + set('class', 'input-group-addon'), + $contactList ? select + ( + set::class('width', 'w-20'), + set::name('contactListMenu'), + set::items($contactList), + set::value() + ) : a + ( + set('href', createLink('my', 'managecontacts', 'listID=0&mode=new')), + set('title', $lang->user->contacts->manage), + set('data-toggle', 'modal'), + icon('cog'), + ) + ), + span + ( + set('class', 'input-group-addon'), + a + ( + set('id', 'refreshMailto'), + set('class', 'text-black'), + set('href', 'javascript:void(0)'), + icon('refresh') + ) + ) + ) + ) : null, + $showKeywords ? formGroup ( set::width('1/2'), - set::class($showKeywords ? '' : 'hidden'), set::label($lang->bug->keywords), set::name('keywords'), set::value($bug->keywords) - ) - ), + ) : null + ) : null, formRow ( formGroup diff --git a/module/bug/ui/edit.html.php b/module/bug/ui/edit.html.php index 247d254f29..7cb961556d 100644 --- a/module/bug/ui/edit.html.php +++ b/module/bug/ui/edit.html.php @@ -187,7 +187,7 @@ panel ( set('id', 'allUsers'), set('href', 'javascript:;'), - $lang->bug->allUsers + $lang->bug->loadAll ) ) ) @@ -323,7 +323,7 @@ panel ( set('id', 'allBuilds'), set('href', 'javascript:;'), - $lang->bug->allBuilds + $lang->bug->loadAll ) ) ) @@ -364,7 +364,7 @@ panel ( set('id', 'allBuilds'), set('href', 'javascript:;'), - $lang->bug->allBuilds + $lang->bug->loadAll ) ) ) diff --git a/module/bug/zen.php b/module/bug/zen.php index b96571a6e2..d8afc42db9 100644 --- a/module/bug/zen.php +++ b/module/bug/zen.php @@ -1158,6 +1158,7 @@ class bugZen extends bug $this->view->releasedBuilds = $this->loadModel('release')->getReleasedBuilds($bug->productID, $bug->branch); $this->view->resultFiles = (!empty($resultID) and !empty($stepIdList)) ? $this->loadModel('file')->getByObject('stepResult', $resultID, str_replace('_', ',', $stepIdList)) : array(); $this->view->product = $currentProduct; + $this->view->contactList = $this->loadModel('user')->getContactLists($this->app->user->account, 'withnote'); } /** diff --git a/module/tree/control.php b/module/tree/control.php index 8b36ae18bd..340f7ae672 100644 --- a/module/tree/control.php +++ b/module/tree/control.php @@ -588,7 +588,7 @@ class tree extends control $output .= ""; $output .= html::a($this->createLink('tree', 'browse', "rootID=$rootID&view=$viewType¤tModuleID=0&branch=$branch", '', true), $this->lang->tree->manage, '', "class='text-primary' data-toggle='modal' data-type='iframe' data-width='95%'"); $output .= '  '; - $output .= html::a("javascript:void(0)", $this->lang->refreshIcon, '', "class='refresh' onclick='loadProductModules($rootID)'"); + $output .= html::a("javascript:void(0)", $this->lang->refreshIcon, '', "id='refreshModule' class='refresh' onclick='loadProductModules($rootID)'"); $output .= ''; } }