Merged in marcoAntonioNina/processmaker/dashboards2 (pull request #2008)

Add validation check group user
This commit is contained in:
Dante Loayza
2015-04-27 15:33:50 -04:00
4 changed files with 75 additions and 39 deletions

View File

@@ -108,10 +108,40 @@ class DashboardDasInd extends BaseDashboardDasInd
} }
} }
public function getOwnerByDashboard ($dasUid) public function loadOwnerByUserId ($usrId)
{ {
try {
$criteria = new Criteria('workflow');
$criteria->add(DashboardDasIndPeer::OWNER_UID, $usrId);
$criteria->add(DashboardDasIndPeer::OWNER_TYPE, "USER");
$dataset = DashboardDasIndPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$fields = array();
while ($dataset->next()) {
$auxField = $dataset->getRow();
$fields[] = $auxField;
}
$criteria = new Criteria('workflow');
$criteria->add(DashboardDasIndPeer::OWNER_TYPE, "GROUP");
$criteria->add(GroupUserPeer::USR_UID, $usrId);
$criteria->addJoin(GroupUserPeer::GRP_UID, DashboardDasIndPeer::OWNER_UID);
$dataset = DashboardDasIndPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($dataset->next()) {
$auxField = $dataset->getRow();
$fields[] = $auxField;
}
return $fields;
} catch (Exception $error) {
throw $error;
}
} }
} }

View File

