* Finish task #117515, product can be sorted only in order_asc.
This commit is contained in:
@@ -535,7 +535,7 @@ class product extends control
|
||||
{
|
||||
/* Can only be order by program sorting. */
|
||||
$orderBy = $this->post->orderBy;
|
||||
if(strpos($orderBy, 'program') === false) return false;
|
||||
if(strpos($orderBy, 'order') === false) return false;
|
||||
|
||||
/* Get sorted id list. */
|
||||
$products = json_decode($this->post->products, true);
|
||||
@@ -579,7 +579,7 @@ class product extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function all(string $browseType = 'noclosed', string $orderBy = 'program_asc', int $param = 0, int $recTotal = 0, int $recPerPage = 20, int $pageID = 1, int $programID = 0)
|
||||
public function all(string $browseType = 'noclosed', string $orderBy = 'order_asc', int $param = 0, int $recTotal = 0, int $recPerPage = 20, int $pageID = 1, int $programID = 0)
|
||||
{
|
||||
/* Set env data. */
|
||||
$this->productZen->setMenu4All();
|
||||
|
||||
@@ -41,8 +41,8 @@ function getCheckedItems()
|
||||
};
|
||||
|
||||
/**
|
||||
* 拖拽的用例或者场景是否允许放下。
|
||||
* Is it allowed to drop the dragged case or scene.
|
||||
* 拖拽的产品是否允许放下。
|
||||
* Is it allowed to drop the dragged product.
|
||||
*
|
||||
* @param from 被拿起的元素
|
||||
* @param to 放下时的目标元素
|
||||
@@ -52,13 +52,12 @@ function getCheckedItems()
|
||||
window.canSortTo = function(from, to)
|
||||
{
|
||||
if(!from || !to) return false;
|
||||
if(from.data.program != to.data.program) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拖拽用例或者场景。
|
||||
* Drag case or scene.
|
||||
* 拖拽产品。
|
||||
* Drag product.
|
||||
*
|
||||
* @param from 被拿起的元素
|
||||
* @param to 放下时的目标元素
|
||||
@@ -69,7 +68,6 @@ window.canSortTo = function(from, to)
|
||||
window.onSortEnd = function(from, to, type)
|
||||
{
|
||||
if(!from || !to) return false;
|
||||
if(from.data.program != to.data.program) return false;
|
||||
|
||||
const url = $.createLink('product', 'updateOrder');
|
||||
const form = new FormData();
|
||||
|
||||
@@ -550,11 +550,7 @@ class productModel extends model
|
||||
if(empty($sortedIdList)) return;
|
||||
|
||||
/* Get the list of products before sorting. */
|
||||
$products = $this->dao->select('t1.`order`, t1.id')->from(TABLE_PRODUCT)->alias('t1')
|
||||
->leftJoin(TABLE_PROGRAM)->alias('t2')->on('t1.program = t2.id')
|
||||
->where('t1.id')->in($sortedIdList)
|
||||
->orderBy('t2.order_asc, t1.line_desc, t1.order_asc')
|
||||
->fetchPairs('order', 'id');
|
||||
$products = $this->dao->select('`order`, id')->from(TABLE_PRODUCT)->where('id')->in($sortedIdList)->orderBy('order_asc')->fetchPairs('order', 'id');
|
||||
|
||||
/* Update order by sorted id list. */
|
||||
foreach($products as $order => $id)
|
||||
|
||||
@@ -126,12 +126,12 @@ toolbar
|
||||
);
|
||||
|
||||
$canBatchEdit = hasPriv('product', 'batchEdit');
|
||||
$canUpdateOrder = hasPriv('product', 'updateOrder');
|
||||
$canUpdateOrder = hasPriv('product', 'updateOrder') && strpos($orderBy, 'order') !== false;
|
||||
dtable
|
||||
(
|
||||
set::id('products'),
|
||||
set::plugins(array('sortable')),
|
||||
set::sortable($canUpdateOrder && strpos($orderBy, 'order') === false),
|
||||
set::sortable($canUpdateOrder),
|
||||
set::onSortEnd($canUpdateOrder ? jsRaw('window.onSortEnd') : null),
|
||||
set::canSortTo($canUpdateOrder ? jsRaw('window.canSortTo') : null),
|
||||
set::cols($cols),
|
||||
|
||||
Reference in New Issue
Block a user