mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-16 22:42:16 +00:00
For each treemenu seperate favorites
This commit is contained in:
+8
-8
@@ -20,8 +20,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the back-end
|
||||
* Provides data to the ajax get calls about favorite verbände
|
||||
* Listens to ajax post calls to change the favorite verbände data
|
||||
* Provides data to the ajax get calls about favorite treemenu entries
|
||||
* Listens to ajax post calls to change the favorite treemenu entries
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Favorites extends FHCAPI_Controller
|
||||
@@ -29,7 +29,7 @@ class Favorites extends FHCAPI_Controller
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'index' => self::PERM_LOGGED,
|
||||
'get' => self::PERM_LOGGED,
|
||||
'set' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
@@ -37,19 +37,19 @@ class Favorites extends FHCAPI_Controller
|
||||
$this->load->model('system/Variable_model', 'VariableModel');
|
||||
}
|
||||
|
||||
public function index()
|
||||
public function get($app)
|
||||
{
|
||||
$result = $this->VariableModel->getVariables(getAuthUID(), ['stv_favorites']);
|
||||
$result = $this->VariableModel->getVariables(getAuthUID(), [$app . '_favorites']);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$data)
|
||||
$this->terminateWithSuccess(null);
|
||||
else
|
||||
$this->terminateWithSuccess($data['stv_favorites'] ?? null);
|
||||
$this->terminateWithSuccess($data[$app . '_favorites'] ?? null);
|
||||
}
|
||||
|
||||
public function set()
|
||||
public function set($app)
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
@@ -60,7 +60,7 @@ class Favorites extends FHCAPI_Controller
|
||||
|
||||
$favorites = $this->input->post('favorites');
|
||||
|
||||
$result = $this->VariableModel->setVariable(getAuthUID(), 'stv_favorites', $favorites);
|
||||
$result = $this->VariableModel->setVariable(getAuthUID(), $app . '_favorites', $favorites);
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
@@ -30,16 +30,16 @@ export default {
|
||||
},
|
||||
// TODO(chris): handle favorites per config
|
||||
favorites: {
|
||||
get() {
|
||||
get(config) {
|
||||
return {
|
||||
method: 'get',
|
||||
url: 'api/frontend/v1/stv/favorites'
|
||||
url: 'api/frontend/v1/favorites/get/' + config
|
||||
};
|
||||
},
|
||||
set(favorites) {
|
||||
set(config, favorites) {
|
||||
return {
|
||||
method: 'post',
|
||||
url: 'api/frontend/v1/stv/favorites/set',
|
||||
url: 'api/frontend/v1/favorites/set/' + config,
|
||||
params: { favorites }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -224,6 +224,7 @@ export default {
|
||||
this.favorites.on = !this.favorites.on;
|
||||
this.$api
|
||||
.call(ApiTreemenu.favorites.set(
|
||||
this.config,
|
||||
JSON.stringify(this.favorites)
|
||||
));
|
||||
},
|
||||
@@ -238,6 +239,7 @@ export default {
|
||||
|
||||
this.$api
|
||||
.call(ApiTreemenu.favorites.set(
|
||||
this.config,
|
||||
JSON.stringify(this.favorites)
|
||||
));
|
||||
},
|
||||
@@ -272,7 +274,7 @@ export default {
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
|
||||
this.$api
|
||||
.call(ApiTreemenu.favorites.get())
|
||||
.call(ApiTreemenu.favorites.get(this.config))
|
||||
.then(result => {
|
||||
if (result.data) {
|
||||
this.favorites = JSON.parse(result.data);
|
||||
|
||||
Reference in New Issue
Block a user