diff --git a/public/js/components/DashboardWidget/News.js b/public/js/components/DashboardWidget/News.js new file mode 100644 index 000000000..6b5fc73d1 --- /dev/null +++ b/public/js/components/DashboardWidget/News.js @@ -0,0 +1,115 @@ +import AbstractWidget from './Abstract'; +import BsModal from '../Bootstrap/Modal'; +const MAX_LOADED_NEWS = 10; + +export default { + name: 'WidgetsNews', + components: { BsModal }, + data: () => ({ + allNewsList: [], + singleNews: {} + }), + mixins: [ + AbstractWidget + ], + computed: { + newsList(){ + //Return news amount depending on widget width and size + let quantity = this.width; + + if (this.width === 1) { + quantity = this.height === 1 ? 4 : 10; + } + + return this.allNewsList.slice(0, quantity); + } + }, + created(){ + axios + .get(this.apiurl + '/dashboard/Api/getNews', {params: {limit: MAX_LOADED_NEWS}}) + .then(res => { this.allNewsList = res.data }) + .catch(err => { console.error('ERROR: ', err.response.data) }); + + this.$emit('setConfig', false); + }, + methods: { + setSingleNews(singleNews){ + this.singleNews = singleNews; + this.$refs.newsModal.show(); + } + }, + template: `
+ + +
{{ singleNews.betreff }}
{{ formatDateTime(singleNews.insertamum) }}
+
+
+