* [task#143873,doing,2h] Insert gantt chart in document.

This commit is contained in:
daitingting
2025-05-27 09:04:09 +00:00
parent 5b9d63618c
commit fde1afa600
4 changed files with 100 additions and 4 deletions
+15 -1
View File
@@ -46,10 +46,12 @@ class programplan extends control
* @param int $baselineID
* @param string $browseType
* @param int $queryID
* @param string $from
* @param int $blockID
* @access public
* @return void
*/
public function browse(int $projectID = 0, int $productID = 0, string $type = 'gantt', string $orderBy = 'id_asc', int $baselineID = 0, string $browseType = '', int $queryID = 0)
public function browse(int $projectID = 0, int $productID = 0, string $type = 'gantt', string $orderBy = 'id_asc', int $baselineID = 0, string $browseType = '', int $queryID = 0, string $from = 'project', int $blockID = 0)
{
if($type == 'lists')
{
@@ -57,6 +59,15 @@ class programplan extends control
return;
}
if($from == 'doc')
{
$this->loadModel('doc');
$projects = $this->loadModel('project')->getPairsByModel(array('ipd', 'waterfall', 'waterfallplus'));
if(empty($projects)) return $this->send(array('result' => 'fail', 'message' => $this->lang->doc->tips->noProject));
$this->view->projects = $projects;
}
$this->app->loadLang('stage');
$this->session->set('projectPlanList', $this->app->getURI(true), 'project');
$this->commonAction($projectID, $productID);
@@ -71,6 +82,9 @@ class programplan extends control
$browseType = strtolower($browseType);
$plans = $this->programplanZen->buildStages($projectID, $productID, $baselineID, $type, $orderBy, $browseType, $queryID);
$this->view->from = $from;
$this->view->blockID = $blockID;
/* Build gantt browse view. */
$this->programplanZen->buildBrowseView($projectID, $productID, $plans, $type, $orderBy, $baselineID, $browseType, $queryID);
}
+1
View File
@@ -0,0 +1 @@
.mb-4-important {margin-bottom: 16px !important;}
+22
View File
@@ -0,0 +1,22 @@
window.insertToDoc = function(blockID, insertLink)
{
const docID = getDocApp()?.docID;
const blockType = 'gantt';
const url = $.createLink('doc', 'buildZentaoList', `docID=${docID}&type=${blockType}&blockID=${blockID}`);
const formData = new FormData();
formData.append('ganttOptions', JSON.stringify(ganttOptions));
formData.append('url', insertLink);
$.post(url, formData, function(resp)
{
resp = JSON.parse(resp);
if(resp.result == 'success')
{
const oldBlockID = resp.oldBlockID;
const newBlockID = resp.newBlockID;
zui.Modal.hide();
window.insertZentaoList && window.insertZentaoList(blockType, newBlockID, null, oldBlockID);
}
});
}
+62 -3
View File
@@ -15,7 +15,58 @@ namespace zin;
data('fileName', 'gantt-export-' . $projectID);
include './ganttfields.html.php';
if($app->rawModule == 'programplan')
$isFromDoc = $from === 'doc';
if($isFromDoc)
{
jsVar('ganttOptions', $plans);
$this->app->loadLang('doc');
$projectChangeLink = createLink('programPlan', 'browse', "projectID={projectID}&productID={$productID}&type={$type}&orderBy=$orderBy&baselineID=&browseType={$browseType}&queryID={$queryID}&from=$from&blockID=$blockID");
$insertLink = createLink('programPlan', 'browse', "projectID=$projectID&productID={$productID}&type={$type}&orderBy=$orderBy&baselineID=&browseType={$browseType}&queryID={$queryID}&from=$from&blockID={blockID}");
formPanel
(
setID('zentaolist'),
setClass('mb-4-important'),
set::title(sprintf($this->lang->doc->insertTitle, $this->lang->doc->zentaoList['gantt'])),
set::actions(array()),
set::showExtra(false),
to::titleSuffix
(
span
(
setClass('text-muted text-sm text-gray-600 font-light'),
span
(
setClass('text-warning mr-1'),
icon('help'),
),
$lang->doc->previewTip
)
),
formRow
(
formGroup
(
set::width('1/2'),
set::name('project'),
set::label($lang->doc->project),
set::control(array('required' => false)),
set::items($projects),
set::value($projectID),
set::required(),
span
(
setClass('error-tip text-danger hidden'),
$lang->doc->emptyError
),
on::change('[name="project"]')->do("loadModal('$projectChangeLink'.replace('{projectID}', $(this).val()))")
)
)
);
}
if($app->rawModule == 'programplan' && !$isFromDoc)
{
$productDropdown = null;
if($project->stageBy == 'product')
@@ -63,9 +114,17 @@ gantt
(
set('ganttLang', $ganttLang),
set('ganttFields', $ganttFields),
set('canEdit', common::hasPriv('programplan', 'ganttEdit')),
set('canEditDeadline', common::hasPriv('review', 'edit')),
set('canEdit', $isFromDoc ? false : hasPriv('programplan', 'ganttEdit')),
set('canEditDeadline', $isFromDoc ? false : hasPriv('review', 'edit')),
set('zooming', isset($zooming) ? $zooming : 'day'),
set('showChart', !$dateDetails),
set('options', $plans)
);
$isFromDoc ? btn
(
setClass('mt-4'),
set::type('primary'),
on::click("insertToDoc($blockID, '$insertLink')"),
$lang->doc->insertText
) : null;