Use FHCAPI Controller for Phrasen

This commit is contained in:
cgfhtw
2024-03-06 16:49:35 +01:00
parent 68459e086a
commit f6427f57b8
2 changed files with 18 additions and 14 deletions
@@ -5,8 +5,12 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
class Phrasen extends FHC_Controller
class Phrasen extends FHCAPI_Controller
{
public function __construct()
{
parent::__construct(['loadModule' => [self::PERM_ANONYMOUS]]);
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
@@ -17,11 +21,6 @@ class Phrasen extends FHC_Controller
public function loadModule($module)
{
$this->load->library('PhrasesLib', [$module], 'pj');
$this->outputJson([
'data' => json_decode($this->pj->getJSON()),
'meta' => [
'status' => FHCAPI_Controller::STATUS_SUCCESS
]
]);
$this->terminateWithSuccess(json_decode($this->pj->getJSON()));
}
}
+12 -7
View File
@@ -1,3 +1,5 @@
import FhcApi from './FhcApi.js';
const categories = Vue.reactive({});
const loadingModules = {};
@@ -23,13 +25,11 @@ const phrasen = {
if (Array.isArray(category))
return Promise.all(category.map(cat => this.loadCategory(cat)));
if (!loadingModules[category])
loadingModules[category] = axios
.get(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/api/frontend/v1/phrasen/loadModule/' + category)
loadingModules[category] = this.config.globalProperties.$fhcApi
.get('/api/frontend/v1/phrasen/loadModule/' + category)
.then(res => res?.data ? extractCategory(res.data, category) : {})
.then(res => {
if (res?.data?.data)
categories[category] = extractCategory(res.data.data, category);
else
categories[category] = {};
categories[category] = res;
});
return loadingModules[category];
},
@@ -62,6 +62,11 @@ const phrasen = {
export default {
install(app, options) {
app.config.globalProperties.$p = phrasen;
app.use(FhcApi);
app.config.globalProperties.$p = {
t: phrasen.t,
loadCategory: cat => phrasen.loadCategory.call(app, cat),
t_ref: phrasen.t_ref
};
}
}