* Adjust for program projectview page.

This commit is contained in:
wangyidong
2023-06-16 15:53:31 +08:00
parent 02397b3f01
commit 87bb89fc0c
7 changed files with 38 additions and 22 deletions
+3 -2
View File
@@ -31,8 +31,9 @@ window.showLink = function(obj)
$(document).on('click', '.batch-btn', function()
{
const type = $(this).data('type');
const dtable = zui.DTable.query($('#' + type + 'DTable'));
const $this = $(this);
const type = $this.data('type');
const dtable = zui.DTable.query($this);
const checkedList = dtable.$.getChecks();
if(!checkedList.length) return;
+5 -2
View File
@@ -46,7 +46,9 @@ $config->program->dtable->fieldList['end']['sortType'] = true;
$config->program->dtable->fieldList['progress']['name'] = 'progress';
$config->program->dtable->fieldList['progress']['title'] = $lang->program->progressAB;
$config->program->dtable->fieldList['progress']['minWidth'] = 100;
$config->program->dtable->fieldList['progress']['type'] = 'circleProgress';
$config->program->dtable->fieldList['progress']['sortType'] = false;
$config->program->dtable->fieldList['progress']['type'] = 'progress';
$config->program->dtable->fieldList['progress']['align'] = 'center';
$config->program->dtable->fieldList['actions']['name'] = 'actions';
$config->program->dtable->fieldList['actions']['title'] = $lang->actions;
@@ -193,6 +195,7 @@ $config->program->projectView->dtable->fieldList['name']['name'] = 'name
$config->program->projectView->dtable->fieldList['name']['title'] = $lang->nameAB;
$config->program->projectView->dtable->fieldList['name']['width'] = 200;
$config->program->projectView->dtable->fieldList['name']['type'] = 'link';
$config->program->projectView->dtable->fieldList['name']['link'] = "RAWJS<function(info){const {row, col} = info; if(row.data.type == 'project') return {url:$.createLink('project', 'browse', 'projectID={id}')}; if(row.data.type == 'program') return {url:$.createLink('program', 'view', 'programID={id}')};}>RAWJS";
$config->program->projectView->dtable->fieldList['name']['flex'] = 1;
$config->program->projectView->dtable->fieldList['name']['nestedToggle'] = true;
$config->program->projectView->dtable->fieldList['name']['checkbox'] = true;
@@ -281,7 +284,7 @@ $config->program->projectView->dtable->fieldList['realEnd']['group'] = 7;
$config->program->projectView->dtable->fieldList['progress']['name'] = 'progress';
$config->program->projectView->dtable->fieldList['progress']['title'] = $lang->program->progressAB;
$config->program->projectView->dtable->fieldList['progress']['minWidth'] = 100;
$config->program->projectView->dtable->fieldList['progress']['type'] = 'circleProgress';
$config->program->projectView->dtable->fieldList['progress']['type'] = 'progress';
$config->program->projectView->dtable->fieldList['progress']['show'] = true;
$config->program->projectView->dtable->fieldList['progress']['group'] = 8;
+2 -2
View File
@@ -165,7 +165,7 @@ class program extends control
$program = $this->program->getByID($programID);
$path = explode(',', $program->path);
$path = array_filter($path);
$programID = current($path);
$programID = (int)current($path);
$this->view->program = $program;
}
@@ -747,7 +747,7 @@ class program extends control
* @access public
* @return void
*/
public function view($programID)
public function view(int $programID)
{
$programID = (int)$programID;
$program = $this->program->getByID($programID);
+14 -2
View File
@@ -1,8 +1,8 @@
window.footerGenerator = function()
{
const count = this.layout.allRows.filter((x) => x.data.type === "product").length;
const count = this.layout.allRows.filter((x) => x.data.type === "product").length;
const statistic = summeryTpl.replace('%s', ' ' + count + ' ');
return [{children: statistic, className: "text-dark"}, "flex", "pager"];
return ['checkbox', 'toolbar', {html: statistic, className: "text-dark"}, "flex", "pager"];
}
window.renderCell = function(result, {col, row})
@@ -27,3 +27,15 @@ window.renderCell = function(result, {col, row})
return result;
}
$(document).on('click', '.batch-btn', function()
{
const $this = $(this);
const dtable = zui.DTable.query($this);
const checkedList = dtable.$.getChecks();
if(!checkedList.length) return;
const postData = new FormData();
checkedList.forEach((id) => postData.append('projectIdList[]', id));
postAndLoadPage($(this).data('url'), postData);
})
+2 -2
View File
@@ -27,7 +27,7 @@ class programModel extends model
* @access public
* @return int
*/
public function saveState($programID = 0, $programs = array())
public function saveState(int $programID = 0, array $programs = array()): int
{
if($programID > 0) $this->session->set('program', (int)$programID);
if($programID == 0 and $this->cookie->lastProgram) $this->session->set('program', (int)$this->cookie->lastProgram);
@@ -38,7 +38,7 @@ class programModel extends model
if($programID && strpos(",{$this->app->user->view->programs},", ",{$this->session->program},") === false) $this->accessDenied();
}
return $this->session->program;
return (int)$this->session->program;
}
/**
+11 -12
View File
@@ -2,7 +2,6 @@
namespace zin;
$cols = array_values($config->program->projectView->dtable->fieldList);
$data = array();
foreach($programs as $program)
{
@@ -28,14 +27,18 @@ foreach($programs as $program)
}
/* Calculate budget.*/
$programBudget = $this->loadModel('project')->getBudgetWithUnit($program->budget);
$programBudget = $this->loadModel('project')->getBudgetWithUnit($program->budget);
$program->budget = $program->budget != 0 ? zget($lang->project->currencySymbol, $program->budgetUnit) . ' ' . $programBudget : $lang->project->future;
/* Progress. */
if(isset($progressList[$program->id])) $program->progress = round($progressList[$program->id]);
$program->isParent = false;
if($program->parent > 0 and isset($programs[$program->parent])) $programs[$program->parent]->isParent = true;
/* Set invested hours. */
if(!isset($program->invested)) $program->invested = 0;
if(str_contains($program->end, LONG_TIME)) $program->end = $lang->program->longTime;
/* Actions. */
$program->actions = array();
@@ -52,20 +55,13 @@ foreach($programs as $program)
$data[] = $program;
}
jsVar('langManDay', $lang->program->manDay);
jsVar('langPostponed', empty($program->end) ? $lang->project->statusList['delay'] : sprintf($lang->project->delayInfo, helper::diffDate(helper::today(), $program->end)));
jsVar('summeryTpl', $summary);
jsVar('langManDay', $lang->program->manDay);
jsVar('summeryTpl', $summary);
featureBar
(
set::current($status),
set::linkParams("status={key}&orderBy=$orderBy"),
(hasPriv('project', 'batchEdit') && $programType != 'bygrid' && $hasProject === true) ? item
(
set::type('checkbox'),
set::text($lang->project->edit),
set::checked($this->cookie->editProject)
) : NULL,
li(searchToggle(set::module('program')))
);
@@ -87,16 +83,19 @@ toolbar
])),
);
$footToolbar = common::hasPriv('project', 'batchEdit') ? array('items' => array(array('text' => $lang->project->edit, 'class' => 'btn batch-btn size-sm primary', 'data-url' => createLink('project', 'batchEdit')))) : null;
dtable
(
set::cols($cols),
set::data($data),
set::nested(true),
set::onRenderCell(jsRaw('window.renderCell')),
set::canRowCheckable(jsRaw("function(rowID){return this.getRowInfo(rowID).data.type == 'project';}")),
set::footPager(usePager()),
set::footer(jsRaw('function(){return window.footerGenerator.call(this);}')),
set::customCols(true),
set::userMap($this->loadModel('user')->getPairs('noletter|pofirst'))
set::userMap($this->loadModel('user')->getPairs('noletter|pofirst')),
set::footToolbar($footToolbar),
);
render();
+1
View File
@@ -5738,6 +5738,7 @@ class storyModel extends model
{
$story->actions = $this->buildActionButtonList($story, 'browse');
$story->estimate = $story->estimate . $this->config->hourUnit;
$story->isParent = isset($story->children);
$story->taskCount = zget(zget($options, 'storyTasks', array()), $story->id, 0);
$story->bugCount = zget(zget($options, 'storyBugs', array()), $story->id, 0);