diff --git a/application/controllers/api/frontend/v1/dashboard/User.php b/application/controllers/api/frontend/v1/dashboard/User.php index 27cb2c789..6c7b934dc 100644 --- a/application/controllers/api/frontend/v1/dashboard/User.php +++ b/application/controllers/api/frontend/v1/dashboard/User.php @@ -56,7 +56,7 @@ class User extends FHCAPI_Controller $mergedconfig ) ]);*/ - $defaultconfig = $this->dashboardlib->getDefaultConfig($dashboard->dashboard_id, $uid); + $defaultconfig = $this->dashboardlib->getDefaultConfig($dashboard->dashboard_id); $userconfig = $this->dashboardlib->getUserConfig($dashboard->dashboard_id, $uid); $defaultconfig_squashed = $defaultconfig ? call_user_func_array('array_merge_recursive', $defaultconfig) : []; diff --git a/application/libraries/dashboard/DashboardLib.php b/application/libraries/dashboard/DashboardLib.php index eb91350fd..9b5306d94 100644 --- a/application/libraries/dashboard/DashboardLib.php +++ b/application/libraries/dashboard/DashboardLib.php @@ -49,7 +49,7 @@ class DashboardLib public function getMergedConfig($dashboard_id, $uid) { - $defaultconfig = $this->getDefaultConfig($dashboard_id, $uid); + $defaultconfig = $this->getDefaultConfig($dashboard_id); $userconfig = $this->getUserConfig($dashboard_id, $uid); $mergedconfig = array_replace_recursive($defaultconfig, $userconfig); @@ -57,14 +57,28 @@ class DashboardLib return $mergedconfig; } - public function getDefaultConfig($dashboard_id, $uid) + public function getDefaultConfig($dashboard_id) { - $res_presets = $this->_ci->DashboardPresetModel->getPresets($dashboard_id, $uid); + $funktion_kurzbzs = []; + $rights = $this->_ci->permissionlib->getAccessRights(); + if ($rights) + $funktion_kurzbzs = array_unique(array_map(function ($right) { + return $right->funktion_kurzbz; + }, $rights)); + + $this->_ci->DashboardPresetModel->db->where_in('funktion_kurzbz', $funktion_kurzbzs); + $this->_ci->DashboardPresetModel->db->or_where('funktion_kurzbz IS NULL'); + + $this->_ci->DashboardPresetModel->addOrder('funktion_kurzbz', 'DESC'); + + $result = $this->_ci->DashboardPresetModel->loadWhere([ + 'dashboard_id' => $dashboard_id + ]); $defaultconfig = array(); - if (hasData($res_presets)) + if (hasData($result)) { - $presets = getData($res_presets); + $presets = getData($result); foreach ($presets as $presetobj) { $preset = json_decode($presetobj->preset, true); @@ -137,8 +151,10 @@ class DashboardLib $dashboard = $this->getDashboardByKurzbz($dashboard_kurzbz); $funktion_kurzbz = ($section === self::SECTION_IF_FUNKTION_KURZBZ_IS_NULL) ? null : $section; - $result = $this->_ci->DashboardPresetModel - ->getPresetByDashboardAndFunktion($dashboard->dashboard_id, $funktion_kurzbz); + $result = $this->_ci->DashboardPresetModel->loadWhere([ + 'dashboard_id' => $dashboard->dashboard_id, + 'funktion_kurzbz' => $funktion_kurzbz + ]); if (hasData($result)) { diff --git a/application/models/dashboard/Dashboard_Preset_model.php b/application/models/dashboard/Dashboard_Preset_model.php index ca10ce98a..42570d091 100644 --- a/application/models/dashboard/Dashboard_Preset_model.php +++ b/application/models/dashboard/Dashboard_Preset_model.php @@ -11,57 +11,4 @@ class Dashboard_Preset_model extends DB_Model $this->dbTable = 'dashboard.tbl_dashboard_preset'; $this->pk = 'preset_id'; } - - /** - * Get Presets of given uid. - * @param integer dashboard_id - * @param string $uid - * @return array - */ - public function getPresets($dashboard_id, $uid) - { - // TODO: get Funktionen for uid and load all preset for all funktionen for uid - //return $this->loadWhere(array('dashboard_id' => $dashboard_id, 'funktion_kurzbz'=> null)); - $sql = <<execQuery($sql, array($dashboard_id, $uid)); - } - - /** - * Get Preset by Dashboard and Funktion - * @param integer dashboard_id - * @param string funktion_kurzbz - * @return array - */ - public function getPresetByDashboardAndFunktion($dashboard_id, $funktion_kurzbz) - { - return $this->loadWhere(array('dashboard_id' => $dashboard_id, 'funktion_kurzbz' => $funktion_kurzbz)); - } } diff --git a/public/js/components/Dashboard/Item.js b/public/js/components/Dashboard/Item.js index 1fe67ab45..79e61293d 100644 --- a/public/js/components/Dashboard/Item.js +++ b/public/js/components/Dashboard/Item.js @@ -70,6 +70,14 @@ export default { ready() { return this.component && this.arguments !== null; }, + visible: { + get() { + return !this.hidden; + }, + set(value) { + this.$emit('remove', this.hidden); + } + } }, methods: { unpin(){ @@ -191,7 +199,7 @@ export default {
- +