From a2f5dd92807ff99c1c6b9766a4fdf027620fc51e Mon Sep 17 00:00:00 2001 From: liumengyi Date: Fri, 13 Oct 2023 13:49:43 +0800 Subject: [PATCH] * Change `get` to `getJSON` when updating the items of assignedTo picker. --- module/bug/control.php | 12 +++++----- module/bug/js/common.ui.js | 45 ++++++++++++++------------------------ 2 files changed, 22 insertions(+), 35 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index d26b841f5b..48feb25bb9 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -1353,8 +1353,8 @@ class bug extends control { /* 获取bug模块负责人。 */ /* Get module owner. */ - $moduleOwner = $this->bug->getModuleOwner($moduleID, $productID); - return print(json_encode($moduleOwner)); + list($account, $realname) = $this->bug->getModuleOwner($moduleID, $productID); + return print(json_encode(array('account' => $account, 'realname' => $realname))); } /** @@ -1373,7 +1373,7 @@ class bug extends control $items = array(); foreach($members as $account => $member) { - if($account) $items[] = array('text' => $member, 'value' => $account, 'keys' => $account . $member); + if($account) $items[] = array('text' => $member, 'value' => $account); } return print(json_encode($items)); } @@ -1455,7 +1455,7 @@ class bug extends control $items = array(); foreach($productMembers as $account => $member) { - if($account) $items[] = array('text' => $member, 'value' => $account, 'keys' => $member); + if($account) $items[] = array('text' => $member, 'value' => $account); } return print(json_encode($items)); } @@ -1481,7 +1481,7 @@ class bug extends control unset($productBugs[$bugID]); $bugList = array(); - foreach($productBugs as $bugID => $bugName) $bugList[] = array('value' => $bugID, 'text' => $bugName, 'keys' => $bugName); + foreach($productBugs as $bugID => $bugName) $bugList[] = array('value' => $bugID, 'text' => $bugName); return $this->send($bugList); } @@ -1504,7 +1504,7 @@ class bug extends control if($account) { $userName = ucfirst(mb_substr($account, 0, 1)) . ':' . ($member ? $member : $account); - $items[] = array('text' => $userName, 'value' => $account, 'keys' => $userName); + $items[] = array('text' => $userName, 'value' => $account); } } return print(json_encode($items)); diff --git a/module/bug/js/common.ui.js b/module/bug/js/common.ui.js index 9dbb6e1342..c2f5e55821 100644 --- a/module/bug/js/common.ui.js +++ b/module/bug/js/common.ui.js @@ -269,48 +269,36 @@ function loadAssignedToByProduct(productID) if(typeof(branch) == 'undefined') branch = 0; const link = $.createLink('bug', 'ajaxGetProductMembers', 'productID=' + productID + '&selectedUser=' + $('[name="assignedTo"]').val() + '&branchID=' + branch); - $.get(link, function(data) + $.getJSON(link, function(data) { let assignedTo = $('[name="assignedTo"]').val(); let $assignedToPicker = $('[name="assignedTo"]').zui('picker'); - if(data) - { - data = JSON.parse(data); - $assignedToPicker.render({items: data}); - $assignedToPicker.$.setValue(assignedTo); - } + $assignedToPicker.render({items: data}); + $assignedToPicker.$.setValue(assignedTo); }); } function loadAssignedToByProject(projectID) { const link = $.createLink('bug', 'ajaxGetProjectTeamMembers', 'projectID=' + projectID); - $.get(link, function(data) + $.getJSON(link, function(data) { let assignedTo = $('[name="assignedTo"]').val(); let $assignedToPicker = $('[name="assignedTo"]').zui('picker'); - if(data) - { - data = JSON.parse(data); - $assignedToPicker.render({items: data}); - $assignedToPicker.$.setValue(assignedTo); - } + $assignedToPicker.render({items: data}); + $assignedToPicker.$.setValue(assignedTo); }); } function loadAssignedToByExecution(executionID) { const link = $.createLink('bug', 'ajaxLoadAssignedTo', 'executionID=' + executionID); - $.get(link, function(data) + $.getJSON(link, function(data) { let assignedTo = $('[name="assignedTo"]').val(); let $assignedToPicker = $('[name="assignedTo"]').zui('picker'); - if(data) - { - data = JSON.parse(data); - $assignedToPicker.render({items: data}); - $assignedToPicker.$.setValue(assignedTo); - } + $assignedToPicker.render({items: data}); + $assignedToPicker.$.setValue(assignedTo); }); } @@ -319,15 +307,14 @@ function loadAssignedToByModule(moduleID, productID) if(typeof(productID) == 'undefined') productID = $('[name="product"]').val(); if(typeof(moduleID) == 'undefined') moduleID = $('[name="module"]').val(); const link = $.createLink('bug', 'ajaxGetModuleOwner', 'moduleID=' + moduleID + '&productID=' + productID); - $.get(link, function(owner) + $.getJSON(link, function(owner) { - owner = JSON.parse(owner); - var account = owner[0]; - var realName = owner[1]; - var isExist = false; - var $assignedToPicker = $('[name="assignedTo"]').zui('picker'); - var assignedToItems = $assignedToPicker.ref.current.state.items; - var count = assignedToItems.length; + let account = owner.account; + let realName = owner.realname; + let isExist = false; + let $assignedToPicker = $('[name="assignedTo"]').zui('picker'); + let assignedToItems = $assignedToPicker.options.items; + let count = assignedToItems.length; for(var i = 0; i < count; i++) { if(assignedToItems[i].value == account)