users assignment (continue)

This commit is contained in:
Erik Amaru Ortiz
2011-02-22 23:22:50 +00:00
parent ea617b4f07
commit 282c491797
5 changed files with 601 additions and 195 deletions

View File

@@ -147,4 +147,61 @@ class TaskUser extends BaseTaskUser {
return $aRows; return $aRows;
} }
//erik: new functions
function getUsersTask($TAS_UID, $TU_TYPE=1){
require_once 'classes/model/Users.php';
$groupsTask = array();
$usersTask = array();
//getting task's users
$criteria = new Criteria('workflow');
$criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
$criteria->addSelectColumn(UsersPeer::USR_LASTNAME);
$criteria->addSelectColumn(UsersPeer::USR_USERNAME);
$criteria->addSelectColumn(TaskUserPeer::TAS_UID);
$criteria->addSelectColumn(TaskUserPeer::USR_UID);
$criteria->addSelectColumn(TaskUserPeer::TU_TYPE);
$criteria->addSelectColumn(TaskUserPeer::TU_RELATION);
$criteria->addJoin(TaskUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
$criteria->add(TaskUserPeer::TAS_UID, $TAS_UID);
$criteria->add(TaskUserPeer::TU_TYPE, $TU_TYPE);
$criteria->add(TaskUserPeer::TU_RELATION, 1);
$dataset = TaskUserPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($dataset->next())
$usersTask[] = $dataset->getRow();
//getting task's groups
$delimiter = DBAdapter::getStringDelimiter ();
$criteria = new Criteria('workflow');
$criteria->addAsColumn('GRP_TITLE', 'CONTENT.CON_VALUE');
$criteria->addSelectColumn(TaskUserPeer::TAS_UID);
$criteria->addSelectColumn(TaskUserPeer::USR_UID);
$criteria->addSelectColumn(TaskUserPeer::TU_TYPE);
$criteria->addSelectColumn(TaskUserPeer::TU_RELATION);
$aConditions[] = array(TaskUserPeer::USR_UID, 'CONTENT.CON_ID');
$aConditions[] = array('CONTENT.CON_CATEGORY', $delimiter . 'GRP_TITLE' . $delimiter);
$aConditions[] = array('CONTENT.CON_LANG', $delimiter . SYS_LANG . $delimiter);
$criteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
$criteria->add(TaskUserPeer::TAS_UID, $TAS_UID);
$criteria->add(TaskUserPeer::TU_TYPE, $TU_TYPE);
$criteria->add(TaskUserPeer::TU_RELATION, 2);
$dataset = TaskUserPeer::doSelectRS($criteria);
$dataset = TaskUserPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while( $dataset->next() )
$usersTask[] = $dataset->getRow();
$result->data = $usersTask;
$result->totalCount = sizeof($usersTask);
return $result;
}
} // TaskUser } // TaskUser

View File

