From 88e49266ea266920fd87dabe2a05822257f0bae5 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Mon, 16 Oct 2023 17:32:03 +0800 Subject: [PATCH] * Adjust for program module. --- module/product/ui/batchedit.html.php | 4 ++- module/productplan/js/browse.ui.js | 7 ++--- module/productplan/ui/browsebylist.html.php | 3 +-- module/program/js/product.ui.js | 16 ++++++++---- module/program/js/project.ui.js | 5 ++++ module/program/ui/product.html.php | 29 ++++++++++----------- module/program/ui/project.html.php | 2 +- module/story/js/batchcreate.ui.js | 8 ------ module/story/ui/batchcreate.html.php | 2 +- 9 files changed, 38 insertions(+), 38 deletions(-) diff --git a/module/product/ui/batchedit.html.php b/module/product/ui/batchedit.html.php index 89acf94dff..f5c9c6af12 100644 --- a/module/product/ui/batchedit.html.php +++ b/module/product/ui/batchedit.html.php @@ -17,6 +17,7 @@ $items['id'] = array('name' => 'id', 'label' => $lang->idAB, 'control foreach($fields as $fieldName => $field) { $items[$fieldName] = array('name' => $fieldName, 'label' => $field['title'], 'control' => $field['control'], 'width' => $field['width'], 'required' => $field['required'], 'items' => zget($field, 'options', array())); + if($items[$fieldName]['control'] == 'select') $items[$fieldName]['control'] = 'picker'; } $items['acl']['control'] = array('type' => $items['acl']['control'], 'inline' => true); @@ -24,9 +25,10 @@ $extendFields = $this->product->getFlowExtendFields(); foreach($extendFields as $extendField) { $items[$extendField->field] = array('name' => $extendField->field, 'label' => $extendField->name, 'required' => strpos(",$extendField->rules,", ',1,') !== false, 'control' => $extendField->control, 'items' => zget($extendField, 'options', array())); + if($extendField->control == 'select') $items[$extendField->field]['control'] = 'picker'; if($extendField->control == 'multi-select') { - $items[$extendField->field]['control'] = 'select'; + $items[$extendField->field]['control'] = 'picker'; $items[$extendField->field]['multiple'] = true; } } diff --git a/module/productplan/js/browse.ui.js b/module/productplan/js/browse.ui.js index 2c019bb653..4333cbe225 100644 --- a/module/productplan/js/browse.ui.js +++ b/module/productplan/js/browse.ui.js @@ -9,12 +9,9 @@ const executionDropdownMap = new Map(); * @access public * @return object */ -window.setStatistics = function(element, checkedIDList) +window.setStatistics = function(element, checkedIDList, pageSummary) { - if(!checkedIDList.length) - { - return {html: pageSummary, className: 'text-dark'}; - } + if(!checkedIDList.length) return {html: pageSummary, className: 'text-dark'}; let total = checkedIDList.length; let totalParent = 0; diff --git a/module/productplan/ui/browsebylist.html.php b/module/productplan/ui/browsebylist.html.php index 0a359205e0..a5dc131835 100644 --- a/module/productplan/ui/browsebylist.html.php +++ b/module/productplan/ui/browsebylist.html.php @@ -10,7 +10,6 @@ declare(strict_types=1); */ namespace zin; -jsVar('+pageSummary', $summary); jsVar('checkedSummary', $lang->productplan->checkedSummary); /* zin: Define the set::module('productplan') feature bar on main menu. */ @@ -85,7 +84,7 @@ dtable set::customCols(true), set::onRenderCell(jsRaw('window.renderCell')), set::footToolbar($footToolbar), - set::checkInfo(jsRaw('function(checkedIDList){return window.setStatistics(this, checkedIDList);}')), + set::checkInfo(jsRaw("function(checkedIDList){return window.setStatistics(this, checkedIDList, '{$summary}');}")), set::footPager( usePager(array('linkCreator' => createLink($app->rawModule, 'browse', "productID={$productID}&branch={$branch}&browseType={$browseType}&queryID={$queryID}&orderBy={$orderBy}&recTotal={$pager->recTotal}&recPerPage={recPerPage}&pageID={page}"))), ) diff --git a/module/program/js/product.ui.js b/module/program/js/product.ui.js index 54411303e1..f88efbc1fd 100644 --- a/module/program/js/product.ui.js +++ b/module/program/js/product.ui.js @@ -1,10 +1,11 @@ /** * Submit data to product batch edit page by html form while click on the batch edit button. */ -window.onClickBatchEdit = function(event) +$(document).off('click', '[data-formaction]').on('click', '[data-formaction]', function() { - const checkedList = zui.DTable.query(event.target).$.getChecks(); - + const $this = $(this); + const dtable = zui.DTable.query($('#products')); + const checkedList = dtable.$.getChecks(); if(!checkedList.length) return; const formData = new FormData(); @@ -13,5 +14,10 @@ window.onClickBatchEdit = function(event) formData.append('productIDList[]', id); }); - postAndLoadPage($(event.target.closest('button')).data('url'), formData, '', {app: 'program'}); -}; + postAndLoadPage($this.data('formaction'), formData); +}); + +window.footerSummary = function(checkedIdList, pageSummary) +{ + return {html: pageSummary}; +} diff --git a/module/program/js/project.ui.js b/module/program/js/project.ui.js index 57f11d1ccb..846803214e 100644 --- a/module/program/js/project.ui.js +++ b/module/program/js/project.ui.js @@ -24,3 +24,8 @@ $(document).on('click', '.batch-btn', function() checkedList.forEach((id) => form.append('projectIdList[]', id)); postAndLoadPage(url, form); }); + +window.footerSummary = function(checkedIdList, pageSummary) +{ + return {html: pageSummary}; +} diff --git a/module/program/ui/product.html.php b/module/program/ui/product.html.php index fd939c6164..4eb8204611 100644 --- a/module/program/ui/product.html.php +++ b/module/program/ui/product.html.php @@ -37,30 +37,29 @@ $products = initTableData($products, $cols, $this->product); foreach($products as $product) $data[] = $this->product->formatDataForList($product, $users, $usersAvatar); $summary = sprintf($lang->product->pageSummary, count($data)); -$footToolbar = common::hasPriv('product', 'batchEdit') ? - array( - 'type' => 'btn-group', - 'items' => array( - array( - 'text' => $lang->edit, - 'btnType' => 'secondary size-sm', - 'data-url' => $this->createLink('product', 'batchEdit', "programID={$programID}"), - 'data-app' => $this->app->tab, - 'onClick' => jsRaw('window.onClickBatchEdit') - ) - ) - ) : - null; +$footToolbar = common::hasPriv('product', 'batchEdit') ? array( + 'type' => 'btn-group', + 'items' => array( + array( + 'text' => $lang->edit, + 'className' => 'secondary size-sm batch-btn', + 'data-page' => 'batch', + 'data-app' => $this->app->tab, + 'data-formaction' => $this->createLink('product', 'batchEdit', "programID={$programID}") + ), + ) +) : null; dtable ( + setID('products'), set::userMap($users), set::cols($cols), set::data($data), set::nested(false), set::footToolbar($footToolbar), set::footPager(usePager()), - set::footer(array('checkbox', 'toolbar', array('html' => $summary, 'className' => "text-dark"), 'flex', 'pager')), + set::checkInfo(jsRaw("function(checkedIDList){ return window.footerSummary(checkedIDList, '{$summary}');}")), ); render(); diff --git a/module/program/ui/project.html.php b/module/program/ui/project.html.php index 4492cabe32..8c29f3ce62 100644 --- a/module/program/ui/project.html.php +++ b/module/program/ui/project.html.php @@ -64,7 +64,7 @@ dtable set::nested(false), set::footToolbar($footToolbar), set::footPager(usePager()), - set::footer(array('checkbox', 'toolbar', array('html' => $summary, 'className' => "text-dark"), 'flex', 'pager')), + set::checkInfo(jsRaw("function(checkedIDList){ return window.footerSummary(checkedIDList, '{$summary}');}")), ); render(); diff --git a/module/story/js/batchcreate.ui.js b/module/story/js/batchcreate.ui.js index 6baeb26726..e69de29bb2 100644 --- a/module/story/js/batchcreate.ui.js +++ b/module/story/js/batchcreate.ui.js @@ -1,8 +0,0 @@ -window.renderRowData = function($row) -{ - $row.find('select').each(function() - { - $select = $(this); - if($select.prop('multiple')){$select.attr('name', $select.attr('name') + '[]');} - }); -}; diff --git a/module/story/ui/batchcreate.html.php b/module/story/ui/batchcreate.html.php index 212248f7a8..fcd72c91e6 100644 --- a/module/story/ui/batchcreate.html.php +++ b/module/story/ui/batchcreate.html.php @@ -26,6 +26,7 @@ $fnGenerateFields = function() use ($lang, $fields) $field['name'] = $name; if(!empty($field['options'])) $field['items'] = $field['options']; if(!empty($field['default'])) $field['value'] = $field['default']; + if($field['control'] == 'select') $field['control'] = 'picker'; unset($field['options']); return $field; @@ -42,7 +43,6 @@ formBatchPanel set::pasteField('title'), set::customFields(array('list' => $customFields, 'show' => explode(',', $showFields), 'key' => 'batchCreateFields')), set::items($fnGenerateFields()), - set::onRenderRow(jsRaw('renderRowData')), set::actions(array ( array('text' => $lang->save, 'id' => 'saveButton', 'class' => 'primary'),