Adding new project type (bpmn) creation button and loading fe a be and some changes for method PUT /project/{prj_uid} (still not functional)
This commit is contained in:
@@ -2340,7 +2340,7 @@ class G
|
||||
* @param string $parameter
|
||||
* @return string
|
||||
*/
|
||||
public function header ($parameter)
|
||||
public static function header ($parameter)
|
||||
{
|
||||
if (defined( 'ENABLE_ENCRYPT' ) && (ENABLE_ENCRYPT == 'yes') && (substr( $parameter, 0, 9 ) == 'location:')) {
|
||||
$url = G::encryptUrl( substr( $parameter, 10 ), URL_KEY );
|
||||
|
||||
@@ -26,59 +26,32 @@ class BpmnActivity extends BaseBpmnActivity
|
||||
$this->bound->setBouContainer('bpmnDiagram');
|
||||
}
|
||||
|
||||
/* DEPRECATED, IT WILL BE REMOVED SOON
|
||||
public function create($data, $generateUid = true)
|
||||
public function getBound()
|
||||
{
|
||||
// validate foreign keys, they must be present into data array
|
||||
|
||||
if (! array_key_exists('PRJ_UID', $data)) {
|
||||
throw new PropelException("Error, required param 'PRJ_UID' is missing!");
|
||||
}
|
||||
|
||||
if (! array_key_exists('PRO_UID', $data)) {
|
||||
throw new PropelException("Error, required param 'PRO_UID' is missing!");
|
||||
}
|
||||
|
||||
$this->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
if ($generateUid) {
|
||||
$this->setActUid(\ProcessMaker\Util\Hash::generateUID());
|
||||
}
|
||||
|
||||
$this->save();
|
||||
$process = BpmnProcessPeer::retrieveByPK($data['PRO_UID']);
|
||||
|
||||
// create related bound
|
||||
$bound = new Bound();
|
||||
$bound->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
$bound->setBouUid(\ProcessMaker\Util\Hash::generateUID());
|
||||
$bound->setPrjUid($this->getPrjUid());
|
||||
$bound->setDiaUid($process->getDiaUid());
|
||||
$bound->setElementUid($this->getActUid());
|
||||
$bound->setBouElementType('bpmnActivity');
|
||||
$bound->setBouElement('pm_canvas');
|
||||
$bound->setBouContainer('bpmnDiagram');
|
||||
$bound->save();
|
||||
}*/
|
||||
return $this->bound;
|
||||
}
|
||||
|
||||
|
||||
// OVERRIDES
|
||||
|
||||
public function fromArray($data)
|
||||
public function setActUid($actUid)
|
||||
{
|
||||
parent::fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
parent::setActUid($actUid);
|
||||
$this->bound->setElementUid($this->getActUid());
|
||||
}
|
||||
|
||||
// try resolve the related bound
|
||||
if (array_key_exists('BOU_UID', $data)) {
|
||||
//$bound = BpmnBound::findByElement('Activity', $this->getActUid());
|
||||
$bound = BpmnBoundPeer::retrieveByPK($data['BOU_UID']);
|
||||
public function setPrjUid($prjUid)
|
||||
{
|
||||
parent::setPrjUid($prjUid);
|
||||
$this->bound->setPrjUid($this->getPrjUid());
|
||||
}
|
||||
|
||||
if (is_object($bound)) {
|
||||
$this->bound = $bound;
|
||||
}
|
||||
}
|
||||
public function setProUid($proUid)
|
||||
{
|
||||
parent::setProUid($proUid);
|
||||
|
||||
$this->bound->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
$process = BpmnProcessPeer::retrieveByPK($this->getProUid());
|
||||
$this->bound->setDiaUid($process->getDiaUid());
|
||||
}
|
||||
|
||||
public function save($con = null)
|
||||
@@ -90,6 +63,32 @@ class BpmnActivity extends BaseBpmnActivity
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
// first, delete the related bound object
|
||||
if (is_object($this->bound) && get_class($this->bound) == 'BpmnBound') {
|
||||
$this->bound->delete($con);
|
||||
}
|
||||
|
||||
parent::delete($con);
|
||||
}
|
||||
|
||||
public function fromArray($data)
|
||||
{
|
||||
parent::fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
// try resolve the related bound
|
||||
$bound = BpmnBound::findByElement('Activity', $this->getActUid());
|
||||
|
||||
//if (array_key_exists('BOU_UID', $data)) {
|
||||
if (is_object($bound)) {
|
||||
//$bound = BpmnBoundPeer::retrieveByPK($data['BOU_UID']);
|
||||
$this->bound = $bound;
|
||||
}
|
||||
|
||||
$this->bound->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$data = parent::toArray($keyType);
|
||||
|
||||
@@ -645,13 +645,27 @@ class Process extends BaseProcess
|
||||
$casesCnt = $this->getCasesCountInAllProcesses();
|
||||
}
|
||||
|
||||
// getting bpmn projects
|
||||
$c = new Criteria('workflow');
|
||||
$c->addSelectColumn(BpmnProjectPeer::PRJ_UID);
|
||||
$ds = ProcessPeer::doSelectRS($c);
|
||||
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$bpmnProjects = array();
|
||||
|
||||
while ($ds->next()) {
|
||||
$row = $ds->getRow();
|
||||
$bpmnProjects[] = $row['PRJ_UID'];
|
||||
}
|
||||
|
||||
//execute the query
|
||||
$oDataset = ProcessPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$processes = Array ();
|
||||
$uids = array ();
|
||||
while ($oDataset->next()) {
|
||||
$processes[] = $oDataset->getRow();
|
||||
$row = $oDataset->getRow();
|
||||
$row['PROJECT_TYPE'] = in_array($row['PRO_UID'], $bpmnProjects) ? 'bpmn' : 'classic';
|
||||
$processes[] = $row;
|
||||
$uids[] = $processes[sizeof( $processes ) - 1]['PRO_UID'];
|
||||
}
|
||||
|
||||
|
||||
@@ -37,56 +37,74 @@ class ProcessProxy extends HttpProxyController
|
||||
*/
|
||||
public function saveProcess ($httpData)
|
||||
{
|
||||
$projectType = empty($_GET['type']) ? 'classicProject' : $_GET['type'];
|
||||
|
||||
require_once 'classes/model/Task.php';
|
||||
G::LoadClass( 'processMap' );
|
||||
$oProcessMap = new ProcessMap();
|
||||
|
||||
$httpData->PRO_TITLE = trim( $httpData->PRO_TITLE );
|
||||
|
||||
if (! isset( $httpData->PRO_UID )) {
|
||||
try {
|
||||
if (! isset( $httpData->PRO_UID )) {
|
||||
if (Process::existsByProTitle( $httpData->PRO_TITLE )) {
|
||||
$result = array ('success' => false,'msg' => G::LoadTranslation( 'ID_SAVE_PROCESS_ERROR' ),'errors' => array ('PRO_TITLE' => G::LoadTranslation( 'ID_PROCESSTITLE_ALREADY_EXISTS', SYS_LANG, Array ('PRO_TITLE' => $httpData->PRO_TITLE
|
||||
) )
|
||||
)
|
||||
);
|
||||
print G::json_encode( $result );
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
if (Process::existsByProTitle( $httpData->PRO_TITLE )) {
|
||||
$result = array ('success' => false,'msg' => G::LoadTranslation( 'ID_SAVE_PROCESS_ERROR' ),'errors' => array ('PRO_TITLE' => G::LoadTranslation( 'ID_PROCESSTITLE_ALREADY_EXISTS', SYS_LANG, Array ('PRO_TITLE' => $httpData->PRO_TITLE
|
||||
) )
|
||||
)
|
||||
);
|
||||
print G::json_encode( $result );
|
||||
exit( 0 );
|
||||
$processData['USR_UID'] = $_SESSION['USER_LOGGED'];
|
||||
$processData['PRO_TITLE'] = $httpData->PRO_TITLE;
|
||||
$processData['PRO_DESCRIPTION'] = $httpData->PRO_DESCRIPTION;
|
||||
$processData['PRO_CATEGORY'] = $httpData->PRO_CATEGORY;
|
||||
|
||||
$sProUid = $oProcessMap->createProcess( $processData );
|
||||
|
||||
//call plugins
|
||||
$oData['PRO_UID'] = $sProUid;
|
||||
$oData['PRO_TEMPLATE'] = isset( $httpData->PRO_TEMPLATE ) && $httpData->PRO_TEMPLATE != '' ? $httpData->PRO_TEMPLATE : '';
|
||||
$oData['PROCESSMAP'] = $oProcessMap;
|
||||
|
||||
$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
||||
$oPluginRegistry->executeTriggers( PM_NEW_PROCESS_SAVE, $oData );
|
||||
|
||||
} else {
|
||||
//$oProcessMap->updateProcess($_POST['form']);
|
||||
$sProUid = $httpData->PRO_UID;
|
||||
}
|
||||
|
||||
$processData['USR_UID'] = $_SESSION['USER_LOGGED'];
|
||||
$processData['PRO_TITLE'] = $httpData->PRO_TITLE;
|
||||
$processData['PRO_DESCRIPTION'] = $httpData->PRO_DESCRIPTION;
|
||||
$processData['PRO_CATEGORY'] = $httpData->PRO_CATEGORY;
|
||||
//Save Calendar ID for this process
|
||||
if (isset( $httpData->PRO_CALENDAR )) {
|
||||
G::LoadClass( "calendar" );
|
||||
$calendarObj = new Calendar();
|
||||
$calendarObj->assignCalendarTo( $sProUid, $httpData->PRO_CALENDAR, 'PROCESS' );
|
||||
}
|
||||
|
||||
$sProUid = $oProcessMap->createProcess( $processData );
|
||||
// Creating BPMN Project Layer
|
||||
if ($projectType == 'bpmnProject') {
|
||||
$bpmnModel = new ProcessMaker\Adapter\Bpmn\Model();
|
||||
$replaceUids = false;
|
||||
|
||||
//call plugins
|
||||
$oData['PRO_UID'] = $sProUid;
|
||||
$oData['PRO_TEMPLATE'] = isset( $httpData->PRO_TEMPLATE ) && $httpData->PRO_TEMPLATE != '' ? $httpData->PRO_TEMPLATE : '';
|
||||
$oData['PROCESSMAP'] = $oProcessMap;
|
||||
$data = array(
|
||||
'PRJ_UID' => $sProUid,
|
||||
'PRJ_NAME' => $httpData->PRO_TITLE,
|
||||
'PRJ_DESCRIPTION' => $httpData->PRO_DESCRIPTION,
|
||||
'PRJ_CATEGORY' => $httpData->PRO_CATEGORY
|
||||
);
|
||||
|
||||
$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
||||
$oPluginRegistry->executeTriggers( PM_NEW_PROCESS_SAVE, $oData );
|
||||
$result = $bpmnModel->createProject($data, $replaceUids);
|
||||
}
|
||||
|
||||
} else {
|
||||
//$oProcessMap->updateProcess($_POST['form']);
|
||||
$sProUid = $httpData->PRO_UID;
|
||||
$this->success = true;
|
||||
$this->PRO_UID = $sProUid;
|
||||
$this->msg = G::LoadTranslation( 'ID_CREATE_PROCESS_SUCCESS' );
|
||||
} catch (Exception $e) {
|
||||
$this->success = false;
|
||||
$this->msg = $e->getMessage();
|
||||
}
|
||||
|
||||
//Save Calendar ID for this process
|
||||
if (isset( $httpData->PRO_CALENDAR )) {
|
||||
G::LoadClass( "calendar" );
|
||||
$calendarObj = new Calendar();
|
||||
$calendarObj->assignCalendarTo( $sProUid, $httpData->PRO_CALENDAR, 'PROCESS' );
|
||||
}
|
||||
|
||||
$this->success = true;
|
||||
$this->PRO_UID = $sProUid;
|
||||
$this->msg = G::LoadTranslation( 'ID_CREATE_PROCESS_SUCCESS' );
|
||||
|
||||
//TODO save bpmn project
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
16
workflow/engine/methods/processes/openDesigner.php
Normal file
16
workflow/engine/methods/processes/openDesigner.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
if (! array_key_exists('pro_uid', $_REQUEST)) {
|
||||
die('Bad Request: The param "pro_uid" is required!');
|
||||
}
|
||||
|
||||
$proUid = $_GET['pro_uid'];
|
||||
$bpmnProject = BpmnProjectPeer::retrieveByPK($proUid);
|
||||
|
||||
|
||||
if (is_object($bpmnProject)) {
|
||||
$url = '../designer?pro_uid=' . $proUid;
|
||||
} else {
|
||||
$url = 'processes_Map?PRO_UID=' . $proUid;
|
||||
}
|
||||
|
||||
G::header("location: $url");
|
||||
File diff suppressed because it is too large
Load Diff
@@ -33,18 +33,31 @@ class Project extends Api
|
||||
function post($request_data)
|
||||
{
|
||||
try {
|
||||
$bpmnModel = new BpmnModel();
|
||||
$uids = $bpmnModel->createProject($request_data);
|
||||
$config = array();
|
||||
$config['project'] = array('replace_uids' => true);
|
||||
|
||||
$wfProcess = Workflow::loadFromBpmnProject($uids[0]['new_uid']);
|
||||
$bpmnModel = new BpmnModel();
|
||||
$result = $bpmnModel->createProject($request_data, $config['project']['replace_uids']);
|
||||
|
||||
if (array_key_exists('prj_uid', $result)) {
|
||||
$prjUid = $result['prj_uid'];
|
||||
} else {
|
||||
$prjUid = $result[0]['new_uid'];
|
||||
}
|
||||
|
||||
$wfProcess = Workflow::loadFromBpmnProject($prjUid);
|
||||
|
||||
$process = new \BusinessModel\Process();
|
||||
$userUid = $this->getUserId();
|
||||
$data = array('process' => $wfProcess);
|
||||
|
||||
$process->createProcess($userUid, $data);
|
||||
|
||||
return $uids;
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
// TODO in case that $process->createProcess($userUid, $data); fails maybe the BPMN project was created successfully
|
||||
// so, we need remove it or change the creation order.
|
||||
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ Ext.onReady(function(){
|
||||
{name : 'CASES_COUNT_DRAFT', type:'float'},
|
||||
{name : 'CASES_COUNT_TO_DO', type:'float'},
|
||||
{name : 'CASES_COUNT_COMPLETED', type:'float'},
|
||||
{name : 'CASES_COUNT_CANCELLED', type:'float'}
|
||||
{name : 'CASES_COUNT_CANCELLED', type:'float'},
|
||||
{name : 'PROJECT_TYPE', type:'string'}
|
||||
]
|
||||
}),
|
||||
|
||||
@@ -197,7 +198,13 @@ Ext.onReady(function(){
|
||||
{id:'PRO_UID', dataIndex: 'PRO_UID', hidden:true, hideable:false},
|
||||
{header: "", dataIndex: 'PRO_STATUS', width: 50, hidden:true, hideable:false},
|
||||
{header: _('ID_PRO_DESCRIPTION'), dataIndex: 'PRO_DESCRIPTION',hidden:true, hideable:false},
|
||||
{header: _('ID_PRO_TITLE'), dataIndex: 'PRO_TITLE', width: 300},
|
||||
{header: _('ID_PRO_TITLE'), dataIndex: 'PRO_TITLE', width: 300, renderer:function(v,p,r){
|
||||
// TODO Labels for var 'type' are hardcoded, they must be replaced on the future
|
||||
var color = r.get('PROJECT_TYPE') == 'bpmn'? 'green': 'blue';
|
||||
var type = r.get('PROJECT_TYPE') == 'bpmn'? ' (BPMN Project)': '';
|
||||
return v + ' ' + String.format("<font color='{0}'>{1}</font>", color, type);
|
||||
}},
|
||||
{header: _('ID_TYPE'), dataIndex: 'PROJECT_TYPE', width: 60, hidden:false},
|
||||
{header: _('ID_CATEGORY'), dataIndex: 'PRO_CATEGORY_LABEL', width: 100, hidden:false},
|
||||
{header: _('ID_STATUS'), dataIndex: 'PRO_STATUS_LABEL', width: 50, renderer:function(v,p,r){
|
||||
color = r.get('PRO_STATUS') == 'ACTIVE'? 'green': 'red';
|
||||
@@ -215,24 +222,52 @@ Ext.onReady(function(){
|
||||
}),
|
||||
store: store,
|
||||
tbar:[
|
||||
{
|
||||
xtype: 'tbsplit',
|
||||
text: _('ID_NEW'),
|
||||
iconCls: 'button_menu_ext ss_sprite ss_add',
|
||||
menu: [
|
||||
{
|
||||
text: "New Project",
|
||||
iconCls: 'silk-add',
|
||||
icon: '/images/delete-16x16.gif',
|
||||
handler: function () {
|
||||
newProcess({type:"bpmnProject"});
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "New Project (Old Version)",
|
||||
iconCls: 'silk-add',
|
||||
icon: '/images/delete-16x16.gif',
|
||||
handler: function () {
|
||||
newProcess({type:"classicProject"});
|
||||
}
|
||||
}
|
||||
],
|
||||
listeners: {
|
||||
"click": function (obj, e) {
|
||||
obj.showMenu();
|
||||
}
|
||||
}
|
||||
},/*
|
||||
{
|
||||
text: _('ID_NEW'),
|
||||
iconCls: 'button_menu_ext ss_sprite ss_add',
|
||||
//icon: '/images/addc.png',
|
||||
handler: newProcess
|
||||
},
|
||||
},*/
|
||||
'-'
|
||||
,{
|
||||
text: _('ID_EDIT'),
|
||||
iconCls: 'button_menu_ext ss_sprite ss_pencil',
|
||||
//icon: '/images/edit.gif',
|
||||
handler: editProcess
|
||||
},{
|
||||
},/*{
|
||||
text: 'Edit (New Editor)',
|
||||
iconCls: 'button_menu_ext',
|
||||
icon: '/images/pencil_beta.png',
|
||||
handler: editNewProcess
|
||||
},{
|
||||
},*/{
|
||||
text: _('ID_STATUS'),
|
||||
id:'activator',
|
||||
icon: '',
|
||||
@@ -412,8 +447,14 @@ Ext.onReady(function(){
|
||||
});
|
||||
|
||||
|
||||
function newProcess(){
|
||||
// window.location = 'processes_New';
|
||||
function newProcess(params)
|
||||
{
|
||||
params = typeof params == 'undefined' ? {type:'classicProject'} : params;
|
||||
|
||||
// TODO this variable have hardcoded labels, it must be changed on the future
|
||||
var formTitle = params.type == "classicProject" ? "New Project (Old Version)" : "New Project"
|
||||
|
||||
// window.location = 'processes_New';
|
||||
var ProcessCategories = new Ext.form.ComboBox({
|
||||
fieldLabel : _('ID_CATEGORY'),
|
||||
hiddenName : 'PRO_CATEGORY',
|
||||
@@ -445,7 +486,6 @@ function newProcess(){
|
||||
ProcessCategories.setValue(store.getAt(0).get('CATEGORY_UID'));
|
||||
});
|
||||
|
||||
|
||||
var frm = new Ext.FormPanel( {
|
||||
id: 'newProcessForm',
|
||||
labelAlign : 'right',
|
||||
@@ -487,27 +527,35 @@ function newProcess(){
|
||||
});
|
||||
|
||||
var win = new Ext.Window({
|
||||
title: _('ID_CREATE_PROCESS'),
|
||||
id: 'newProjectWin',
|
||||
title: formTitle, //_('ID_CREATE_PROCESS'),
|
||||
width: 470,
|
||||
height: 220,
|
||||
layout:'fit',
|
||||
autoScroll:true,
|
||||
modal: true,
|
||||
maximizable: false,
|
||||
items: [frm]
|
||||
items: [frm],
|
||||
_projectType: params.type
|
||||
});
|
||||
win.show();
|
||||
}
|
||||
|
||||
function saveProcess()
|
||||
{
|
||||
var projectType = Ext.getCmp('newProjectWin')._projectType;
|
||||
|
||||
Ext.getCmp('newProcessForm').getForm().submit( {
|
||||
url : '../processProxy/saveProcess',
|
||||
url : '../processProxy/saveProcess?type=' + projectType,
|
||||
waitMsg : _('ID_SAVING_PROCESS'),
|
||||
waitTitle : " ",
|
||||
timeout : 36000,
|
||||
success : function(obj, resp) {
|
||||
location.href = 'processes_Map?PRO_UID='+resp.result.PRO_UID;
|
||||
if (projectType == 'classicProject') {
|
||||
location.href = 'processes_Map?PRO_UID='+resp.result.PRO_UID;
|
||||
} else {
|
||||
location.href = '../designer?pro_uid='+resp.result.PRO_UID;
|
||||
}
|
||||
},
|
||||
failure: function(obj, resp) {
|
||||
PMExt.error( _('ID_ERROR'), resp.result.msg);
|
||||
@@ -527,7 +575,8 @@ function doSearch(){
|
||||
editProcess = function(){
|
||||
var rowSelected = processesGrid.getSelectionModel().getSelected();
|
||||
if( rowSelected ) {
|
||||
location.href = 'processes_Map?PRO_UID='+rowSelected.data.PRO_UID+'&rand='+Math.random()
|
||||
//location.href = 'processes_Map?PRO_UID='+rowSelected.data.PRO_UID+'&rand='+Math.random()
|
||||
location.href = 'openDesigner?pro_uid='+rowSelected.data.PRO_UID+'&rand='+Math.random()
|
||||
} else {
|
||||
Ext.Msg.show({
|
||||
title:'',
|
||||
|
||||
Reference in New Issue
Block a user