mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-31 22:17:33 +00:00
add saving and reloading layout data
This commit is contained in:
parent
84a65f0f32
commit
bdd0dd6582
|
@ -152,6 +152,8 @@ else if ($action == "setrenderdata") {
|
||||||
|
|
||||||
$data = $_POST["data"];
|
$data = $_POST["data"];
|
||||||
|
|
||||||
|
$workflow->setLayoutData($data);
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode(array('success'=>true, 'message'=>getMLText("workflow_layoutdata_saved")));
|
echo json_encode(array('success'=>true, 'message'=>getMLText("workflow_layoutdata_saved")));
|
||||||
exit;
|
exit;
|
||||||
|
|
|
@ -35,7 +35,16 @@ class SeedDMS_View_WorkflowGraph extends SeedDMS_Bootstrap_Style {
|
||||||
$this->workflow = $this->params['workflow'];
|
$this->workflow = $this->params['workflow'];
|
||||||
header('Content-Type: application/javascript; charset=UTF-8');
|
header('Content-Type: application/javascript; charset=UTF-8');
|
||||||
|
|
||||||
$renderdata = '';
|
$renderdata = $this->workflow->getLayoutData();
|
||||||
|
if($renderdata) {
|
||||||
|
$positions = array();
|
||||||
|
$data = json_decode($renderdata);
|
||||||
|
foreach($data->nodes as $node) {
|
||||||
|
if($node->group == 'nodes') {
|
||||||
|
$positions[$node->data->id] = $node->position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
var cy = cytoscape({
|
var cy = cytoscape({
|
||||||
container: document.getElementById('canvas'),
|
container: document.getElementById('canvas'),
|
||||||
|
@ -106,7 +115,7 @@ var cy = cytoscape({
|
||||||
'curve-style': 'bezier'
|
'curve-style': 'bezier'
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
<?php if($renderdata) echo ",".$renderdata; ?>
|
<?php //if($renderdata) echo ",elements: ".$renderdata; ?>
|
||||||
}
|
}
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -139,11 +148,9 @@ cy.on('free', 'node', function(evt) {
|
||||||
$('#png').attr('src', cy.png({'full': true}));
|
$('#png').attr('src', cy.png({'full': true}));
|
||||||
});
|
});
|
||||||
<?php
|
<?php
|
||||||
if(!$renderdata)
|
$this->printGraph($positions);
|
||||||
$this->printGraph();
|
|
||||||
?>
|
?>
|
||||||
cy.layout({ name: '<?php echo $renderdata ? 'preset' : 'cose'; ?>', condense: true, ready: function() {$('#png').attr('src', cy.png({'full': true}))} });
|
cy.layout({ name: '<?php echo $renderdata ? 'preset' : 'cose'; ?>', ready: function() {$('#png').attr('src', cy.png({'full': true}))} });
|
||||||
// $('#png').attr('src', cy.png({'full': true}));
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('body').on('click', '#savelayout', function(ev){
|
$('body').on('click', '#savelayout', function(ev){
|
||||||
|
@ -159,7 +166,7 @@ $(document).ready(function() {
|
||||||
<?php
|
<?php
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function printGraph() { /* {{{ */
|
function printGraph($positions) { /* {{{ */
|
||||||
$transitions = $this->workflow->getTransitions();
|
$transitions = $this->workflow->getTransitions();
|
||||||
if($transitions) {
|
if($transitions) {
|
||||||
|
|
||||||
|
@ -198,13 +205,15 @@ $(document).ready(function() {
|
||||||
foreach($transgroups as $transgroup) {
|
foreach($transgroups as $transgroup) {
|
||||||
$gnames[] = $transgroup->getGroup()->getName();
|
$gnames[] = $transgroup->getGroup()->getName();
|
||||||
}
|
}
|
||||||
|
$nodeid = "A".$transition->getID()."-".$action->getID();
|
||||||
echo "cy.add({
|
echo "cy.add({
|
||||||
data: {
|
data: {
|
||||||
id: 'A".$transition->getID()."-".$action->getID()."',
|
id: '".$nodeid."',
|
||||||
name: \"".str_replace('"', "\\\"", $action->getName()).($unames ? "\\n(".str_replace('"', "\\\"", implode(", ", $unames)).")" : '').($gnames ? "\\n(".str_replace('"', "\\\"", implode(", ", $gnames)).")" : '')."\"
|
name: \"".str_replace('"', "\\\"", $action->getName()).($unames ? "\\n(".str_replace('"', "\\\"", implode(", ", $unames)).")" : '').($gnames ? "\\n(".str_replace('"', "\\\"", implode(", ", $gnames)).")" : '')."\"
|
||||||
},
|
},".(isset($positions[$nodeid]) ? "
|
||||||
classes: 'action'
|
position: {x: ".$positions[$nodeid]->x.", y: ".$positions[$nodeid]->y."}," : "")."
|
||||||
});\n";
|
classes: 'action'
|
||||||
|
});\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($this->states[$state->getID()])) {
|
if(!isset($this->states[$state->getID()])) {
|
||||||
|
@ -212,24 +221,28 @@ $(document).ready(function() {
|
||||||
$initstate = '';
|
$initstate = '';
|
||||||
if($state == $this->workflow->getInitState())
|
if($state == $this->workflow->getInitState())
|
||||||
$initstate = getMLText('workflow_initstate');
|
$initstate = getMLText('workflow_initstate');
|
||||||
|
$nodeid = "S".$state->getID();
|
||||||
echo "cy.add({
|
echo "cy.add({
|
||||||
data: {
|
data: {
|
||||||
id: 'S".$state->getID()."',
|
id: '".$nodeid."',
|
||||||
name: \"".str_replace('"', "\\\"", $state->getName()."\\n".$initstate)."\"
|
name: \"".str_replace('"', "\\\"", $state->getName()."\\n".$initstate)."\"
|
||||||
},
|
},".(isset($positions[$nodeid]) ? "
|
||||||
classes: 'state ".($state == $this->workflow->getInitState() ? 'init' : '')."'
|
position: {x: ".$positions[$nodeid]->x.", y: ".$positions[$nodeid]->y."}," : "")."
|
||||||
});\n";
|
classes: 'state ".($state == $this->workflow->getInitState() ? 'init' : '')."'
|
||||||
|
});\n";
|
||||||
}
|
}
|
||||||
if(!isset($this->states[$nextstate->getID()])) {
|
if(!isset($this->states[$nextstate->getID()])) {
|
||||||
$this->states[$nextstate->getID()] = $nextstate;
|
$this->states[$nextstate->getID()] = $nextstate;
|
||||||
$docstatus = $nextstate->getDocumentStatus();
|
$docstatus = $nextstate->getDocumentStatus();
|
||||||
|
$nodeid = "S".$nextstate->getID();
|
||||||
echo "cy.add({
|
echo "cy.add({
|
||||||
data: {
|
data: {
|
||||||
id: 'S".$nextstate->getID()."',
|
id: '".$nodeid."',
|
||||||
name: '".str_replace('"', "\\\"", $nextstate->getName())/*.($docstatus == S_RELEASED || $docstatus == S_REJECTED ? "\\n(".getOverallStatusText($docstatus).")" : '')*/."'
|
name: '".str_replace('"', "\\\"", $nextstate->getName())/*.($docstatus == S_RELEASED || $docstatus == S_REJECTED ? "\\n(".getOverallStatusText($docstatus).")" : '')*/."'
|
||||||
},
|
},".(isset($positions[$nodeid]) ? "
|
||||||
classes: 'state".($docstatus == S_RELEASED ? ' released' : ($docstatus == S_REJECTED ? ' rejected' : ''))."'
|
position: {x: ".$positions[$nodeid]->x.", y: ".$positions[$nodeid]->y."}," : "")."
|
||||||
});\n";
|
classes: 'state".($docstatus == S_RELEASED ? ' released' : ($docstatus == S_REJECTED ? ' rejected' : ''))."'
|
||||||
|
});\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user