@@ -23,7 +23,7 @@ class Dashboard {
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "DashboardDasInd.php"); require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "DashboardDasInd.php");
$oDashboardDasInd = new \DashboardDasInd(); $oDashboardDasInd = new \DashboardDasInd();
$response = $oDashboardDasInd->loadByOwner($usr_uid); $response = $oDashboardDasInd->loadOwnerByUserId($usr_uid);
return $response; return $response;
} }
@@ -40,27 +40,32 @@ class Dashboard {
{ {
$resp = array(); $resp = array();
$dashboards = $this->getDashboardsUidByUser($usr_uid); $dashboards = $this->getDashboardsUidByUser($usr_uid);
$existFavorite = false; $existFavorite = false;
foreach($dashboards as $i=>$x) { foreach($dashboards as $i=>$x) {
$resp[$i] = $this->getDashboard($x['DAS_UID']); //$resp[$i] = $this->getDashboard($x['DAS_UID']);
$Dashboard = new \ProcessMaker\BusinessModel\Dashboard(); $dashboardUser = $this->getDashboard($x['DAS_UID']);
$dashConfig = $Dashboard->getConfig($usr_uid); if ($dashboardUser['DAS_STATUS'] == 0) {
$resp[$i]['DAS_FAVORITE'] = 0; continue;
foreach ($dashConfig as $dashId=>$dashData) { }
if($dashId == $x['DAS_UID'] ) { $resp[$i] = $dashboardUser;
$resp[$i]['DAS_FAVORITE'] = $dashData['dashFavorite']; $Dashboard = new \ProcessMaker\BusinessModel\Dashboard();
if ($dashData['dashFavorite']==1) { $dashConfig = $Dashboard->getConfig($usr_uid);
$existFavorite = true; $resp[$i]['DAS_FAVORITE'] = 0;
} foreach ($dashConfig as $dashId=>$dashData) {
if($dashId == $x['DAS_UID'] ) {
$resp[$i]['DAS_FAVORITE'] = $dashData['dashFavorite'];
if ($dashData['dashFavorite']==1) {
$existFavorite = true;
} }
} }
} }
//if no favorite is set, the default vavorite is the first one
if ($existFavorite == false && $dashboards != null && sizeof($dashboards)>0) {
$resp[0]['DAS_FAVORITE'] = 1;
} }
return $resp;
//if no favorite is set, the default favorite is the first one
if ($existFavorite == false && $resp != null && sizeof($resp)>0) {
$resp[0]['DAS_FAVORITE'] = 1;
}
return $resp;
} }
/** /**

View File

@@ -76,6 +76,8 @@ Ext.onReady(function() {
statusButton = new Ext.Action({ statusButton = new Ext.Action({
text: _('ID_STATUS'), text: _('ID_STATUS'),
icon : '',
id : 'activator',
iconCls: 'silk-add', iconCls: 'silk-add',
handler: statusDashboard, handler: statusDashboard,
disabled: true disabled: true
@@ -105,18 +107,18 @@ Ext.onReady(function() {
} }
} }
var activator = Ext.getCmp('activator');
if( record.data.DAS_STATUS == 1 ){ if( record.data.DAS_STATUS == 1 ){
statusButton.setIconClass('icon-activate'); activator.setIcon('/images/deactivate.png');
statusButton.setText( _('ID_DEACTIVATE') ); activator.setText( _('ID_DEACTIVATE') );
editButton.enable(); editButton.enable();
deleteButton.enable(); deleteButton.enable();
//statusButton.enable();
} else { } else {
statusButton.setIconClass('icon-deactivate'); activator.setIcon('/images/activate.png');
statusButton.setText( _('ID_ACTIVATE') ); activator.setText( _('ID_ACTIVATE') );
editButton.disable(); editButton.disable();
deleteButton.disable(); deleteButton.disable();
//statusButton.disable();
} }
}, },
rowdeselect: function(sm, index, record){ rowdeselect: function(sm, index, record){
@@ -237,7 +239,7 @@ Ext.onReady(function() {
viewConfig: { viewConfig: {
forceFit:true forceFit:true
}, },
title : _('ID_DASHBOARD'), title : _('ID_STRATEGIC_DASHBOARD'),
store: store, store: store,
cm: cmodel, cm: cmodel,
sm: smodel, sm: smodel,

View File

@@ -41,7 +41,6 @@ var frmDashboard;
var addTabButton; var addTabButton;
var tabPanel; var tabPanel;
var dashboardIndicatorFields; var dashboardIndicatorFields;
var dashboardIndicatorPanel;
var store; var store;
var indexTab = 0; var indexTab = 0;
@@ -49,7 +48,7 @@ var comboPageSize = 10;
var resultTpl; var resultTpl;
var storeIndicatorType; var storeIndicatorType;
var storeGraphic; var storeGraphic;
var storeFrecuency; var storeFrequency;
var storeProject; var storeProject;
var storeGroup; var storeGroup;
var storeUsers; var storeUsers;
@@ -79,7 +78,7 @@ Ext.onReady( function() {
items : [ items : [
{ {
id : 'DAS_TITLE', id : 'DAS_TITLE',
fieldLabel : _('ID_DASHBOARD_TITLE')+ ' *', fieldLabel : '<span style=\"color:red;\" ext:qtip="'+ _('ID_FIELD_REQUIRED', _('ID_DASHBOARD_TITLE')) +'"> * </span>' + _('ID_DASHBOARD_TITLE'),
xtype : 'textfield', xtype : 'textfield',
anchor : '85%', anchor : '85%',
maxLength : 250, maxLength : 250,
@@ -297,7 +296,7 @@ Ext.onReady( function() {
} }
}); });
storeFrecuency = new Ext.data.GroupingStore( { storeFrequency = new Ext.data.GroupingStore( {
proxy : new Ext.data.HttpProxy({ proxy : new Ext.data.HttpProxy({
api: { api: {
read : urlProxy + 'catalog/periodicity' read : urlProxy + 'catalog/periodicity'
@@ -754,7 +753,7 @@ var addTab = function (flag) {
hidden : true hidden : true
}, },
{ {
fieldLabel : _('ID_INDICATOR_TITLE')+ ' *', fieldLabel : '<span style=\"color:red;\" ext:qtip="'+ _('ID_FIELD_REQUIRED', _('ID_INDICATOR_TITLE')) +'"> * </span>' + _('ID_INDICATOR_TITLE'),
id : 'IND_TITLE_'+ indexTab, id : 'IND_TITLE_'+ indexTab,
xtype : 'textfield', xtype : 'textfield',
anchor : '85%', anchor : '85%',
@@ -768,7 +767,7 @@ var addTab = function (flag) {
anchor : '85%', anchor : '85%',
editable : false, editable : false,
id : 'IND_TYPE_'+ indexTab, id : 'IND_TYPE_'+ indexTab,
fieldLabel : _('ID_INDICATOR_TYPE')+ ' *', fieldLabel : '<span style=\"color:red;\" ext:qtip="'+ _('ID_FIELD_REQUIRED', _('ID_INDICATOR_TYPE')) +'"> * </span>' + _('ID_INDICATOR_TYPE'),
displayField : 'CAT_LABEL_ID', displayField : 'CAT_LABEL_ID',
valueField : 'CAT_UID', valueField : 'CAT_UID',
forceSelection : false, forceSelection : false,
@@ -880,7 +879,7 @@ var addTab = function (flag) {
new Ext.form.ComboBox({ new Ext.form.ComboBox({
anchor : '85%', anchor : '85%',
editable : false, editable : false,
fieldLabel : _('ID_PROCESS')+ ' *', fieldLabel : '<span style=\"color:red;\" ext:qtip="'+ _('ID_FIELD_REQUIRED', _('ID_PROCESS')) +'"> * </span>' + _('ID_PROCESS'),
id : 'IND_PROCESS_'+ indexTab, id : 'IND_PROCESS_'+ indexTab,
displayField : 'prj_name', displayField : 'prj_name',
valueField : 'prj_uid', valueField : 'prj_uid',
@@ -923,7 +922,7 @@ var addTab = function (flag) {
typeAhead : true, typeAhead : true,
autocomplete : true, autocomplete : true,
triggerAction : 'all', triggerAction : 'all',
store : storeFrecuency store : storeFrequency
}), }),
new Ext.form.ComboBox({ new Ext.form.ComboBox({
anchor : '85%', anchor : '85%',
@@ -955,7 +954,7 @@ var addTab = function (flag) {
typeAhead : true, typeAhead : true,
autocomplete : true, autocomplete : true,
triggerAction : 'all', triggerAction : 'all',
store : storeFrecuency store : storeFrequency
}) })
] ]
}) })