From ecab3ea4d97024fd6c895fc20214d3c0373e1c0c Mon Sep 17 00:00:00 2001 From: Johann Hoffmann Date: Fri, 22 Nov 2024 11:43:05 +0100 Subject: [PATCH] remove hardcoded h1 tag, keep the title h1 tag; more cleanup; --- .../js/components/Dashboard/Admin/Widgets.js | 3 +- .../js/components/DashboardWidget/Default.js | 4 +- public/js/components/DashboardWidget/News.js | 157 ++++++------- public/js/components/DashboardWidget/Url.js | 210 +++++++++--------- system/dbupdate_3.4/25999_cis4_cms.php | 1 - 5 files changed, 187 insertions(+), 188 deletions(-) diff --git a/public/js/components/Dashboard/Admin/Widgets.js b/public/js/components/Dashboard/Admin/Widgets.js index 34b7b482c..645d3f8cc 100644 --- a/public/js/components/Dashboard/Admin/Widgets.js +++ b/public/js/components/Dashboard/Admin/Widgets.js @@ -36,7 +36,8 @@ export default { } ).catch(err => console.error('ERROR:', err)); }, - template: `
+ template: ` +
diff --git a/public/js/components/DashboardWidget/Default.js b/public/js/components/DashboardWidget/Default.js index 859528ca5..5351d66ef 100644 --- a/public/js/components/DashboardWidget/Default.js +++ b/public/js/components/DashboardWidget/Default.js @@ -1,5 +1,4 @@ import AbstractWidget from './Abstract'; - export default { mixins: [ AbstractWidget @@ -12,7 +11,8 @@ export default { created() { this.$emit('setConfig', false) }, - template: `
+ template: ` +
{{ config.title }}

{{ config.msg }}

` diff --git a/public/js/components/DashboardWidget/News.js b/public/js/components/DashboardWidget/News.js index f7acb504b..2946e24b1 100644 --- a/public/js/components/DashboardWidget/News.js +++ b/public/js/components/DashboardWidget/News.js @@ -1,89 +1,90 @@ 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: { - getNewsWidgetStyle() { - return this.width == 1 ? "padding: 1rem 1rem;" : "padding: 0px;" - }, - newsList() { - //Return news amount depending on widget width and size - let quantity = this.width; + name: "WidgetsNews", + components: {BsModal}, + data: () => ({ + allNewsList: [], + singleNews: {}, + }), + mixins: [AbstractWidget], + computed: { + getNewsWidgetStyle() { + return this.width == 1 ? "padding: 1rem 1rem;" : "padding: 0px;" + }, + newsList() { + //Return news amount depending on widget width and size + let quantity = this.width; - if (this.width === 1) { - quantity = this.height === 1 ? 4 : 10; - } + if (this.width === 1) { + quantity = this.height === 1 ? 4 : 10; + } - return this.allNewsList.slice(0, quantity); - }, - placeHolderImgURL: function () { - return ( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - "skin/images/fh_technikum_wien_illustration_klein.png" - ); - }, - }, - created() { - this.$fhcApi.factory.cms - .news(MAX_LOADED_NEWS) - .then((res) => { - this.allNewsList = res.data; - }) - .catch((err) => { - console.error("ERROR: ", err.response.data); - }); + return this.allNewsList.slice(0, quantity); + }, + placeHolderImgURL: function () { + return ( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + "skin/images/fh_technikum_wien_illustration_klein.png" + ); + }, + }, + created() { + this.$fhcApi.factory.cms + .news(MAX_LOADED_NEWS) + .then((res) => { + this.allNewsList = res.data; + }) + .catch((err) => { + console.error("ERROR: ", err.response.data); + }); - this.$emit("setConfig", false); - }, - methods: { - contentURI: function (content_id) { - return ( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - "/CisVue/Cms/content/" + - content_id - ); - }, - allNewsURI: function () { - return ( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - "/CisVue/Cms/news" - ); - }, - setSingleNews(singleNews) { - this.singleNews = singleNews; - this.$refs.newsModal.show(); - }, - }, - template: /*html*/ `
- -
-
-
-
- {{ news.content_obj.betreff?news.content_obj.betreff:getDate(news.insertamum) }}
- {{ formatDateTime(news.insertamum) }} + this.$emit("setConfig", false); + }, + methods: { + contentURI: function (content_id) { + return ( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/CisVue/Cms/content/" + + content_id + ); + }, + allNewsURI: function () { + return ( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/CisVue/Cms/news" + ); + }, + setSingleNews(singleNews) { + this.singleNews = singleNews; + this.$refs.newsModal.show(); + }, + }, + template: /*html*/ ` +
+
+ +
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
`, }; diff --git a/public/js/components/DashboardWidget/Url.js b/public/js/components/DashboardWidget/Url.js index 2ab3c9fe4..aee73752f 100644 --- a/public/js/components/DashboardWidget/Url.js +++ b/public/js/components/DashboardWidget/Url.js @@ -1,7 +1,7 @@ import AbstractWidget from './Abstract'; export default { - name: "WidgetsUrl", + name: "WidgetsUrl", mixins: [AbstractWidget], inject: { editModeIsActive: { @@ -9,119 +9,117 @@ export default { default: false } }, - data: () => ({ - title_input: "", - url_input: "", - validation:{ - invalidURL: false, - invalidTitel:false, - } - }), - - computed: { - tagName() { - return this.config.tag !== undefined && this.config.tag.length > 0 - ? this.config.tag - : this.$p.t("bookmark", "myBookmarks"); - }, - emptyBookmarks() { - if (this.shared instanceof Array && this.shared.length == 0) return true; + data: () => ({ + title_input: "", + url_input: "", + validation: { + invalidURL: false, + invalidTitel: false, + } + }), - if (!this.shared) return true; + computed: { + tagName() { + return this.config.tag !== undefined && this.config.tag.length > 0 + ? this.config.tag + : this.$p.t("bookmark", "myBookmarks"); + }, + emptyBookmarks() { + if (this.shared instanceof Array && this.shared.length == 0) return true; - return false; - }, - }, - methods: { - isValidationSuccessfull(){ - // validate the input fields - if (this.title_input.length === 0) { - this.$fhcAlert.alertError(this.$p.t("bookmark", "invalidTitel")); - this.validation.invalidTitel = true; - } - if (!URL.canParse(this.url_input)) { - this.$fhcAlert.alertError(this.$p.t("bookmark", "invalidUrl")); - this.validation.invalidURL = true; - } + if (!this.shared) return true; - return !Object.values(this.validation).some(value => value === true); + return false; + }, }, - async fetchBookmarks() { - await this.$fhcApi.factory.bookmark - .getBookmarks() - .then((res) => res.data) - .then((result) => { - this.shared = result; - }) - .catch(this.$fhcAlert.handleSystemError); - }, - addLink() { - // reset is-invalid css on url input field - for(let key of Object.keys(this.validation)){ - this.validation[key] = false; - } - - // early return if validation failed - if (!this.isValidationSuccessfull()) return; - - this.$fhcApi.factory.bookmark - .insert({ - tag: this.config.tag, - title: this.title_input, - url: this.url_input, - }) - .then((res) => res.data) - .then((result) => { - this.$fhcAlert.alertInfo(this.$p.t("bookmark", "bookmarkAdded")); - // refetch the bookmarks to see the updates - this.fetchBookmarks(); - }) - .catch(this.$fhcAlert.handleSystemError); + methods: { + isValidationSuccessfull() { + // validate the input fields + if (this.title_input.length === 0) { + this.$fhcAlert.alertError(this.$p.t("bookmark", "invalidTitel")); + this.validation.invalidTitel = true; + } + if (!URL.canParse(this.url_input)) { + this.$fhcAlert.alertError(this.$p.t("bookmark", "invalidUrl")); + this.validation.invalidURL = true; + } - // reset the values for the title and url inputs - this.title_input = ""; - this.url_input = ""; - }, - async removeLink(bookmark_id) { - let isConfirmed = await this.$fhcAlert.confirmDelete(); - - // early return if the confirm dialog was not confirmed - if(!isConfirmed) return; - - this.$fhcApi.factory.bookmark - .delete(bookmark_id) - .then((res) => res.data) - .then((result) => { - this.$fhcAlert.alertInfo(this.$p.t("bookmark", "bookmarkDeleted")); - // refetch the bookmarks to see the updates - this.fetchBookmarks(); - }) - .catch(this.$fhcAlert.handleSystemError); - }, - }, - async mounted() { - await this.fetchBookmarks(); - }, - created() - { - // - // this.$emit('setConfig', true); -> use this to enable widget config mode if needed - }, - template: /*html*/ ` + return !Object.values(this.validation).some(value => value === true); + }, + async fetchBookmarks() { + await this.$fhcApi.factory.bookmark + .getBookmarks() + .then((res) => res.data) + .then((result) => { + this.shared = result; + }) + .catch(this.$fhcAlert.handleSystemError); + }, + addLink() { + // reset is-invalid css on url input field + for (let key of Object.keys(this.validation)) { + this.validation[key] = false; + } + + // early return if validation failed + if (!this.isValidationSuccessfull()) return; + + this.$fhcApi.factory.bookmark + .insert({ + tag: this.config.tag, + title: this.title_input, + url: this.url_input, + }) + .then((res) => res.data) + .then((result) => { + this.$fhcAlert.alertInfo(this.$p.t("bookmark", "bookmarkAdded")); + // refetch the bookmarks to see the updates + this.fetchBookmarks(); + }) + .catch(this.$fhcAlert.handleSystemError); + + // reset the values for the title and url inputs + this.title_input = ""; + this.url_input = ""; + }, + async removeLink(bookmark_id) { + let isConfirmed = await this.$fhcAlert.confirmDelete(); + + // early return if the confirm dialog was not confirmed + if (!isConfirmed) return; + + this.$fhcApi.factory.bookmark + .delete(bookmark_id) + .then((res) => res.data) + .then((result) => { + this.$fhcAlert.alertInfo(this.$p.t("bookmark", "bookmarkDeleted")); + // refetch the bookmarks to see the updates + this.fetchBookmarks(); + }) + .catch(this.$fhcAlert.handleSystemError); + }, + }, + async mounted() { + await this.fetchBookmarks(); + }, + created() { + // + // this.$emit('setConfig', true); -> use this to enable widget config mode if needed + }, + template: /*html*/ `