default dashboard added
This commit is contained in:
@@ -22,6 +22,7 @@ ViewDashboardPresenter.prototype.userDashboardsViewModel = function(data) {
|
|||||||
//if null data is returned we default to an empty array
|
//if null data is returned we default to an empty array
|
||||||
if (data == null) { data = []; }
|
if (data == null) { data = []; }
|
||||||
var returnList = [];
|
var returnList = [];
|
||||||
|
var hasFavorite = false;
|
||||||
$.each(data, function(index, originalObject) {
|
$.each(data, function(index, originalObject) {
|
||||||
var map = {
|
var map = {
|
||||||
"DAS_TITLE" : "title",
|
"DAS_TITLE" : "title",
|
||||||
@@ -29,8 +30,17 @@ ViewDashboardPresenter.prototype.userDashboardsViewModel = function(data) {
|
|||||||
"DAS_FAVORITE" : "isFavorite"
|
"DAS_FAVORITE" : "isFavorite"
|
||||||
};
|
};
|
||||||
var newObject = that.helper.merge(originalObject, {}, map);
|
var newObject = that.helper.merge(originalObject, {}, map);
|
||||||
|
if (newObject.isFavorite == 1) {
|
||||||
|
hasFavorite = true;
|
||||||
|
}
|
||||||
returnList.push(newObject);
|
returnList.push(newObject);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//if no favorite is selected, the first one is selected.
|
||||||
|
if (!hasFavorite && returnList.length > 0 ) {
|
||||||
|
returnList[0].isFavorite = 1;
|
||||||
|
}
|
||||||
|
|
||||||
return returnList;
|
return returnList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -41,26 +41,27 @@ class Dashboard {
|
|||||||
$resp = array();
|
$resp = array();
|
||||||
$dashboards = $this->getDashboardsUidByUser($usr_uid);
|
$dashboards = $this->getDashboardsUidByUser($usr_uid);
|
||||||
$existFavorite = false;
|
$existFavorite = false;
|
||||||
|
$cont = 0;
|
||||||
foreach($dashboards as $i=>$x) {
|
foreach($dashboards as $i=>$x) {
|
||||||
//$resp[$i] = $this->getDashboard($x['DAS_UID']);
|
//$resp[$i] = $this->getDashboard($x['DAS_UID']);
|
||||||
$dashboardUser = $this->getDashboard($x['DAS_UID']);
|
$dashboardUser = $this->getDashboard($x['DAS_UID']);
|
||||||
if ($dashboardUser['DAS_STATUS'] == 0) {
|
if ($dashboardUser['DAS_STATUS'] == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$resp[$i] = $dashboardUser;
|
$resp[$cont] = $dashboardUser;
|
||||||
$Dashboard = new \ProcessMaker\BusinessModel\Dashboard();
|
$Dashboard = new \ProcessMaker\BusinessModel\Dashboard();
|
||||||
$dashConfig = $Dashboard->getConfig($usr_uid);
|
$dashConfig = $Dashboard->getConfig($usr_uid);
|
||||||
$resp[$i]['DAS_FAVORITE'] = 0;
|
$resp[$cont]['DAS_FAVORITE'] = 0;
|
||||||
foreach ($dashConfig as $dashId=>$dashData) {
|
foreach ($dashConfig as $dashId=>$dashData) {
|
||||||
if($dashId == $x['DAS_UID'] ) {
|
if($dashId == $x['DAS_UID'] ) {
|
||||||
$resp[$i]['DAS_FAVORITE'] = $dashData['dashFavorite'];
|
$resp[$cont]['DAS_FAVORITE'] = $dashData['dashFavorite'];
|
||||||
if ($dashData['dashFavorite']==1) {
|
if ($dashData['dashFavorite']==1) {
|
||||||
$existFavorite = true;
|
$existFavorite = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$cont++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if no favorite is set, the default favorite is the first one
|
//if no favorite is set, the default favorite is the first one
|
||||||
if ($existFavorite == false && $resp != null && sizeof($resp)>0) {
|
if ($existFavorite == false && $resp != null && sizeof($resp)>0) {
|
||||||
$resp[0]['DAS_FAVORITE'] = 1;
|
$resp[0]['DAS_FAVORITE'] = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user