diff --git a/application/controllers/api/frontend/v1/Cms.php b/application/controllers/api/frontend/v1/Cms.php index 7aad344d6..6808d76d8 100644 --- a/application/controllers/api/frontend/v1/Cms.php +++ b/application/controllers/api/frontend/v1/Cms.php @@ -112,23 +112,31 @@ class Cms extends FHCAPI_Controller $limit = $this->input->get('limit',TRUE); // return early if the limit parameter is missing or is not greater than 0 - if(!isset($limit) and $limit > 0) - $this->terminateWithError("limit parameter is missing", self::ERROR_TYPE_GENERAL); + if(!isset($limit) || $limit > 0) + $this->terminateWithError("API parameters are missing", self::ERROR_TYPE_GENERAL); $this->load->model('content/news_model', 'NewsModel'); $news_content_ids = $this->NewsModel->getNewsContentIDs($limit); + $news_metadata = $this->NewsModel->getAll($limit); + $this->addMeta("content_ids",$news_content_ids); - $news_content = array(); + + $news_content = array(); if(isError($news_content_ids)) $this->terminateWithError(getError($news_content_ids), self::ERROR_TYPE_GENERAL); + if(isError($news_metadata)) + $this->terminateWithError(getError($news_metadata), self::ERROR_TYPE_GENERAL); + foreach(getData($news_content_ids) as $content_id){ $news_content[] = $this->fetchContent($content_id->content_id); } - $this->terminateWithSuccess($news_content); + $this->terminateWithSuccess(["news_content" =>$news_content, "news_metadata"=>getData($news_metadata)]); + + } diff --git a/public/css/components/dashboard/news.css b/public/css/components/dashboard/news.css index 93718b819..013401bc8 100644 --- a/public/css/components/dashboard/news.css +++ b/public/css/components/dashboard/news.css @@ -1,8 +1,8 @@ -/* .widgets-news .card-header { +.widgets-news .card-header { flex-direction: column; align-items: flex-start !important; -} */ +} :root{ --news-widget-height: 1; diff --git a/public/js/api/cms.js b/public/js/api/cms.js index 651ddd9b7..c8ac8dc6f 100644 --- a/public/js/api/cms.js +++ b/public/js/api/cms.js @@ -11,12 +11,15 @@ export default { } ); }, - news(limit) { + news(limit, metadata=false) { return this.$fhcApi.get( FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/api/frontend/v1/Cms/news", - { limit: limit} + { + limit: limit, + metadata: metadata, + } ); }, diff --git a/public/js/components/DashboardWidget/News.js b/public/js/components/DashboardWidget/News.js index f597fea10..2bd778283 100755 --- a/public/js/components/DashboardWidget/News.js +++ b/public/js/components/DashboardWidget/News.js @@ -29,10 +29,9 @@ export default { }, created(){ - - this.$fhcApi.factory.cms.news(MAX_LOADED_NEWS) - .then(res => { this.allNewsList = res.data }) - .catch(err => { console.error('ERROR: ', err.response.data) }); + this.$fhcApi.factory.cms.news(MAX_LOADED_NEWS,this.width === 1?true:false) + .then(res => { this.allNewsList = res.data }) + .catch(err => { console.error('ERROR: ', err.response.data) }); this.$emit('setConfig', false); }, @@ -61,16 +60,16 @@ export default { }, template: /*html*/`