@@ -150,12 +150,10 @@ class Ajax
{ {
require_once 'classes/model/Users.php'; require_once 'classes/model/Users.php';
G::LoadClass('configuration'); G::LoadClass('configuration');
$search = isset($params['search']) ? $params['search']: null;
$users = Users::getAll($params['start'], $params['limit'], $search);
$conf = new Configurations; $conf = new Configurations;
$search = isset($params['search']) ? $params['search']: null;
$users = Users::getAll($params['start'], $params['limit'], $search);
foreach($users->data as $i=>$user){ foreach($users->data as $i=>$user){
$users->data[$i]['USER'] = $conf->getEnvSetting( $users->data[$i]['USER'] = $conf->getEnvSetting(
@@ -178,7 +176,125 @@ class Ajax
print G::json_encode($groups); print G::json_encode($groups);
} }
function assignUsersTask($param)
{
try{
require_once 'classes/model/TaskUser.php';
$oTaskUser = new TaskUser();
$UIDS = explode(',', $param['UIDS']);
$TU_TYPE = 1;
foreach( $UIDS as $UID ) {
if ($_POST['TU_RELATION'] == 1 )
$oTaskUser->create(array('TAS_UID' => $param['TAS_UID'], 'USR_UID' => $UID, 'TU_TYPE' => $TU_TYPE, 'TU_RELATION' => 1));
else
$oTaskUser->create(array('TAS_UID' => $param['TAS_UID'], 'USR_UID' => $UID, 'TU_TYPE' => $TU_TYPE, 'TU_RELATION' => 2));
}
$result->success = true;
$result->msg = '';
} catch(Exception $e){
$result->success = false;
$result->msg = $e->getMessage();
}
print G::json_encode($result);
}
function removeUsersTask($param)
{
try{
require_once 'classes/model/TaskUser.php';
$oTaskUser = new TaskUser();
$USR_UIDS = explode(',', $param['USR_UID']);
$TU_RELATIONS = explode(',', $param['TU_RELATION']);
$TU_TYPE = 1;
foreach($USR_UIDS as $i=>$USR_UID) {
if ($TU_RELATIONS[$i] == 1 ){
$oTaskUser->remove($param['TAS_UID'], $USR_UID, $TU_TYPE, 1);
} else {
$oTaskUser->remove($param['TAS_UID'], $USR_UID, $TU_TYPE, 2);
}
}
$result->success = true;
$result->msg = '';
} catch(Exception $e){
$result->success = false;
$result->msg = "{$TU_RELATIONS[$i]} - {$param['TAS_UID']}, {$USR_UIDS[$i]}, $TU_TYPE, 1 --> " . $e->getMessage();
}
print G::json_encode($result);
}
function getUsersTask($param)
{
require_once 'classes/model/TaskUser.php';
G::LoadClass('configuration');
$usersTaskList = Array();
$task = new TaskUser;
$conf = new Configurations;
$TU_TYPE = 1;
$usersTask = $task->getUsersTask($param['TAS_UID'], $TU_TYPE);
foreach($usersTask->data as $userTask) {
$usersTaskListItem['TAS_UID'] = $userTask['TAS_UID'];
if( $userTask['TU_RELATION'] == 1 )
$usersTaskListItem['NAME'] = $conf->getEnvSetting(
'format',
Array(
'userName'=>$userTask['USR_USERNAME'],
'firstName'=>$userTask['USR_FIRSTNAME'],
'lastName'=>$userTask['USR_LASTNAME']
)
);
else
$usersTaskListItem['NAME'] = $userTask['GRP_TITLE'];
$usersTaskListItem['TU_RELATION'] = $userTask['TU_RELATION'];
$usersTaskListItem['USR_UID'] = $userTask['USR_UID'];
$usersTaskList[] = $usersTaskListItem;
}
$result->data = $usersTaskList;
$result->totalCount = $usersTask->totalCount;
print G::json_encode($result);
}
function getProcessDetail($param){
require_once 'classes/model/Process.php';
$PRO_UID = $param['PRO_UID'];
G::loadClass('tasks');
$tasks = new Tasks();
$process = ProcessPeer::retrieveByPk($PRO_UID);
$tasksList = $tasks->getAllTasks($PRO_UID);
$rootNode->id = $process->getProUid();
$rootNode->text = $process->getProTitle();
$rootNode->leaf = false;
$rootNode->expanded =true;
foreach($tasksList as $task) {
$node = new stdClass;
$node->id = $task['TAS_UID'];
$node->text = $task['TAS_TITLE'];
$node->leaf = true;
$rootNode->children[] = $node;
}
$treeDetail[] = $rootNode;
print G::json_encode($treeDetail);
}
} }

View File

@@ -225,6 +225,8 @@ Figure.prototype.onDragend=function() {
case 'bpmnSubProcess': case 'bpmnSubProcess':
currObj.actiontype = 'saveTaskPosition'; currObj.actiontype = 'saveTaskPosition';
currObj.workflow.savePosition(currObj); currObj.workflow.savePosition(currObj);
break; break;
case 'bpmnAnnotation': case 'bpmnAnnotation':
currObj.actiontype = 'saveTextPosition'; currObj.actiontype = 'saveTextPosition';
@@ -969,8 +971,9 @@ bpmnTask.prototype.onDoubleClick = function () {
* erik: Setting task target to Drop user & group assignment * erik: Setting task target to Drop user & group assignment
*/ */
bpmnTask.prototype.onMouseEnter = function () { bpmnTask.prototype.onMouseEnter = function () {
if( this.type == 'bpmnTask' && typeof(Ext.getCmp('usersPanel')) != 'undefined' ) if( this.type == 'bpmnTask' && typeof Ext.getCmp('usersPanel') != 'undefined' ) {
Ext.getCmp('usersPanel')._targetTask = this.id; Ext.getCmp('usersPanel')._targetTask = {id: this.id, name: this.taskName};
}
}; };
bpmnTask.prototype.trim = function (str) { bpmnTask.prototype.trim = function (str) {

View File

@@ -10,6 +10,7 @@ new Ext.KeyMap(document, {
var saveProcess; var saveProcess;
var usersPanel; var usersPanel;
var _TAS_UID;
Ext.onReady ( function() { Ext.onReady ( function() {
workflow = new MyWorkflow("paintarea"); workflow = new MyWorkflow("paintarea");
@@ -131,8 +132,8 @@ Ext.onReady ( function() {
region : "center", region : "center",
layout : "border", layout : "border",
autoScroll: true, autoScroll: true,
height : 1000, height : 1360,
width : PMExt.getBrowser().screen.width, width : 1280, //PMExt.getBrowser().screen.width,
//items : [west, north, center] //items : [west, north, center]
items : [north, center] items : [north, center]
}); });
@@ -196,7 +197,6 @@ Ext.onReady ( function() {
border:true, border:true,
shim: true, shim: true,
plugin: new Ext.ux.WindowAlwaysOnTop,
items: [toolbarPanel] items: [toolbarPanel]
/*html: '<div id="x-shapes">\n\ /*html: '<div id="x-shapes">\n\
<p id="x-shapes-task" class="toolbar-item"><img src= "/skins/ext/images/gray/shapes/pallete/task.png"/></p>\n\ <p id="x-shapes-task" class="toolbar-item"><img src= "/skins/ext/images/gray/shapes/pallete/task.png"/></p>\n\
@@ -268,7 +268,7 @@ Ext.onReady ( function() {
//// ////
usersPanelStart = 0; usersPanelStart = 0;
usersPanelLimit = 11; usersPanelLimit = 10;
var usersStore = new Ext.data.Store( { var usersStore = new Ext.data.Store( {
autoLoad: true, autoLoad: true,
@@ -289,30 +289,24 @@ Ext.onReady ( function() {
}); });
var usersGrid = new Ext.grid.GridPanel({ var usersGrid = new Ext.grid.GridPanel({
id: 'usersGrid', id : 'usersGrid',
title : 'Users', title : 'Users',
height : 180,
stateful : true, stateful : true,
stateId : 'usersGrid', stateId : 'usersGrid',
enableColumnResize: true, ddGroup : 'task-assignment',
enableHdMenu: true, enableDragDrop : true,
//frame:false, viewConfig : {
//columnLines: true, forceFit : true
ddGroup : 'task-assignment',
enableDragDrop: true,
viewConfig: {
forceFit:true
}, },
cm : new Ext.grid.ColumnModel({
cm: new Ext.grid.ColumnModel({
defaults: { defaults: {
width: 200, width: 200,
sortable: true sortable: true
}, },
columns: [ columns : [
{header: 'USR_UID', id:'USR_UID', dataIndex: 'USR_UID', hidden:true, hideable:false}, {header: 'USR_UID', id:'USR_UID', dataIndex: 'USR_UID', hidden:true, hideable:false},
{header: 'USER', dataIndex: 'USER', width: 300, renderer:function(v,p,r){ {header: 'User', dataIndex: 'USER', width: 300}
return v; //String.format("<font color='green'>{0}</font>", v);
}}
] ]
}), }),
store: usersStore, store: usersStore,
@@ -322,23 +316,22 @@ Ext.onReady ( function() {
} }
}, },
tbar:[ tbar:[
//'->',
new Ext.form.TextField ({ new Ext.form.TextField ({
id: 'usersSearchTxt', id : 'usersSearchTxt',
ctCls:'pm_search_text_field', ctCls :'pm_search_text_field',
allowBlank: true, width : 220,
width: 230, allowBlank : true,
emptyText: _('ID_ENTER_SEARCH_TERM'),//'enter search term', emptyText : _('ID_ENTER_SEARCH_TERM'),
listeners: { listeners : {
specialkey: function(f,e){ specialkey: function(f,e){
if (e.getKey() == e.ENTER) if (e.getKey() == e.ENTER)
usersSearch(); usersSearch();
} }
} }
}),{ }),{
text:'X', text : 'X',
ctCls:'pm_search_x_button', ctCls : 'pm_search_x_button',
handler: function(){ handler : function(){
usersStore.setBaseParam( 'search', ''); usersStore.setBaseParam( 'search', '');
usersStore.load({params:{start : 0 , limit : usersPanelLimit}}); usersStore.load({params:{start : 0 , limit : usersPanelLimit}});
Ext.getCmp('usersSearchTxt').setValue(''); Ext.getCmp('usersSearchTxt').setValue('');
@@ -349,15 +342,14 @@ Ext.onReady ( function() {
} }
], ],
bbar: [new Ext.PagingToolbar({ bbar: [new Ext.PagingToolbar({
pageSize: usersPanelLimit, pageSize : usersPanelLimit,
store: usersStore, store : usersStore,
displayInfo: true, displayInfo: true,
displayMsg: '{0} - {1} of {2}', displayMsg : '{2} Users',
emptyMsg: "" emptyMsg : ''
})] })]
}); });
var groupsStore = new Ext.data.Store( { var groupsStore = new Ext.data.Store( {
autoLoad: true, autoLoad: true,
proxy : new Ext.data.HttpProxy({ proxy : new Ext.data.HttpProxy({
@@ -374,104 +366,91 @@ Ext.onReady ( function() {
}); });
var groupsGrid = new Ext.grid.GridPanel({ var groupsGrid = new Ext.grid.GridPanel({
id: 'groupsGrid', id : 'groupsGrid',
title : 'Groups', title : 'Groups',
stateful : true, stateful : true,
stateId : 'groupsGrid', stateId : 'groupsGrid',
//enableColumnResize: true, ddGroup : 'task-assignment',
//enableHdMenu: true, height : 180,
frame:false, enableDragDrop : true,
//columnLines: true, viewConfig : {
ddGroup : 'task-assignment', forceFit :true
height: 200,
enableDragDrop: true,
viewConfig: {
forceFit:true
}, },
cm : new Ext.grid.ColumnModel({
cm: new Ext.grid.ColumnModel({ defaults : {
defaults: { width : 400,
width: 200, sortable : true
sortable: true
}, },
columns: [ columns: [
{header: '', id:'GRP_UID', dataIndex: 'GRP_UID', hidden:true, hideable:false}, {id:'GRP_UID', dataIndex: 'GRP_UID', hidden:true, hideable:false},
{header: 'Group', dataIndex: 'CON_VALUE', width: 300, renderer:function(v,p,r){ {header: 'Group', dataIndex: 'CON_VALUE'}
return v; //String.format("<font color='green'>{0}</font>", v);
}}
] ]
}), }),
store: groupsStore, store : groupsStore,
listeners: { listeners : {
render: function(){ render : function(){
this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING')}); this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING')});
} }
}, },
tbar:[ tbar : [
//'->',
new Ext.form.TextField ({ new Ext.form.TextField ({
id: 'groupsSearchTxt', id : 'groupsSearchTxt',
ctCls:'pm_search_text_field', ctCls :'pm_search_text_field',
allowBlank: true, allowBlank : true,
width: 230, width : 220,
emptyText: _('ID_ENTER_SEARCH_TERM'),//'enter search term', emptyText : _('ID_ENTER_SEARCH_TERM'),
listeners: { listeners : {
specialkey: function(f,e){ specialkey: function(f,e){
if (e.getKey() == e.ENTER) if (e.getKey() == e.ENTER)
groupsSearch(); groupsSearch();
} }
} }
}),{ }), {
text:'X', text :'X',
ctCls:'pm_search_x_button', ctCls :'pm_search_x_button',
handler: function(){ handler : function(){
groupsStore.setBaseParam( 'search', ''); groupsStore.setBaseParam( 'search', '');
groupsStore.load({params:{start : 0 , limit : usersPanelLimit}}); groupsStore.load({params:{start : 0 , limit : usersPanelLimit}});
Ext.getCmp('groupsSearchTxt').setValue(''); Ext.getCmp('groupsSearchTxt').setValue('');
} }
},{ }, {
text:TRANSLATIONS.ID_SEARCH, text :TRANSLATIONS.ID_SEARCH,
handler: groupsSearch handler : groupsSearch
} }
], ],
bbar: [new Ext.PagingToolbar({ bbar: [new Ext.PagingToolbar({
pageSize: usersPanelLimit, pageSize : usersPanelLimit,
store: groupsStore, store : groupsStore,
displayInfo: true, displayInfo: true,
displayMsg: '{0} - {1} of {2}', displayMsg : '{2} Groups',
emptyMsg: "" emptyMsg : 'No records found'
})] })]
}); });
usersPanel = new Ext.Window({ usersPanel = new Ext.Window({
id: 'usersPanel', id : 'usersPanel',
title: '<span style="font-size:10px; font-weight:bold; align:center;">&nbsp;Actors</span>', title : 'Actors',
headerAsText: true, width : 302,
collapsed : true, height : 350,
width: 302,
height:380,
//x: (PMExt.getBrowser().screen.width - designerToolbarWidth) - 5, //x: (PMExt.getBrowser().screen.width - designerToolbarWidth) - 5,
//y: designerToolbarHeight + 2, //y: designerToolbarHeight + 2,
x: 0, minimizable : false,
y: 0, maximizable : false,
minimizable: false, closable : false,
maximizable: false, resizable : false,
closable: false, floating : true,
resizable: false, shadow : false,
floating: true, border : false,
shadow:false,
border:false,
//html: 'userslist'
items:[ items:[
new Ext.TabPanel({ new Ext.TabPanel({
id : 'usersPanelTabs',
border: true, // already wrapped so don't add another border border: true, // already wrapped so don't add another border
activeTab: 0, // second tab initially active activeTab : 0, // second tab initially active
tabPosition: 'top', tabPosition : 'top',
//region:'north', split : true,
split: true, height : 318,
height:350, items : [
items: [
usersGrid, usersGrid,
groupsGrid groupsGrid
] ]
@@ -501,24 +480,57 @@ Ext.onReady ( function() {
] ]
}); });
usersPanel.on('minimize',function(w){
if( Ext.getCmp('usersPanel').collapsed )
Ext.getCmp('usersPanel').expand();
else
Ext.getCmp('usersPanel').collapse();
});
// custom variables // custom variables
usersPanel._targetTask = null; usersPanel._targetTask = null;
usersPanel._onDrop = function(ddSource, e, data) { usersPanel._onDrop = function(ddSource, e, data) {
alert('tas_uid: ' + Ext.getCmp('usersPanel')._targetTask); _TAS_UID = Ext.getCmp('usersPanel')._targetTask.id;
if( typeof parent != 'undefined' ) {
parent._TAS_UID = _TAS_UID;
}
var type = Ext.getCmp('usersPanelTabs').getActiveTab().id == 'usersGrid' ? 1 : 2;
var records = ddSource.dragData.selections; var records = ddSource.dragData.selections;
var uids = Array();
Ext.each(records, function(gridRow){ Ext.each(records, function(gridRow){
alert('usr_uid ->'+gridRow.data.USR_UID); if( type == 1 ) {//some users grid items were dropped
//alert('usr_uid ->'+gridRow.data.USR_UID);
uids.push(gridRow.data.USR_UID);
} else { //some groups grid items were dropped
//alert('grp_uid ->'+gridRow.data.GRP_UID);
uids.push(gridRow.data.GRP_UID);
}
}); });
uids = uids.join(',');
if( typeof parent != 'undefined' ) {
parent.Ext.getCmp('eastPanelCenter').setTitle(Ext.getCmp('usersPanel')._targetTask.name);
}
Ext.Ajax.request({
url: '../processes/ajaxListener',
success: function(response){
var result = Ext.util.JSON.decode(response.responseText);
if( result.success ) {
PMExt.notify('', 'Users & Groups assigned successfully!');
if( typeof parent != 'undefined' ) {
parent.Ext.getCmp('eastPanel').show();
parent.Ext.getCmp('usersTaskGrid').store.reload({params: {action:'getUsersTask', TAS_UID: _TAS_UID}});
}
} else {
PMExt.error(_('ID_ERROR'), result.msg)
}
},
failure: function(){},
params: {
action : 'assignUsersTask',
TAS_UID : _TAS_UID,
TU_RELATION : type,
UIDS : uids
}
});
} }
usersPanel.on('beforeshow', function(e) { usersPanel.on('beforeshow', function(e) {
usersPanel._posRelToView = usersPanel.getPosition(true); usersPanel._posRelToView = usersPanel.getPosition(true);
@@ -623,7 +635,7 @@ Ext.onReady ( function() {
new Ext.ToolTip({ new Ext.ToolTip({
target: 'x-shapes-annotation', target: 'x-shapes-annotation',
title: 'Annotation', title: 'Annotation',
anchor: 'left', anchor: 'top',
trackMouse: true, trackMouse: true,
html: '' html: ''
}); });
@@ -1265,28 +1277,24 @@ Ext.onReady ( function() {
function usersSearch() function usersSearch()
{ {
var search = Ext.getCmp('usersSearchTxt').getValue(); var search = Ext.getCmp('usersSearchTxt').getValue().trim();
if( search == '' ) {
PMExt.info(_('ID_INFO'), _('ID_ENTER_SEARCH_TERM'));
return;
}
Ext.getCmp('usersGrid').store.setBaseParam('search', search); Ext.getCmp('usersGrid').store.setBaseParam('search', search);
Ext.getCmp('usersGrid').store.load({params:{search: search, start : 0 , limit : usersPanelLimit }}); Ext.getCmp('usersGrid').store.load({params:{search: search, start : 0 , limit : usersPanelLimit }});
} }
function groupsSearch() function groupsSearch()
{ {
var search = Ext.getCmp('groupsSearchTxt').getValue(); var search = Ext.getCmp('groupsSearchTxt').getValue().trim();
if( search == '' ) {
PMExt.info(_('ID_INFO'), _('ID_ENTER_SEARCH_TERM'));
return;
}
Ext.getCmp('groupsGrid').store.setBaseParam('search', search); Ext.getCmp('groupsGrid').store.setBaseParam('search', search);
Ext.getCmp('groupsGrid').store.load({params:{search: search, start : 0 , limit : usersPanelLimit }}); Ext.getCmp('groupsGrid').store.load({params:{search: search, start : 0 , limit : usersPanelLimit }});
} }
}); });
Ext.ux.WindowAlwaysOnTop = function(){
this.init = function(win){
win.on('deactivate', function(){
var i=1;
this.manager.each(function(){i++});
this.setZIndex(this.manager.zseed + (i*10));
})
}
}

View File

@@ -1,28 +1,20 @@
new Ext.KeyMap(document, { new Ext.KeyMap(document, {
key: Ext.EventObject.F5, key: Ext.EventObject.F5,
fn: function(keycode, e) { fn: function(keycode, e) {
//here (in the toolbar) we are disabling the ctrl-f5 //e.stopEvent();
e.stopEvent();
//if (! e.ctrlKey) {
// if (Ext.isIE)
// e.browserEvent.keyCode = 8;
// e.stopEvent();
//Ext.Msg.alert('Refresh', 'You clicked: F5');
//document.location = document.location;
//}
//else
//Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5');
} }
}); });
var _TAS_UID;
Ext.onReady ( function() { Ext.onReady ( function() {
workflow = new MyWorkflow("paintarea"); workflow = new MyWorkflow("paintarea");
workflow.setEnableSmoothFigureHandling(false); workflow.setEnableSmoothFigureHandling(false);
workflow.scrollArea.width = 2000; workflow.scrollArea.width = 2000;
//For Undo and Redo Options //For Undo and Redo Options
// workflow.getCommandStack().addCommandStackEventListener(new commandListener()); // workflow.getCommandStack().addCommandStackEventListener(new commandListener());
//Getting process id from the URL using getUrlvars function
if(typeof pro_uid !== 'undefined') { if(typeof pro_uid !== 'undefined') {
Ext.Ajax.request({ Ext.Ajax.request({
url: 'openProcess.php?PRO_UID=' + pro_uid, url: 'openProcess.php?PRO_UID=' + pro_uid,
@@ -37,6 +29,7 @@ Ext.onReady ( function() {
} }
/********************************************************************************** /**********************************************************************************
* *
* Do the Ext (Yahoo UI) Stuff * Do the Ext (Yahoo UI) Stuff
@@ -51,44 +44,270 @@ Ext.onReady ( function() {
autoScroll : true, autoScroll : true,
collapsible :true, collapsible :true,
split :true, split :true,
//collapseMode:'mini',
hideCollapseTool: false,
items:{
html:'<div id="x-shapes">\n\
<p id="x-shapes-task" title="Task" ><img src= "/skins/ext/images/gray/shapes/pallete/task.png"/></p>\n\
<p id="x-shapes-startEvent" title="Start"><img src= "/skins/ext/images/gray/shapes/pallete/startevent.png"/></p>\n\
<p id="x-shapes-interEvent" title="Intermediate Event"><img src= "/skins/ext/images/gray/shapes/pallete/interevent.png"/></p>\n\
<p id="x-shapes-endEvent" title="End Event"><img src= "/skins/ext/images/gray/shapes/pallete/endevent.png"/></p>\n\
<p id="x-shapes-gateways" title="Gateway"><img src= "/skins/ext/images/gray/shapes/pallete/gateway.png"/></p>\n\
<p id="x-shapes-annotation" title="Annotation"><img src= "/skins/ext/images/gray/shapes/pallete/annotation.png"/></p>\n\
<!--<p id="x-shapes-group" title="Group"><img src= "/skins/ext/images/gray/shapes/pallete/group.png"/></p>\n\
<p id="x-shapes-dataobject" title="Data Object"><img src= "/skins/ext/images/gray/shapes/pallete/dataobject.png"/></p>\n\
<p id="x-shapes-pool" title="Pool"><img src= "/skins/ext/images/gray/shapes/pallete/pool.png"/></p>\n\
<p id="x-shapes-lane" title="Lane"><img src= "/skins/ext/images/gray/shapes/pallete/lane.png"/></p>\n\
<p id="x-shapes-milestone" title="Milestone"><img src= "/skins/ext/images/gray/shapes/pallete/milestone.png"/></p>-->\n\
</div>'
}
};
var east= {
id : 'eastPanel',
title : '',
region : 'east',
width : 150,
border : false,
autoScroll : true,
collapsible :true,
split :true,
collapseMode:'mini', collapseMode:'mini',
hideCollapseTool: false, hideCollapseTool: false,
items:{ items:{
html:'east panel' html:''
} }
}; };
var north= { var usersTaskStore = new Ext.data.GroupingStore( {
autoLoad: false,
url: '../processes/ajaxListener',
reader : new Ext.data.JsonReader({
totalProperty: 'totalCount',
root: 'data',
fields : [
{name : 'USR_UID'},
{name : 'NAME'},
{name : 'TU_RELATION'}
]
}),
baseParams: {
action: 'getUsersTask',
TAS_UID: '4619962094d5d499f746ca7075681567'
},
groupField: 'TU_RELATION'
});
var usersTaskGrid = new Ext.grid.GridPanel({
id : 'usersTaskGrid',
title : 'Users & Groups',
height : 180,
stateful : true,
stateId : 'usersTaskGrid',
sortable:false,
view: new Ext.grid.GroupingView({
forceFit:true,
groupTextTpl: '{[values.rs.length]} {[values.rs[0].data["TU_RELATION"] == 1 ? "Users" : "Groups"]}'
//groupTextTpl: '{text}'
}),
cm : new Ext.grid.ColumnModel({
defaults: {
width: 300,
sortable: true
},
columns : [
{id:'USR_UID', dataIndex: 'USR_UID', hidden:true, hideable:false},
{header: 'Assigned', id:'TU_RELATION', dataIndex: 'TU_RELATION', hidden:true, hideable:false},
{header: 'Assigned', dataIndex: 'NAME', hideable:false}
]
}),
store: usersTaskStore,
listeners: {
render: function(){
this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING')});
}
}/*,
tbar:[
'->', {
text: _('ID_REMOVE'),
iconCls: 'button_menu_ext ss_sprite ss_delete',
handler: removeUsersTask
}
]*/,
bbar: [new Ext.PagingToolbar({
pageSize : 10,
store : usersTaskStore,
displayInfo: true,
displayMsg : '{2} Users',
emptyMsg : ''
})]
});
//connecting context menu to grid
usersTaskGrid.addListener('rowcontextmenu', onDynaformsContextMenu,this);
//by default the right click is not selecting the grid row over the mouse
//we need to set this four lines
usersTaskGrid.on('rowcontextmenu', function (grid, rowIndex, evt) {
var sm = grid.getSelectionModel();
sm.selectRow(rowIndex, sm.isSelected(rowIndex));
}, this);
//prevent default
usersTaskGrid.on('contextmenu', function (evt) {
evt.preventDefault();
}, this);
function onDynaformsContextMenu(grid, rowIndex, e) {
e.stopEvent();
var coords = e.getXY();
usersTaskGridContextMenu.showAt([coords[0], coords[1]]);
}
var usersTaskGridContextMenu = new Ext.menu.Menu({
id: 'messageContextMenu',
items: [{
text: _('ID_REMOVE'),
iconCls: 'button_menu_ext ss_sprite ss_delete',
handler: removeUsersTask
}
]
});
function removeUsersTask(){
var usr_uid = Array();
var tu_relation = Array();
var rowsSelected = Ext.getCmp('usersTaskGrid').getSelectionModel().getSelections();
if( rowsSelected.length == 0 ) {
PMExt.error('', _('ID_NO_SELECTION_WARNING'));
return false;
}
for(i=0; i<rowsSelected.length; i++) {
usr_uid[i] = rowsSelected[i].get('USR_UID');
tu_relation[i] = rowsSelected[i].get('TU_RELATION');
}
usr_uid = usr_uid.join(',');
tu_relation = tu_relation.join(',');
PMExt.confirm(_('ID_CONFIRM'), _('ID_DELETE_DYNAFORM_CONFIRM'), function(){
Ext.Ajax.request({
url : '../processes/ajaxListener',
method: 'POST',
params: {
action : 'removeUsersTask',
USR_UID: usr_uid,
TU_RELATION: tu_relation,
TAS_UID: _TAS_UID
},
success: function(response) {
var result = Ext.util.JSON.decode(response.responseText);
if( result.success ){
Ext.getCmp('usersTaskGrid').store.reload();
} else {
PMExt.error(_('ID_ERROR'), result.msg);
}
}
});
});
}
var eastPanelTree = new Ext.tree.TreePanel({
useArrows: true,
autoScroll: true,
animate: true,
//autoHeight: true,
//enableDD: true,
//containerScroll: true,
rootVisible : false,
border: true,
height: PMExt.getBrowser().screen.height * 0.25,
region: 'north',
split : true,
collapseMode:'mini',
// auto create TreeLoader
loader : new Ext.tree.TreeLoader({
preloadChildren : true,
dataUrl : '../processes/ajaxListener',
baseParams : {
action : 'getProcessDetail',
PRO_UID: pro_uid
}
}),
root: {
nodeType : 'async',
draggable : false,
id : 'root',
expanded : true
}
});
var propertiesGrid = new Ext.grid.PropertyGrid({
id: 'propGrid',
title: 'Properties',
//width: 300,
autoHeight: true,
propertyNames: {
tested: 'QA',
borderWidth: 'Border Width'
},
viewConfig : {
forceFit: true,
scrollOffset: 2 // the grid will never have scrollbars
}
});
var propertyStore = new Ext.data.JsonStore({
autoLoad: true, //autoload the data
url: 'ajaxListener?action=getProcessproperties',
root: 'props',
fields: ['First name', 'Last name', 'E-mail'],
listeners: {
load: {
fn: function(store, records, options){
// get the property grid component
var propGrid = Ext.getCmp('propGrid');
// make sure the property grid exists
if (propGrid) {
// populate the property grid with store data
propGrid.setSource(store.getAt(0).data);
}
}
}
}
});
propertiesGrid.setSource({
ttile: 'Properties Grid',
Description: false,
Calendar: true,
Category: false,
created: new Date(Date.parse('10/15/2006')),
tested: false,
version: 0.01,
borderWidth: 1
});
var east = new Ext.Panel({
id : 'eastPanel',
title : '',
region : 'east',
width : 280,
title : '',
//autoScroll : true,
layout:'border',
collapsible :true,
split :true,
//collapseMode:'mini',
//hideCollapseTool: false,
items:[
eastPanelTree
, {
id: 'eastPanelCenter',
xtype: 'panel',
title: 'Process: ',
region: 'center',
layout: 'fit',
items:[
new Ext.TabPanel({
id : 'usersPanelTabs',
title : 'sdd',
border: true, // already wrapped so don't add another border
activeTab : 0, // second tab initially active
tabPosition : 'top',
split : true,
collapseMode:'mini',
//height : 318,
items : [
propertiesGrid,
usersTaskGrid
]
})
]
}
]
});
/*items:[
*/
var north = {
xtype : "panel", xtype : "panel",
initialSize: 60, initialSize: 60,
split:false, split:false,
@@ -97,8 +316,8 @@ Ext.onReady ( function() {
animate: false, animate: false,
region : "north" region : "north"
}; };
var south= { var south = {
xtype : "panel", xtype : "panel",
initialSize: 120, initialSize: 120,
height: 100, height: 100,
@@ -109,16 +328,16 @@ Ext.onReady ( function() {
animate: true, animate: true,
region : "south", region : "south",
items: { items: {
region: 'center', region: 'center',
xtype: 'tabpanel', xtype: 'tabpanel',
items: [{ items: [{
title: 'Properties', title: 'Properties',
html: 'Properties' html: 'Properties'
}, },
{ {
title: 'Debug Console', title: 'Debug Console',
html: 'Debug Console' html: 'Debug Console'
}] }]
} }
}; };
@@ -138,14 +357,15 @@ Ext.onReady ( function() {
var processObj = new ProcessOptions(); var processObj = new ProcessOptions();
var main = new Ext.Panel({ var main = new Ext.Panel({
renderTo : "center1", renderTo : "center1",
region : "center", region : "center",
layout : "border", layout : "border",
autoScroll: true, autoScroll: true,
height : 1000, height : 1000,
width : 1300, width : 1300,
items : [north, center], items : [north, center, east],
tbar: [ tbar: [
{ {
text: 'Save', text: 'Save',
@@ -292,5 +512,7 @@ Ext.onReady ( function() {
,border:false, ,border:false,
items:[main] items:[main]
}); });
Ext.getCmp('eastPanel').hide();
//Ext.getCmp('eastPanel').ownerCt.doLayout();
}); });