From 5c3f340c6e4b5dc07ebecb82f747cae87fd33859 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Fri, 6 Sep 2024 14:28:51 +0800 Subject: [PATCH] * [bug#54426,done,0.5h] get oldProducts at first and hide delete button if it's unmodifiable. --- lib/zin/wg/productsbox/v1.php | 4 ++-- module/execution/control.php | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/zin/wg/productsbox/v1.php b/lib/zin/wg/productsbox/v1.php index b130a2abc2..07d6c57243 100644 --- a/lib/zin/wg/productsbox/v1.php +++ b/lib/zin/wg/productsbox/v1.php @@ -366,7 +366,7 @@ class productsBox extends wg set::multiple(true) ) ) : null, - (!empty($project) && (in_array($product->id, $unmodifiableProducts) || $isStage)) ? null : div + (!empty($project) && $isStage) ? null : div ( setClass('pl-2 flex self-center line-btn c-actions', $i == 0 ? 'first-action' : ''), btn @@ -379,7 +379,7 @@ class productsBox extends wg ( bind::click('removeLine(event)'), setClass('btn btn-link text-gray removeLine'), - setClass(($i == 0 || $disabledProduct) ? 'hidden' : ''), + setClass(($i == 0 || $disabledProduct || in_array($product->id, $unmodifiableProducts)) ? 'hidden' : ''), icon('trash') ) ) diff --git a/module/execution/control.php b/module/execution/control.php index 95beefa0ee..f2a3cdd1b3 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2118,12 +2118,13 @@ class execution extends control if(!empty($_POST)) { + $oldProducts = $this->loadModel('product')->getProducts($executionID); + $oldProducts = array_keys($oldProducts); + $postData = form::data()->get(); $this->execution->updateProducts($executionID, $postData); if(dao::isError()) return $this->sendError(dao::getError()); - $oldProducts = $this->loadModel('product')->getProducts($executionID); - $oldProducts = array_keys($oldProducts); $newProducts = $this->product->getProducts($executionID); $newProducts = array_keys($newProducts); $diffProducts = array_merge(array_diff($oldProducts, $newProducts), array_diff($newProducts, $oldProducts));