default dashboard added

This commit is contained in:
Dante
2015-05-08 09:53:25 -04:00
parent c5519a9db5
commit a48a45e1dc
2 changed files with 15 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ ViewDashboardPresenter.prototype.userDashboardsViewModel = function(data) {
//if null data is returned we default to an empty array
if (data == null) { data = []; }
var returnList = [];
var hasFavorite = false;
$.each(data, function(index, originalObject) {
var map = {
"DAS_TITLE" : "title",
@@ -29,8 +30,17 @@ ViewDashboardPresenter.prototype.userDashboardsViewModel = function(data) {
"DAS_FAVORITE" : "isFavorite"
};
var newObject = that.helper.merge(originalObject, {}, map);
if (newObject.isFavorite == 1) {
hasFavorite = true;
}
returnList.push(newObject);
});
//if no favorite is selected, the first one is selected.
if (!hasFavorite && returnList.length > 0 ) {
returnList[0].isFavorite = 1;
}
return returnList;
};

View File

@@ -41,26 +41,27 @@ class Dashboard {
$resp = array();
$dashboards = $this->getDashboardsUidByUser($usr_uid);
$existFavorite = false;
$cont = 0;
foreach($dashboards as $i=>$x) {
//$resp[$i] = $this->getDashboard($x['DAS_UID']);
$dashboardUser = $this->getDashboard($x['DAS_UID']);
if ($dashboardUser['DAS_STATUS'] == 0) {
continue;
}
$resp[$i] = $dashboardUser;
$resp[$cont] = $dashboardUser;
$Dashboard = new \ProcessMaker\BusinessModel\Dashboard();
$dashConfig = $Dashboard->getConfig($usr_uid);
$resp[$i]['DAS_FAVORITE'] = 0;
$resp[$cont]['DAS_FAVORITE'] = 0;
foreach ($dashConfig as $dashId=>$dashData) {
if($dashId == $x['DAS_UID'] ) {
$resp[$i]['DAS_FAVORITE'] = $dashData['dashFavorite'];
$resp[$cont]['DAS_FAVORITE'] = $dashData['dashFavorite'];
if ($dashData['dashFavorite']==1) {
$existFavorite = true;
}
}
}
$cont++;
}
//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;